forked from MoonsideGames/Refresh
				
			Compare commits
	
		
			2 Commits 
		
	
	
		
			6dc3ca7777
			...
			a258b9fabb
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | a258b9fabb | |
|  | a0b18dc32e | 
|  | @ -169,10 +169,7 @@ typedef enum Refresh_SampleCount | ||||||
| 	REFRESH_SAMPLECOUNT_1, | 	REFRESH_SAMPLECOUNT_1, | ||||||
| 	REFRESH_SAMPLECOUNT_2, | 	REFRESH_SAMPLECOUNT_2, | ||||||
| 	REFRESH_SAMPLECOUNT_4, | 	REFRESH_SAMPLECOUNT_4, | ||||||
| 	REFRESH_SAMPLECOUNT_8, | 	REFRESH_SAMPLECOUNT_8 | ||||||
| 	REFRESH_SAMPLECOUNT_16, |  | ||||||
| 	REFRESH_SAMPLECOUNT_32, |  | ||||||
| 	REFRESH_SAMPLECOUNT_64 |  | ||||||
| } Refresh_SampleCount; | } Refresh_SampleCount; | ||||||
| 
 | 
 | ||||||
| typedef enum Refresh_CubeMapFace | typedef enum Refresh_CubeMapFace | ||||||
|  | @ -284,11 +281,7 @@ typedef enum Refresh_BlendFactor | ||||||
| 	REFRESH_BLENDFACTOR_ONE_MINUS_DST_ALPHA, | 	REFRESH_BLENDFACTOR_ONE_MINUS_DST_ALPHA, | ||||||
| 	REFRESH_BLENDFACTOR_CONSTANT_COLOR, | 	REFRESH_BLENDFACTOR_CONSTANT_COLOR, | ||||||
| 	REFRESH_BLENDFACTOR_ONE_MINUS_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; | } Refresh_BlendFactor; | ||||||
| 
 | 
 | ||||||
| typedef enum Refresh_ColorComponentFlagBits | typedef enum Refresh_ColorComponentFlagBits | ||||||
|  | @ -467,7 +460,6 @@ typedef struct Refresh_TextureCreateInfo | ||||||
| 	uint32_t height; | 	uint32_t height; | ||||||
| 	uint32_t depth; | 	uint32_t depth; | ||||||
| 	uint8_t isCube; | 	uint8_t isCube; | ||||||
| 	Refresh_SampleCount sampleCount; |  | ||||||
| 	uint32_t levelCount; | 	uint32_t levelCount; | ||||||
| 	Refresh_TextureFormat format; | 	Refresh_TextureFormat format; | ||||||
| 	Refresh_TextureUsageFlags usageFlags; | 	Refresh_TextureUsageFlags usageFlags; | ||||||
|  | @ -526,7 +518,6 @@ typedef struct Refresh_DepthStencilState | ||||||
| typedef struct Refresh_ColorAttachmentDescription | typedef struct Refresh_ColorAttachmentDescription | ||||||
| { | { | ||||||
| 	Refresh_TextureFormat format; | 	Refresh_TextureFormat format; | ||||||
| 	Refresh_SampleCount sampleCount; |  | ||||||
| 	Refresh_ColorAttachmentBlendState blendState; | 	Refresh_ColorAttachmentBlendState blendState; | ||||||
| } Refresh_ColorAttachmentDescription; | } Refresh_ColorAttachmentDescription; | ||||||
| 
 | 
 | ||||||
|  | @ -1000,11 +991,6 @@ REFRESHAPI void Refresh_QueueDestroyGraphicsPipeline( | ||||||
| /* Begins a render pass.
 | /* Begins a render pass.
 | ||||||
|  * This will also set a default viewport and scissor state. |  * This will also set a default viewport and scissor state. | ||||||
|  * |  * | ||||||
|  * renderArea: |  | ||||||
|  * 		The area affected by the render pass. |  | ||||||
|  * 		All load, store and resolve operations are restricted |  | ||||||
|  * 		to the given rectangle. |  | ||||||
|  * 		If NULL, a sensible default will be chosen. |  | ||||||
|  * colorAttachmentInfos: |  * colorAttachmentInfos: | ||||||
|  * 		A pointer to an array of Refresh_ColorAttachmentInfo structures |  * 		A pointer to an array of Refresh_ColorAttachmentInfo structures | ||||||
|  * 		that contains render targets and clear values. May be NULL. |  * 		that contains render targets and clear values. May be NULL. | ||||||
|  | @ -1014,7 +1000,6 @@ REFRESHAPI void Refresh_QueueDestroyGraphicsPipeline( | ||||||
| REFRESHAPI void Refresh_BeginRenderPass( | REFRESHAPI void Refresh_BeginRenderPass( | ||||||
| 	Refresh_Device *device, | 	Refresh_Device *device, | ||||||
| 	Refresh_CommandBuffer *commandBuffer, | 	Refresh_CommandBuffer *commandBuffer, | ||||||
| 	Refresh_Rect *renderArea, |  | ||||||
| 	Refresh_ColorAttachmentInfo *colorAttachmentInfos, | 	Refresh_ColorAttachmentInfo *colorAttachmentInfos, | ||||||
| 	uint32_t colorAttachmentCount, | 	uint32_t colorAttachmentCount, | ||||||
| 	Refresh_DepthStencilAttachmentInfo *depthStencilAttachmentInfo | 	Refresh_DepthStencilAttachmentInfo *depthStencilAttachmentInfo | ||||||
|  |  | ||||||
|  | @ -625,7 +625,6 @@ void Refresh_QueueDestroyGraphicsPipeline( | ||||||
| void Refresh_BeginRenderPass( | void Refresh_BeginRenderPass( | ||||||
| 	Refresh_Device *device, | 	Refresh_Device *device, | ||||||
| 	Refresh_CommandBuffer *commandBuffer, | 	Refresh_CommandBuffer *commandBuffer, | ||||||
| 	Refresh_Rect *renderArea, |  | ||||||
| 	Refresh_ColorAttachmentInfo *colorAttachmentInfos, | 	Refresh_ColorAttachmentInfo *colorAttachmentInfos, | ||||||
| 	uint32_t colorAttachmentCount, | 	uint32_t colorAttachmentCount, | ||||||
| 	Refresh_DepthStencilAttachmentInfo *depthStencilAttachmentInfo | 	Refresh_DepthStencilAttachmentInfo *depthStencilAttachmentInfo | ||||||
|  | @ -634,7 +633,6 @@ void Refresh_BeginRenderPass( | ||||||
| 	device->BeginRenderPass( | 	device->BeginRenderPass( | ||||||
| 		device->driverData, | 		device->driverData, | ||||||
| 		commandBuffer, | 		commandBuffer, | ||||||
| 		renderArea, |  | ||||||
| 		colorAttachmentInfos, | 		colorAttachmentInfos, | ||||||
| 		colorAttachmentCount, | 		colorAttachmentCount, | ||||||
| 		depthStencilAttachmentInfo | 		depthStencilAttachmentInfo | ||||||
|  |  | ||||||
|  | @ -395,7 +395,6 @@ struct Refresh_Device | ||||||
| 	void(*BeginRenderPass)( | 	void(*BeginRenderPass)( | ||||||
| 		Refresh_Renderer *driverData, | 		Refresh_Renderer *driverData, | ||||||
| 		Refresh_CommandBuffer *commandBuffer, | 		Refresh_CommandBuffer *commandBuffer, | ||||||
| 		Refresh_Rect *renderArea, |  | ||||||
| 		Refresh_ColorAttachmentInfo *colorAttachmentInfos, | 		Refresh_ColorAttachmentInfo *colorAttachmentInfos, | ||||||
| 		uint32_t colorAttachmentCount, | 		uint32_t colorAttachmentCount, | ||||||
| 		Refresh_DepthStencilAttachmentInfo *depthStencilAttachmentInfo | 		Refresh_DepthStencilAttachmentInfo *depthStencilAttachmentInfo | ||||||
|  |  | ||||||
|  | @ -127,10 +127,6 @@ static TEMPLATE_BLEND_FACTOR_TYPE RefreshToTEMPLATE_BlendFactor[] = | ||||||
| 	0,	/* CONSTANT_COLOR */ | 	0,	/* CONSTANT_COLOR */ | ||||||
| 	0,	/* ONE_MINUS_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[] = | static TEMPLATE_BLEND_OP_TYPE RefreshToTEMPLATE_BlendOp[] = | ||||||
|  |  | ||||||
|  | @ -287,11 +287,7 @@ static VkBlendFactor RefreshToVK_BlendFactor[] = | ||||||
| 	VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR, | 	VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR, | ||||||
| 	VK_BLEND_FACTOR_CONSTANT_ALPHA, | 	VK_BLEND_FACTOR_CONSTANT_ALPHA, | ||||||
| 	VK_BLEND_FACTOR_ONE_MINUS_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[] = | static VkBlendOp RefreshToVK_BlendOp[] = | ||||||
|  | @ -971,6 +967,7 @@ typedef struct RenderPassHash | ||||||
| 	RenderPassColorTargetDescription colorTargetDescriptions[MAX_COLOR_TARGET_BINDINGS]; | 	RenderPassColorTargetDescription colorTargetDescriptions[MAX_COLOR_TARGET_BINDINGS]; | ||||||
| 	uint32_t colorAttachmentCount; | 	uint32_t colorAttachmentCount; | ||||||
| 	RenderPassDepthStencilTargetDescription depthStencilTargetDescription; | 	RenderPassDepthStencilTargetDescription depthStencilTargetDescription; | ||||||
|  | 	Refresh_SampleCount colorAttachmentSampleCount; | ||||||
| } RenderPassHash; | } RenderPassHash; | ||||||
| 
 | 
 | ||||||
| typedef struct RenderPassHashMap | typedef struct RenderPassHashMap | ||||||
|  | @ -997,6 +994,11 @@ static inline uint8_t RenderPassHash_Compare( | ||||||
| 		return 0; | 		return 0; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	if (a->colorAttachmentSampleCount != b->colorAttachmentSampleCount) | ||||||
|  | 	{ | ||||||
|  | 		return 0; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	for (i = 0; i < a->colorAttachmentCount; i += 1) | 	for (i = 0; i < a->colorAttachmentCount; i += 1) | ||||||
| 	{ | 	{ | ||||||
| 		if (a->colorTargetDescriptions[i].format != b->colorTargetDescriptions[i].format) | 		if (a->colorTargetDescriptions[i].format != b->colorTargetDescriptions[i].format) | ||||||
|  | @ -2023,6 +2025,29 @@ static inline VkDeviceSize VULKAN_INTERNAL_BytesPerImage( | ||||||
| 	return blocksPerRow * blocksPerColumn * VULKAN_INTERNAL_BytesPerPixel(format); | 	return blocksPerRow * blocksPerColumn * VULKAN_INTERNAL_BytesPerPixel(format); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static inline Refresh_SampleCount VULKAN_INTERNAL_GetMaxMultiSampleCount( | ||||||
|  | 	VulkanRenderer *renderer, | ||||||
|  | 	Refresh_SampleCount multiSampleCount | ||||||
|  | ) { | ||||||
|  | 	VkSampleCountFlags flags = renderer->physicalDeviceProperties.properties.limits.framebufferColorSampleCounts; | ||||||
|  | 	Refresh_SampleCount maxSupported = REFRESH_SAMPLECOUNT_1; | ||||||
|  | 
 | ||||||
|  | 	if (flags & VK_SAMPLE_COUNT_8_BIT) | ||||||
|  | 	{ | ||||||
|  | 		maxSupported = REFRESH_SAMPLECOUNT_8; | ||||||
|  | 	} | ||||||
|  | 	else if (flags & VK_SAMPLE_COUNT_4_BIT) | ||||||
|  | 	{ | ||||||
|  | 		maxSupported = REFRESH_SAMPLECOUNT_4; | ||||||
|  | 	} | ||||||
|  | 	else if (flags & VK_SAMPLE_COUNT_2_BIT) | ||||||
|  | 	{ | ||||||
|  | 		maxSupported = REFRESH_SAMPLECOUNT_2; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return SDL_min(multiSampleCount, maxSupported); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* Memory Management */ | /* Memory Management */ | ||||||
| 
 | 
 | ||||||
| static inline VkDeviceSize VULKAN_INTERNAL_NextHighestAlignment( | static inline VkDeviceSize VULKAN_INTERNAL_NextHighestAlignment( | ||||||
|  | @ -5431,6 +5456,12 @@ static VulkanRenderTarget* VULKAN_INTERNAL_CreateRenderTarget( | ||||||
| 	/* create resolve target for multisample */ | 	/* create resolve target for multisample */ | ||||||
| 	if (multisampleCount > REFRESH_SAMPLECOUNT_1) | 	if (multisampleCount > REFRESH_SAMPLECOUNT_1) | ||||||
| 	{ | 	{ | ||||||
|  | 		/* Find a compatible sample count to use */ | ||||||
|  | 		multisampleCount = VULKAN_INTERNAL_GetMaxMultiSampleCount( | ||||||
|  | 			renderer, | ||||||
|  | 			multisampleCount | ||||||
|  | 		); | ||||||
|  | 
 | ||||||
| 		renderTarget->multisampleTexture = | 		renderTarget->multisampleTexture = | ||||||
| 			VULKAN_INTERNAL_CreateTexture( | 			VULKAN_INTERNAL_CreateTexture( | ||||||
| 				renderer, | 				renderer, | ||||||
|  | @ -5576,8 +5607,12 @@ static VkRenderPass VULKAN_INTERNAL_CreateRenderPass( | ||||||
| 			colorAttachmentInfos[i].sampleCount | 			colorAttachmentInfos[i].sampleCount | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		if (renderTarget->multisampleTexture != NULL) | 		if (renderTarget->multisampleCount > VK_SAMPLE_COUNT_1_BIT) | ||||||
| 		{ | 		{ | ||||||
|  | 			multisampling = 1; | ||||||
|  | 
 | ||||||
|  | 			/* Transition the multisample attachment */ | ||||||
|  | 
 | ||||||
| 			VULKAN_INTERNAL_ImageMemoryBarrier( | 			VULKAN_INTERNAL_ImageMemoryBarrier( | ||||||
| 				renderer, | 				renderer, | ||||||
| 				commandBuffer->commandBuffer, | 				commandBuffer->commandBuffer, | ||||||
|  | @ -5591,11 +5626,6 @@ static VkRenderPass VULKAN_INTERNAL_CreateRenderPass( | ||||||
| 				renderTarget->multisampleTexture->image, | 				renderTarget->multisampleTexture->image, | ||||||
| 				&renderTarget->multisampleTexture->resourceAccessType | 				&renderTarget->multisampleTexture->resourceAccessType | ||||||
| 			); | 			); | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		if (renderTarget->multisampleCount > VK_SAMPLE_COUNT_1_BIT) |  | ||||||
| 		{ |  | ||||||
| 			multisampling = 1; |  | ||||||
| 
 | 
 | ||||||
| 			/* Resolve attachment and multisample attachment */ | 			/* Resolve attachment and multisample attachment */ | ||||||
| 
 | 
 | ||||||
|  | @ -5606,9 +5636,8 @@ static VkRenderPass VULKAN_INTERNAL_CreateRenderPass( | ||||||
| 			attachmentDescriptions[attachmentDescriptionCount].loadOp = RefreshToVK_LoadOp[ | 			attachmentDescriptions[attachmentDescriptionCount].loadOp = RefreshToVK_LoadOp[ | ||||||
| 				colorAttachmentInfos[i].loadOp | 				colorAttachmentInfos[i].loadOp | ||||||
| 			]; | 			]; | ||||||
| 			attachmentDescriptions[attachmentDescriptionCount].storeOp = RefreshToVK_StoreOp[ | 			attachmentDescriptions[attachmentDescriptionCount].storeOp = | ||||||
| 				colorAttachmentInfos[i].storeOp | 				VK_ATTACHMENT_STORE_OP_STORE; /* Always store the resolve texture */ | ||||||
| 			]; |  | ||||||
| 			attachmentDescriptions[attachmentDescriptionCount].stencilLoadOp = | 			attachmentDescriptions[attachmentDescriptionCount].stencilLoadOp = | ||||||
| 				VK_ATTACHMENT_LOAD_OP_DONT_CARE; | 				VK_ATTACHMENT_LOAD_OP_DONT_CARE; | ||||||
| 			attachmentDescriptions[attachmentDescriptionCount].stencilStoreOp = | 			attachmentDescriptions[attachmentDescriptionCount].stencilStoreOp = | ||||||
|  | @ -5661,9 +5690,8 @@ static VkRenderPass VULKAN_INTERNAL_CreateRenderPass( | ||||||
| 			attachmentDescriptions[attachmentDescriptionCount].loadOp = RefreshToVK_LoadOp[ | 			attachmentDescriptions[attachmentDescriptionCount].loadOp = RefreshToVK_LoadOp[ | ||||||
| 				colorAttachmentInfos[i].loadOp | 				colorAttachmentInfos[i].loadOp | ||||||
| 			]; | 			]; | ||||||
| 			attachmentDescriptions[attachmentDescriptionCount].storeOp = RefreshToVK_StoreOp[ | 			attachmentDescriptions[attachmentDescriptionCount].storeOp = | ||||||
| 				colorAttachmentInfos[i].storeOp | 				VK_ATTACHMENT_STORE_OP_STORE; /* Always store non-MSAA textures */ | ||||||
| 			]; |  | ||||||
| 			attachmentDescriptions[attachmentDescriptionCount].stencilLoadOp = | 			attachmentDescriptions[attachmentDescriptionCount].stencilLoadOp = | ||||||
| 				VK_ATTACHMENT_LOAD_OP_DONT_CARE; | 				VK_ATTACHMENT_LOAD_OP_DONT_CARE; | ||||||
| 			attachmentDescriptions[attachmentDescriptionCount].stencilStoreOp = | 			attachmentDescriptions[attachmentDescriptionCount].stencilStoreOp = | ||||||
|  | @ -5778,7 +5806,8 @@ static VkRenderPass VULKAN_INTERNAL_CreateRenderPass( | ||||||
| 
 | 
 | ||||||
| static VkRenderPass VULKAN_INTERNAL_CreateTransientRenderPass( | static VkRenderPass VULKAN_INTERNAL_CreateTransientRenderPass( | ||||||
| 	VulkanRenderer *renderer, | 	VulkanRenderer *renderer, | ||||||
| 	Refresh_GraphicsPipelineAttachmentInfo attachmentInfo | 	Refresh_GraphicsPipelineAttachmentInfo attachmentInfo, | ||||||
|  | 	Refresh_SampleCount sampleCount | ||||||
| ) { | ) { | ||||||
| 	VkAttachmentDescription attachmentDescriptions[2 * MAX_COLOR_TARGET_BINDINGS + 1]; | 	VkAttachmentDescription attachmentDescriptions[2 * MAX_COLOR_TARGET_BINDINGS + 1]; | ||||||
| 	VkAttachmentReference colorAttachmentReferences[MAX_COLOR_TARGET_BINDINGS]; | 	VkAttachmentReference colorAttachmentReferences[MAX_COLOR_TARGET_BINDINGS]; | ||||||
|  | @ -5800,7 +5829,7 @@ static VkRenderPass VULKAN_INTERNAL_CreateTransientRenderPass( | ||||||
| 	{ | 	{ | ||||||
| 		attachmentDescription = attachmentInfo.colorAttachmentDescriptions[i]; | 		attachmentDescription = attachmentInfo.colorAttachmentDescriptions[i]; | ||||||
| 
 | 
 | ||||||
| 		if (attachmentDescription.sampleCount > REFRESH_SAMPLECOUNT_1) | 		if (sampleCount > REFRESH_SAMPLECOUNT_1) | ||||||
| 		{ | 		{ | ||||||
| 			multisampling = 1; | 			multisampling = 1; | ||||||
| 
 | 
 | ||||||
|  | @ -5829,7 +5858,7 @@ static VkRenderPass VULKAN_INTERNAL_CreateTransientRenderPass( | ||||||
| 				attachmentDescription.format | 				attachmentDescription.format | ||||||
| 			]; | 			]; | ||||||
| 			attachmentDescriptions[attachmentDescriptionCount].samples = RefreshToVK_SampleCount[ | 			attachmentDescriptions[attachmentDescriptionCount].samples = RefreshToVK_SampleCount[ | ||||||
| 				attachmentDescription.sampleCount | 				sampleCount | ||||||
| 			]; | 			]; | ||||||
| 			attachmentDescriptions[attachmentDescriptionCount].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; | 			attachmentDescriptions[attachmentDescriptionCount].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; | ||||||
| 			attachmentDescriptions[attachmentDescriptionCount].storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; | 			attachmentDescriptions[attachmentDescriptionCount].storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; | ||||||
|  | @ -5960,6 +5989,7 @@ static Refresh_GraphicsPipeline* VULKAN_CreateGraphicsPipeline( | ||||||
| ) { | ) { | ||||||
| 	VkResult vulkanResult; | 	VkResult vulkanResult; | ||||||
| 	uint32_t i; | 	uint32_t i; | ||||||
|  | 	Refresh_SampleCount actualSampleCount; | ||||||
| 
 | 
 | ||||||
| 	VulkanGraphicsPipeline *graphicsPipeline = (VulkanGraphicsPipeline*) SDL_malloc(sizeof(VulkanGraphicsPipeline)); | 	VulkanGraphicsPipeline *graphicsPipeline = (VulkanGraphicsPipeline*) SDL_malloc(sizeof(VulkanGraphicsPipeline)); | ||||||
| 	VkGraphicsPipelineCreateInfo vkPipelineCreateInfo; | 	VkGraphicsPipelineCreateInfo vkPipelineCreateInfo; | ||||||
|  | @ -5997,11 +6027,19 @@ static Refresh_GraphicsPipeline* VULKAN_CreateGraphicsPipeline( | ||||||
| 
 | 
 | ||||||
| 	VulkanRenderer *renderer = (VulkanRenderer*) driverData; | 	VulkanRenderer *renderer = (VulkanRenderer*) driverData; | ||||||
| 
 | 
 | ||||||
|  | 	/* Find a compatible sample count to use */ | ||||||
|  | 
 | ||||||
|  | 	actualSampleCount = VULKAN_INTERNAL_GetMaxMultiSampleCount( | ||||||
|  | 		renderer, | ||||||
|  | 		pipelineCreateInfo->multisampleState.multisampleCount | ||||||
|  | 	); | ||||||
|  | 
 | ||||||
| 	/* Create a "compatible" render pass */ | 	/* Create a "compatible" render pass */ | ||||||
| 
 | 
 | ||||||
| 	VkRenderPass transientRenderPass = VULKAN_INTERNAL_CreateTransientRenderPass( | 	VkRenderPass transientRenderPass = VULKAN_INTERNAL_CreateTransientRenderPass( | ||||||
| 		renderer, | 		renderer, | ||||||
| 		pipelineCreateInfo->attachmentInfo | 		pipelineCreateInfo->attachmentInfo, | ||||||
|  | 		actualSampleCount | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	/* Dynamic state */ | 	/* Dynamic state */ | ||||||
|  | @ -6132,9 +6170,7 @@ static Refresh_GraphicsPipeline* VULKAN_CreateGraphicsPipeline( | ||||||
| 	multisampleStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; | 	multisampleStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; | ||||||
| 	multisampleStateCreateInfo.pNext = NULL; | 	multisampleStateCreateInfo.pNext = NULL; | ||||||
| 	multisampleStateCreateInfo.flags = 0; | 	multisampleStateCreateInfo.flags = 0; | ||||||
| 	multisampleStateCreateInfo.rasterizationSamples = RefreshToVK_SampleCount[ | 	multisampleStateCreateInfo.rasterizationSamples = RefreshToVK_SampleCount[actualSampleCount]; | ||||||
| 		pipelineCreateInfo->multisampleState.multisampleCount |  | ||||||
| 	]; |  | ||||||
| 	multisampleStateCreateInfo.sampleShadingEnable = VK_FALSE; | 	multisampleStateCreateInfo.sampleShadingEnable = VK_FALSE; | ||||||
| 	multisampleStateCreateInfo.minSampleShading = 1.0f; | 	multisampleStateCreateInfo.minSampleShading = 1.0f; | ||||||
| 	multisampleStateCreateInfo.pSampleMask = | 	multisampleStateCreateInfo.pSampleMask = | ||||||
|  | @ -8019,6 +8055,10 @@ static VkRenderPass VULKAN_INTERNAL_FetchRenderPass( | ||||||
| 		hash.colorTargetDescriptions[i].storeOp = colorAttachmentInfos[i].storeOp; | 		hash.colorTargetDescriptions[i].storeOp = colorAttachmentInfos[i].storeOp; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	hash.colorAttachmentSampleCount = (colorAttachmentCount > 0) ? | ||||||
|  | 		colorAttachmentInfos[0].sampleCount : | ||||||
|  | 		REFRESH_SAMPLECOUNT_1; | ||||||
|  | 
 | ||||||
| 	hash.colorAttachmentCount = colorAttachmentCount; | 	hash.colorAttachmentCount = colorAttachmentCount; | ||||||
| 
 | 
 | ||||||
| 	if (depthStencilAttachmentInfo == NULL) | 	if (depthStencilAttachmentInfo == NULL) | ||||||
|  | @ -8316,7 +8356,6 @@ static void VULKAN_SetScissor( | ||||||
| static void VULKAN_BeginRenderPass( | static void VULKAN_BeginRenderPass( | ||||||
| 	Refresh_Renderer *driverData, | 	Refresh_Renderer *driverData, | ||||||
| 	Refresh_CommandBuffer *commandBuffer, | 	Refresh_CommandBuffer *commandBuffer, | ||||||
| 	Refresh_Rect *renderArea, |  | ||||||
| 	Refresh_ColorAttachmentInfo *colorAttachmentInfos, | 	Refresh_ColorAttachmentInfo *colorAttachmentInfos, | ||||||
| 	uint32_t colorAttachmentCount, | 	uint32_t colorAttachmentCount, | ||||||
| 	Refresh_DepthStencilAttachmentInfo *depthStencilAttachmentInfo | 	Refresh_DepthStencilAttachmentInfo *depthStencilAttachmentInfo | ||||||
|  | @ -8417,7 +8456,7 @@ static void VULKAN_BeginRenderPass( | ||||||
| 			&texture->resourceAccessType | 			&texture->resourceAccessType | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		if (colorAttachmentInfos[i].sampleCount > 1) | 		if (colorAttachmentInfos[i].sampleCount > REFRESH_SAMPLECOUNT_1) | ||||||
| 		{ | 		{ | ||||||
| 			clearCount += 1; | 			clearCount += 1; | ||||||
| 			multisampleAttachmentCount += 1; | 			multisampleAttachmentCount += 1; | ||||||
|  | @ -8467,7 +8506,7 @@ static void VULKAN_BeginRenderPass( | ||||||
| 		clearValues[i].color.float32[2] = colorAttachmentInfos[i].clearColor.z; | 		clearValues[i].color.float32[2] = colorAttachmentInfos[i].clearColor.z; | ||||||
| 		clearValues[i].color.float32[3] = colorAttachmentInfos[i].clearColor.w; | 		clearValues[i].color.float32[3] = colorAttachmentInfos[i].clearColor.w; | ||||||
| 
 | 
 | ||||||
| 		if (colorAttachmentInfos[i].sampleCount > 0) | 		if (colorAttachmentInfos[i].sampleCount > REFRESH_SAMPLECOUNT_1) | ||||||
| 		{ | 		{ | ||||||
| 			i += 1; | 			i += 1; | ||||||
| 			clearValues[i].color.float32[0] = colorAttachmentInfos[i].clearColor.x; | 			clearValues[i].color.float32[0] = colorAttachmentInfos[i].clearColor.x; | ||||||
|  | @ -8492,21 +8531,10 @@ static void VULKAN_BeginRenderPass( | ||||||
| 	renderPassBeginInfo.framebuffer = framebuffer->framebuffer; | 	renderPassBeginInfo.framebuffer = framebuffer->framebuffer; | ||||||
| 	renderPassBeginInfo.pClearValues = clearValues; | 	renderPassBeginInfo.pClearValues = clearValues; | ||||||
| 	renderPassBeginInfo.clearValueCount = clearCount; | 	renderPassBeginInfo.clearValueCount = clearCount; | ||||||
| 
 |  | ||||||
| 	if (renderArea != NULL) |  | ||||||
| 	{ |  | ||||||
| 		renderPassBeginInfo.renderArea.extent.width = renderArea->w; |  | ||||||
| 		renderPassBeginInfo.renderArea.extent.height = renderArea->h; |  | ||||||
| 		renderPassBeginInfo.renderArea.offset.x = renderArea->x; |  | ||||||
| 		renderPassBeginInfo.renderArea.offset.y = renderArea->y; |  | ||||||
| 	} |  | ||||||
| 	else |  | ||||||
| 	{ |  | ||||||
| 	renderPassBeginInfo.renderArea.extent.width = framebufferWidth; | 	renderPassBeginInfo.renderArea.extent.width = framebufferWidth; | ||||||
| 	renderPassBeginInfo.renderArea.extent.height = framebufferHeight; | 	renderPassBeginInfo.renderArea.extent.height = framebufferHeight; | ||||||
| 	renderPassBeginInfo.renderArea.offset.x = 0; | 	renderPassBeginInfo.renderArea.offset.x = 0; | ||||||
| 	renderPassBeginInfo.renderArea.offset.y = 0; | 	renderPassBeginInfo.renderArea.offset.y = 0; | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	renderer->vkCmdBeginRenderPass( | 	renderer->vkCmdBeginRenderPass( | ||||||
| 		vulkanCommandBuffer->commandBuffer, | 		vulkanCommandBuffer->commandBuffer, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue