forked from MoonsideGames/Refresh
				
			Compare commits
	
		
			No commits in common. "11d262dc1113606ec594c2d5097ceb0a62db0067" and "ade74d73fe32bcaf43e7d5692444df0f7aa3f893" have entirely different histories. 
		
	
	
		
			11d262dc11
			...
			ade74d73fe
		
	
		|  | @ -281,7 +281,11 @@ typedef enum Refresh_BlendFactor | |||
| 	REFRESH_BLENDFACTOR_ONE_MINUS_DST_ALPHA, | ||||
| 	REFRESH_BLENDFACTOR_CONSTANT_COLOR, | ||||
| 	REFRESH_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR, | ||||
| 	REFRESH_BLENDFACTOR_SRC_ALPHA_SATURATE | ||||
| 	REFRESH_BLENDFACTOR_SRC_ALPHA_SATURATE, | ||||
| 	REFRESH_BLENDFACTOR_SRC1_COLOR, | ||||
| 	REFRESH_BLENDFACTOR_ONE_MINUS_SRC1_COLOR, | ||||
| 	REFRESH_BLENDFACTOR_SRC1_ALPHA, | ||||
| 	REFRESH_BLENDFACTOR_ONE_MINUS_SRC1_ALPHA | ||||
| } Refresh_BlendFactor; | ||||
| 
 | ||||
| typedef enum Refresh_ColorComponentFlagBits | ||||
|  | @ -376,14 +380,6 @@ typedef struct Refresh_TextureSlice | |||
| 	uint32_t level; | ||||
| } Refresh_TextureSlice; | ||||
| 
 | ||||
| typedef struct Refresh_IndirectDrawCommand | ||||
| { | ||||
| 	uint32_t vertexCount; | ||||
| 	uint32_t instanceCount; | ||||
| 	uint32_t firstVertex; | ||||
| 	uint32_t firstInstance; | ||||
| } Refresh_IndirectDrawCommand; | ||||
| 
 | ||||
| /* State structures */ | ||||
| 
 | ||||
| typedef struct Refresh_SamplerStateCreateInfo | ||||
|  | @ -450,6 +446,12 @@ typedef struct Refresh_ColorAttachmentBlendState | |||
| 	Refresh_ColorComponentFlags colorWriteMask; | ||||
| } Refresh_ColorAttachmentBlendState; | ||||
| 
 | ||||
| typedef struct Refresh_ComputePipelineLayoutCreateInfo | ||||
| { | ||||
| 	uint32_t bufferBindingCount; | ||||
| 	uint32_t imageBindingCount; | ||||
| } Refresh_ComputePipelineLayoutCreateInfo; | ||||
| 
 | ||||
| typedef struct Refresh_ShaderModuleCreateInfo | ||||
| { | ||||
| 	size_t codeSize; | ||||
|  | @ -488,6 +490,7 @@ typedef struct Refresh_ComputeShaderInfo | |||
| 
 | ||||
| typedef struct Refresh_RasterizerState | ||||
| { | ||||
| 	uint8_t depthClampEnable; | ||||
| 	Refresh_FillMode fillMode; | ||||
| 	Refresh_CullMode cullMode; | ||||
| 	Refresh_FrontFace frontFace; | ||||
|  | @ -674,7 +677,6 @@ REFRESHAPI void Refresh_DrawPrimitives( | |||
| ); | ||||
| 
 | ||||
| /* Similar to Refresh_DrawPrimitives, but draw parameters are set from a buffer.
 | ||||
|  * The buffer layout should match the layout of Refresh_IndirectDrawCommand. | ||||
|  * | ||||
|  * buffer:              A buffer containing draw parameters. | ||||
|  * offsetInBytes:       The offset to start reading from the draw buffer. | ||||
|  | @ -758,11 +760,6 @@ REFRESHAPI Refresh_Buffer* Refresh_CreateBuffer( | |||
| /* Setters */ | ||||
| 
 | ||||
| /* Uploads image data to a texture object.
 | ||||
|  * | ||||
|  * NOTE:  | ||||
|  *	DO NOT expect this to execute in sequence relative to other commands! | ||||
|  *	Calling SetTextureData in a command buffer that also references the | ||||
|  *	texture may result in undefined behavior. | ||||
|  * | ||||
|  * 	textureSlice:		The texture slice to be updated. | ||||
|  * 	data:				A pointer to the image data. | ||||
|  | @ -1039,9 +1036,7 @@ REFRESHAPI void Refresh_SetScissor( | |||
| 	Refresh_Rect *scissor | ||||
| ); | ||||
| 
 | ||||
| /* Binds vertex buffers for use with subsequent draw calls.
 | ||||
|  * Note that this may only be called after binding a graphics pipeline. | ||||
|  */ | ||||
| /* Binds vertex buffers for use with subsequent draw calls. */ | ||||
| REFRESHAPI void Refresh_BindVertexBuffers( | ||||
| 	Refresh_Device *device, | ||||
| 	Refresh_CommandBuffer *commandBuffer, | ||||
|  |  | |||
|  | @ -126,7 +126,11 @@ static TEMPLATE_BLEND_FACTOR_TYPE RefreshToTEMPLATE_BlendFactor[] = | |||
| 	0,	/* ONE_MINUS_DST_ALPHA */ | ||||
| 	0,	/* CONSTANT_COLOR */ | ||||
| 	0,	/* ONE_MINUS_CONSTANT_COLOR */ | ||||
| 	0	/* SRC_ALPHA_SATURATE */ | ||||
| 	0,	/* SRC_ALPHA_SATURATE */ | ||||
| 	0,	/* SRC1_COLOR */ | ||||
| 	0,	/* ONE_MINUS_SRC1_COLOR */ | ||||
| 	0,	/* SRC1_ALPHA */ | ||||
| 	0	/* ONE_MINUS_SRC1_ALPHA */ | ||||
| }; | ||||
| 
 | ||||
| static TEMPLATE_BLEND_OP_TYPE RefreshToTEMPLATE_BlendOp[] = | ||||
|  |  | |||
|  | @ -287,7 +287,11 @@ static VkBlendFactor RefreshToVK_BlendFactor[] = | |||
| 	VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR, | ||||
| 	VK_BLEND_FACTOR_CONSTANT_ALPHA, | ||||
| 	VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA, | ||||
| 	VK_BLEND_FACTOR_SRC_ALPHA_SATURATE | ||||
| 	VK_BLEND_FACTOR_SRC_ALPHA_SATURATE, | ||||
| 	VK_BLEND_FACTOR_SRC1_COLOR, | ||||
| 	VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR, | ||||
| 	VK_BLEND_FACTOR_SRC1_ALPHA, | ||||
| 	VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA | ||||
| }; | ||||
| 
 | ||||
| static VkBlendOp RefreshToVK_BlendOp[] = | ||||
|  | @ -3822,7 +3826,8 @@ static void VULKAN_INTERNAL_BindUniformBuffer( | |||
| 
 | ||||
| static uint8_t VULKAN_INTERNAL_CreateUniformBuffer( | ||||
| 	VulkanRenderer *renderer, | ||||
| 	VulkanUniformBufferPool *bufferPool | ||||
| 	VulkanUniformBufferPool *bufferPool, | ||||
| 	VkDeviceSize blockSize | ||||
| ) { | ||||
| 	VulkanResourceAccessType resourceAccessType; | ||||
| 	VkDescriptorSetLayout descriptorSetLayout; | ||||
|  | @ -4028,7 +4033,7 @@ static VulkanUniformBuffer* VULKAN_INTERNAL_AcquireUniformBufferFromPool( | |||
| 
 | ||||
| 	if (bufferPool->availableBufferCount == 0) | ||||
| 	{ | ||||
| 		if (!VULKAN_INTERNAL_CreateUniformBuffer(renderer, bufferPool)) | ||||
| 		if (!VULKAN_INTERNAL_CreateUniformBuffer(renderer, bufferPool, blockSize)) | ||||
| 		{ | ||||
| 			SDL_UnlockMutex(bufferPool->lock); | ||||
| 			Refresh_LogError("Failed to create uniform buffer!"); | ||||
|  | @ -6133,7 +6138,7 @@ static Refresh_GraphicsPipeline* VULKAN_CreateGraphicsPipeline( | |||
| 	rasterizationStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
| 	rasterizationStateCreateInfo.pNext = NULL; | ||||
| 	rasterizationStateCreateInfo.flags = 0; | ||||
| 	rasterizationStateCreateInfo.depthClampEnable = VK_FALSE; | ||||
| 	rasterizationStateCreateInfo.depthClampEnable = pipelineCreateInfo->rasterizerState.depthClampEnable; | ||||
| 	rasterizationStateCreateInfo.rasterizerDiscardEnable = VK_FALSE; | ||||
| 	rasterizationStateCreateInfo.polygonMode = RefreshToVK_PolygonMode[ | ||||
| 		pipelineCreateInfo->rasterizerState.fillMode | ||||
|  | @ -6840,6 +6845,12 @@ static void VULKAN_SetTextureData( | |||
| 	uint32_t bufferRowLength; | ||||
| 	uint32_t bufferImageHeight; | ||||
| 
 | ||||
| 	if (vulkanCommandBuffer->renderPassInProgress) | ||||
| 	{ | ||||
| 		Refresh_LogError("Cannot perform buffer updates mid-render pass!"); | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	transferBuffer = VULKAN_INTERNAL_AcquireTransferBuffer( | ||||
| 		renderer, | ||||
| 		vulkanCommandBuffer, | ||||
|  | @ -7333,6 +7344,12 @@ static void VULKAN_SetBufferData( | |||
| 	VkBufferCopy bufferCopy; | ||||
| 	VulkanResourceAccessType accessType = vulkanBuffer->resourceAccessType; | ||||
| 
 | ||||
| 	if (vulkanCommandBuffer->renderPassInProgress) | ||||
| 	{ | ||||
| 		Refresh_LogError("Cannot perform buffer updates mid-render pass!"); | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	transferBuffer = VULKAN_INTERNAL_AcquireTransferBuffer( | ||||
| 		renderer, | ||||
| 		vulkanCommandBuffer, | ||||
|  | @ -7460,6 +7477,18 @@ static uint32_t VULKAN_PushFragmentShaderUniforms( | |||
| 	VulkanGraphicsPipeline* graphicsPipeline = vulkanCommandBuffer->currentGraphicsPipeline; | ||||
| 	uint32_t offset; | ||||
| 
 | ||||
| 	if (graphicsPipeline == NULL) | ||||
| 	{ | ||||
| 		Refresh_LogError("Cannot push uniforms if a pipeline is not bound!"); | ||||
| 		return 0; | ||||
| 	} | ||||
| 
 | ||||
| 	if (graphicsPipeline->fragmentUniformBlockSize == 0) | ||||
| 	{ | ||||
| 		Refresh_LogError("Bound pipeline's fragment stage does not declare uniforms!"); | ||||
| 		return 0; | ||||
| 	} | ||||
| 
 | ||||
| 	if ( | ||||
| 		vulkanCommandBuffer->fragmentUniformBuffer->offset + | ||||
| 		graphicsPipeline->fragmentUniformBlockSize >= | ||||
|  | @ -7502,6 +7531,18 @@ static uint32_t VULKAN_PushComputeShaderUniforms( | |||
| 	VulkanComputePipeline* computePipeline = vulkanCommandBuffer->currentComputePipeline; | ||||
| 	uint32_t offset; | ||||
| 
 | ||||
| 	if (computePipeline == NULL) | ||||
| 	{ | ||||
| 		Refresh_LogError("Cannot push uniforms if a pipeline is not bound!"); | ||||
| 		return 0; | ||||
| 	} | ||||
| 
 | ||||
| 	if (computePipeline->uniformBlockSize == 0) | ||||
| 	{ | ||||
| 		Refresh_LogError("Bound compute pipeline does not declare uniforms!"); | ||||
| 		return 0; | ||||
| 	} | ||||
| 
 | ||||
| 	if ( | ||||
| 		vulkanCommandBuffer->computeUniformBuffer->offset + | ||||
| 		computePipeline->uniformBlockSize >= | ||||
|  | @ -8250,6 +8291,12 @@ static void VULKAN_SetViewport( | |||
| 	VulkanRenderer* renderer = (VulkanRenderer*) driverData; | ||||
| 	VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer; | ||||
| 
 | ||||
| 	if (!vulkanCommandBuffer->renderPassInProgress) | ||||
| 	{ | ||||
| 		Refresh_LogError("Illegal to set viewport state outside of a render pass!"); | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	VULKAN_INTERNAL_SetCurrentViewport( | ||||
| 		vulkanCommandBuffer, | ||||
| 		viewport | ||||
|  | @ -8281,6 +8328,12 @@ static void VULKAN_SetScissor( | |||
| 	VulkanRenderer* renderer = (VulkanRenderer*) driverData; | ||||
| 	VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer; | ||||
| 
 | ||||
| 	if (!vulkanCommandBuffer->renderPassInProgress) | ||||
| 	{ | ||||
| 		Refresh_LogError("Illegal to set scissor state outside of a render pass!"); | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	VULKAN_INTERNAL_SetCurrentScissor( | ||||
| 		vulkanCommandBuffer, | ||||
| 		scissor | ||||
|  | @ -8317,6 +8370,12 @@ static void VULKAN_BeginRenderPass( | |||
| 	uint32_t framebufferWidth = UINT32_MAX; | ||||
| 	uint32_t framebufferHeight = UINT32_MAX; | ||||
| 
 | ||||
| 	if (colorAttachmentCount == 0 && depthStencilAttachmentInfo == NULL) | ||||
| 	{ | ||||
| 		Refresh_LogError("Render pass must have at least one render target!"); | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	/* The framebuffer cannot be larger than the smallest attachment. */ | ||||
| 
 | ||||
| 	for (i = 0; i < colorAttachmentCount; i += 1) | ||||
|  | @ -8627,6 +8686,12 @@ static void VULKAN_BindGraphicsPipeline( | |||
| 	VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer; | ||||
| 	VulkanGraphicsPipeline* pipeline = (VulkanGraphicsPipeline*) graphicsPipeline; | ||||
| 
 | ||||
| 	if (!vulkanCommandBuffer->renderPassInProgress) | ||||
| 	{ | ||||
| 		Refresh_LogError("Illegal to bind a graphics pipeline outside of a render pass!"); | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	if (	vulkanCommandBuffer->vertexUniformBuffer != renderer->dummyVertexUniformBuffer && | ||||
| 		vulkanCommandBuffer->vertexUniformBuffer != NULL | ||||
| 	) { | ||||
|  | @ -9351,6 +9416,13 @@ static Refresh_Texture* VULKAN_AcquireSwapchainTexture( | |||
| 	VulkanPresentData *presentData; | ||||
| 
 | ||||
| 	windowData = VULKAN_INTERNAL_FetchWindowData(windowHandle); | ||||
| 
 | ||||
| 	if (windowData == NULL) | ||||
| 	{ | ||||
| 		Refresh_LogError("Cannot acquire swapchain texture, window has not been claimed!"); | ||||
| 		return NULL; | ||||
| 	} | ||||
| 
 | ||||
| 	swapchainData = windowData->swapchainData; | ||||
| 
 | ||||
| 	/* Window is claimed but swapchain is invalid! */ | ||||
|  | @ -10535,9 +10607,10 @@ static uint8_t VULKAN_INTERNAL_CreateLogicalDevice( | |||
| 	/* specifying used device features */ | ||||
| 
 | ||||
| 	SDL_zero(deviceFeatures); | ||||
| 	deviceFeatures.occlusionQueryPrecise = VK_TRUE; | ||||
| 	deviceFeatures.fillModeNonSolid = VK_TRUE; | ||||
| 	deviceFeatures.depthClamp = VK_TRUE; | ||||
| 	deviceFeatures.samplerAnisotropy = VK_TRUE; | ||||
| 	deviceFeatures.multiDrawIndirect = VK_TRUE; | ||||
| 
 | ||||
| 	/* creating the logical device */ | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue