From a26d3e36892890421f82b47495c08d476b4ae6a1 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Fri, 25 Feb 2022 17:37:42 -0800 Subject: [PATCH] move color blend state to AttachmentInfo --- include/Refresh.h | 15 +++++++-------- src/Refresh_Driver_Vulkan.c | 24 +++++++++++++----------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/include/Refresh.h b/include/Refresh.h index 9442757..04be0b5 100644 --- a/include/Refresh.h +++ b/include/Refresh.h @@ -447,7 +447,7 @@ typedef struct Refresh_StencilOpState uint32_t reference; } Refresh_StencilOpState; -typedef struct Refresh_ColorTargetBlendState +typedef struct Refresh_ColorAttachmentBlendState { uint8_t blendEnable; Refresh_BlendFactor srcColorBlendFactor; @@ -457,7 +457,7 @@ typedef struct Refresh_ColorTargetBlendState Refresh_BlendFactor dstAlphaBlendFactor; Refresh_BlendOp alphaBlendOp; Refresh_ColorComponentFlags colorWriteMask; -} Refresh_ColorTargetBlendState; +} Refresh_ColorAttachmentBlendState; typedef struct Refresh_ComputePipelineLayoutCreateInfo { @@ -538,14 +538,12 @@ typedef struct Refresh_DepthStencilState float maxDepthBounds; } Refresh_DepthStencilState; -typedef struct Refresh_ColorBlendState +typedef struct Refresh_PipelineColorBlendState { uint8_t logicOpEnable; Refresh_LogicOp logicOp; - const Refresh_ColorTargetBlendState *blendStates; - uint32_t blendStateCount; float blendConstants[4]; -} Refresh_ColorBlendState; +} Refresh_PipelineColorBlendState; typedef struct Refresh_ComputePipelineCreateInfo { @@ -557,11 +555,12 @@ typedef struct Refresh_ColorAttachmentDescription { Refresh_TextureFormat format; Refresh_SampleCount sampleCount; + Refresh_ColorAttachmentBlendState blendState; } Refresh_ColorAttachmentDescription; typedef struct Refresh_GraphicsPipelineAttachmentInfo { - const Refresh_ColorAttachmentDescription *colorAttachmentDescriptions; + Refresh_ColorAttachmentDescription *colorAttachmentDescriptions; uint32_t colorAttachmentCount; uint8_t hasDepthStencilAttachment; Refresh_TextureFormat depthStencilFormat; @@ -577,7 +576,7 @@ typedef struct Refresh_GraphicsPipelineCreateInfo Refresh_RasterizerState rasterizerState; Refresh_MultisampleState multisampleState; Refresh_DepthStencilState depthStencilState; - Refresh_ColorBlendState colorBlendState; + Refresh_PipelineColorBlendState colorBlendState; Refresh_GraphicsPipelineLayoutCreateInfo pipelineLayoutCreateInfo; Refresh_GraphicsPipelineAttachmentInfo attachmentInfo; } Refresh_GraphicsPipelineCreateInfo; diff --git a/src/Refresh_Driver_Vulkan.c b/src/Refresh_Driver_Vulkan.c index a5ace7f..beb80b8 100644 --- a/src/Refresh_Driver_Vulkan.c +++ b/src/Refresh_Driver_Vulkan.c @@ -5127,7 +5127,7 @@ static Refresh_GraphicsPipeline* VULKAN_CreateGraphicsPipeline( VkPipelineColorBlendStateCreateInfo colorBlendStateCreateInfo; VkPipelineColorBlendAttachmentState *colorBlendAttachmentStates = SDL_stack_alloc( VkPipelineColorBlendAttachmentState, - pipelineCreateInfo->colorBlendState.blendStateCount + pipelineCreateInfo->attachmentInfo.colorAttachmentCount ); VulkanRenderer *renderer = (VulkanRenderer*) driverData; @@ -5344,30 +5344,32 @@ static Refresh_GraphicsPipeline* VULKAN_CreateGraphicsPipeline( /* Color Blend */ - for (i = 0; i < pipelineCreateInfo->colorBlendState.blendStateCount; i += 1) + for (i = 0; i < pipelineCreateInfo->attachmentInfo.colorAttachmentCount; i += 1) { + Refresh_ColorAttachmentBlendState blendState = pipelineCreateInfo->attachmentInfo.colorAttachmentDescriptions[i].blendState; + colorBlendAttachmentStates[i].blendEnable = - pipelineCreateInfo->colorBlendState.blendStates[i].blendEnable; + blendState.blendEnable; colorBlendAttachmentStates[i].srcColorBlendFactor = RefreshToVK_BlendFactor[ - pipelineCreateInfo->colorBlendState.blendStates[i].srcColorBlendFactor + blendState.srcColorBlendFactor ]; colorBlendAttachmentStates[i].dstColorBlendFactor = RefreshToVK_BlendFactor[ - pipelineCreateInfo->colorBlendState.blendStates[i].dstColorBlendFactor + blendState.dstColorBlendFactor ]; colorBlendAttachmentStates[i].colorBlendOp = RefreshToVK_BlendOp[ - pipelineCreateInfo->colorBlendState.blendStates[i].colorBlendOp + blendState.colorBlendOp ]; colorBlendAttachmentStates[i].srcAlphaBlendFactor = RefreshToVK_BlendFactor[ - pipelineCreateInfo->colorBlendState.blendStates[i].srcAlphaBlendFactor + blendState.srcAlphaBlendFactor ]; colorBlendAttachmentStates[i].dstAlphaBlendFactor = RefreshToVK_BlendFactor[ - pipelineCreateInfo->colorBlendState.blendStates[i].dstAlphaBlendFactor + blendState.dstAlphaBlendFactor ]; colorBlendAttachmentStates[i].alphaBlendOp = RefreshToVK_BlendOp[ - pipelineCreateInfo->colorBlendState.blendStates[i].alphaBlendOp + blendState.alphaBlendOp ]; colorBlendAttachmentStates[i].colorWriteMask = - pipelineCreateInfo->colorBlendState.blendStates[i].colorWriteMask; + blendState.colorWriteMask; } colorBlendStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; @@ -5379,7 +5381,7 @@ static Refresh_GraphicsPipeline* VULKAN_CreateGraphicsPipeline( pipelineCreateInfo->colorBlendState.logicOp ]; colorBlendStateCreateInfo.attachmentCount = - pipelineCreateInfo->colorBlendState.blendStateCount; + pipelineCreateInfo->attachmentInfo.colorAttachmentCount; colorBlendStateCreateInfo.pAttachments = colorBlendAttachmentStates; colorBlendStateCreateInfo.blendConstants[0] =