From 8d09aa12da63a9d6a4ed81b4ba8d3bd81cc12d08 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 7 Oct 2019 11:26:05 +0200 Subject: [PATCH] [dxvk] Move DxvkGraphicsPipelineStateInfo to new file We're going to put a lot of code here, so try to keep things clean. --- src/dxvk/dxvk_graphics.cpp | 29 --------- src/dxvk/dxvk_graphics.h | 87 +-------------------------- src/dxvk/dxvk_graphics_state.h | 104 +++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 115 deletions(-) create mode 100644 src/dxvk/dxvk_graphics_state.h diff --git a/src/dxvk/dxvk_graphics.cpp b/src/dxvk/dxvk_graphics.cpp index 5e05b4251..ea52eeb04 100644 --- a/src/dxvk/dxvk_graphics.cpp +++ b/src/dxvk/dxvk_graphics.cpp @@ -1,5 +1,4 @@ #include -#include #include "dxvk_device.h" #include "dxvk_graphics.h" @@ -9,34 +8,6 @@ namespace dxvk { - DxvkGraphicsPipelineStateInfo::DxvkGraphicsPipelineStateInfo() { - std::memset(this, 0, sizeof(DxvkGraphicsPipelineStateInfo)); - } - - - DxvkGraphicsPipelineStateInfo::DxvkGraphicsPipelineStateInfo( - const DxvkGraphicsPipelineStateInfo& other) { - std::memcpy(this, &other, sizeof(DxvkGraphicsPipelineStateInfo)); - } - - - DxvkGraphicsPipelineStateInfo& DxvkGraphicsPipelineStateInfo::operator = ( - const DxvkGraphicsPipelineStateInfo& other) { - std::memcpy(this, &other, sizeof(DxvkGraphicsPipelineStateInfo)); - return *this; - } - - - bool DxvkGraphicsPipelineStateInfo::operator == (const DxvkGraphicsPipelineStateInfo& other) const { - return std::memcmp(this, &other, sizeof(DxvkGraphicsPipelineStateInfo)) == 0; - } - - - bool DxvkGraphicsPipelineStateInfo::operator != (const DxvkGraphicsPipelineStateInfo& other) const { - return std::memcmp(this, &other, sizeof(DxvkGraphicsPipelineStateInfo)) != 0; - } - - DxvkGraphicsPipeline::DxvkGraphicsPipeline( DxvkPipelineManager* pipeMgr, DxvkGraphicsPipelineShaders shaders) diff --git a/src/dxvk/dxvk_graphics.h b/src/dxvk/dxvk_graphics.h index 81c232d0c..0f8aee7b4 100644 --- a/src/dxvk/dxvk_graphics.h +++ b/src/dxvk/dxvk_graphics.h @@ -4,6 +4,7 @@ #include "dxvk_bind_mask.h" #include "dxvk_constant_state.h" +#include "dxvk_graphics_state.h" #include "dxvk_pipecache.h" #include "dxvk_pipelayout.h" #include "dxvk_renderpass.h" @@ -54,92 +55,6 @@ namespace dxvk { return state; } }; - - - /** - * \brief Graphics pipeline state info - * - * Stores all information that is required to create - * a graphics pipeline, except the shader objects - * themselves. Also used to identify pipelines using - * the current pipeline state vector. - */ - struct DxvkGraphicsPipelineStateInfo { - DxvkGraphicsPipelineStateInfo(); - DxvkGraphicsPipelineStateInfo( - const DxvkGraphicsPipelineStateInfo& other); - - DxvkGraphicsPipelineStateInfo& operator = ( - const DxvkGraphicsPipelineStateInfo& other); - - bool operator == (const DxvkGraphicsPipelineStateInfo& other) const; - bool operator != (const DxvkGraphicsPipelineStateInfo& other) const; - - bool useDynamicStencilRef() const { - return dsEnableStencilTest; - } - - bool useDynamicDepthBias() const { - return rsDepthBiasEnable; - } - - bool useDynamicDepthBounds() const { - return dsEnableDepthBoundsTest; - } - - bool useDynamicBlendConstants() const { - bool result = false; - - for (uint32_t i = 0; i < MaxNumRenderTargets && !result; i++) { - result |= omBlendAttachments[i].blendEnable - && (util::isBlendConstantBlendFactor(omBlendAttachments[i].srcColorBlendFactor) - || util::isBlendConstantBlendFactor(omBlendAttachments[i].dstColorBlendFactor) - || util::isBlendConstantBlendFactor(omBlendAttachments[i].srcAlphaBlendFactor) - || util::isBlendConstantBlendFactor(omBlendAttachments[i].dstAlphaBlendFactor)); - } - - return result; - } - - DxvkBindingMask bsBindingMask; - - VkPrimitiveTopology iaPrimitiveTopology; - VkBool32 iaPrimitiveRestart; - uint32_t iaPatchVertexCount; - - uint32_t ilAttributeCount; - uint32_t ilBindingCount; - VkVertexInputAttributeDescription ilAttributes[DxvkLimits::MaxNumVertexAttributes]; - VkVertexInputBindingDescription ilBindings[DxvkLimits::MaxNumVertexBindings]; - uint32_t ilDivisors[DxvkLimits::MaxNumVertexBindings]; - - VkBool32 rsDepthClipEnable; - VkBool32 rsDepthBiasEnable; - VkPolygonMode rsPolygonMode; - VkCullModeFlags rsCullMode; - VkFrontFace rsFrontFace; - uint32_t rsViewportCount; - VkSampleCountFlags rsSampleCount; - - VkSampleCountFlags msSampleCount; - uint32_t msSampleMask; - VkBool32 msEnableAlphaToCoverage; - - VkBool32 dsEnableDepthTest; - VkBool32 dsEnableDepthWrite; - VkBool32 dsEnableDepthBoundsTest; - VkBool32 dsEnableStencilTest; - VkCompareOp dsDepthCompareOp; - VkStencilOpState dsStencilOpFront; - VkStencilOpState dsStencilOpBack; - - VkBool32 omEnableLogicOp; - VkLogicOp omLogicOp; - VkPipelineColorBlendAttachmentState omBlendAttachments[MaxNumRenderTargets]; - VkComponentMapping omComponentMapping[MaxNumRenderTargets]; - - uint32_t scSpecConstants[MaxNumSpecConstants]; - }; /** diff --git a/src/dxvk/dxvk_graphics_state.h b/src/dxvk/dxvk_graphics_state.h new file mode 100644 index 000000000..afa9ff2af --- /dev/null +++ b/src/dxvk/dxvk_graphics_state.h @@ -0,0 +1,104 @@ +#pragma once + +#include "dxvk_limits.h" + +#include + +namespace dxvk { + + /** + * \brief Packed graphics pipeline state + * + * Stores a compressed representation of the full + * graphics pipeline state which is optimized for + * lookup performance. + */ + struct alignas(32) DxvkGraphicsPipelineStateInfo { + DxvkGraphicsPipelineStateInfo() { + std::memset(this, 0, sizeof(*this)); + } + + DxvkGraphicsPipelineStateInfo(const DxvkGraphicsPipelineStateInfo& other) { + std::memcpy(this, &other, sizeof(*this)); + } + + DxvkGraphicsPipelineStateInfo& operator = (const DxvkGraphicsPipelineStateInfo& other) { + std::memcpy(this, &other, sizeof(*this)); + return *this; + } + + bool operator == (const DxvkGraphicsPipelineStateInfo& other) const { + return !std::memcmp(this, &other, sizeof(*this)); + } + + bool operator != (const DxvkGraphicsPipelineStateInfo& other) const { + return std::memcmp(this, &other, sizeof(*this)); + } + + bool useDynamicStencilRef() const { + return dsEnableStencilTest; + } + + bool useDynamicDepthBias() const { + return rsDepthBiasEnable; + } + + bool useDynamicDepthBounds() const { + return dsEnableDepthBoundsTest; + } + + bool useDynamicBlendConstants() const { + bool result = false; + + for (uint32_t i = 0; i < MaxNumRenderTargets && !result; i++) { + result |= omBlendAttachments[i].blendEnable + && (util::isBlendConstantBlendFactor(omBlendAttachments[i].srcColorBlendFactor) + || util::isBlendConstantBlendFactor(omBlendAttachments[i].dstColorBlendFactor) + || util::isBlendConstantBlendFactor(omBlendAttachments[i].srcAlphaBlendFactor) + || util::isBlendConstantBlendFactor(omBlendAttachments[i].dstAlphaBlendFactor)); + } + + return result; + } + + DxvkBindingMask bsBindingMask; + + VkPrimitiveTopology iaPrimitiveTopology; + VkBool32 iaPrimitiveRestart; + uint32_t iaPatchVertexCount; + + uint32_t ilAttributeCount; + uint32_t ilBindingCount; + VkVertexInputAttributeDescription ilAttributes[DxvkLimits::MaxNumVertexAttributes]; + VkVertexInputBindingDescription ilBindings[DxvkLimits::MaxNumVertexBindings]; + uint32_t ilDivisors[DxvkLimits::MaxNumVertexBindings]; + + VkBool32 rsDepthClipEnable; + VkBool32 rsDepthBiasEnable; + VkPolygonMode rsPolygonMode; + VkCullModeFlags rsCullMode; + VkFrontFace rsFrontFace; + uint32_t rsViewportCount; + VkSampleCountFlags rsSampleCount; + + VkSampleCountFlags msSampleCount; + uint32_t msSampleMask; + VkBool32 msEnableAlphaToCoverage; + + VkBool32 dsEnableDepthTest; + VkBool32 dsEnableDepthWrite; + VkBool32 dsEnableDepthBoundsTest; + VkBool32 dsEnableStencilTest; + VkCompareOp dsDepthCompareOp; + VkStencilOpState dsStencilOpFront; + VkStencilOpState dsStencilOpBack; + + VkBool32 omEnableLogicOp; + VkLogicOp omLogicOp; + VkPipelineColorBlendAttachmentState omBlendAttachments[MaxNumRenderTargets]; + VkComponentMapping omComponentMapping[MaxNumRenderTargets]; + + uint32_t scSpecConstants[MaxNumSpecConstants]; + }; + +}