1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-15 07:29:17 +01:00

[dxvk] Detect Xfb and set rasterized stream index

This commit is contained in:
Philip Rebohle 2018-07-24 18:19:52 +02:00
parent 1f135f59ed
commit a27e440272
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 44 additions and 3 deletions

View File

@ -232,9 +232,13 @@ namespace dxvk {
DxvkShaderOptions shaderOptions = { }; DxvkShaderOptions shaderOptions = { };
if (m_moduleInfo.xfb != nullptr) if (m_moduleInfo.xfb != nullptr) {
shaderOptions.rasterizedStream = m_moduleInfo.xfb->rasterizedStream; shaderOptions.rasterizedStream = m_moduleInfo.xfb->rasterizedStream;
for (uint32_t i = 0; i < 4; i++)
shaderOptions.xfbStrides[i] = m_moduleInfo.xfb->strides[i];
}
// Create the shader module object // Create the shader module object
return new DxvkShader( return new DxvkShader(
m_programInfo.shaderStage(), m_programInfo.shaderStage(),

View File

@ -70,6 +70,9 @@ namespace dxvk {
m_vsIn = vs != nullptr ? vs->interfaceSlots().inputSlots : 0; m_vsIn = vs != nullptr ? vs->interfaceSlots().inputSlots : 0;
m_fsOut = fs != nullptr ? fs->interfaceSlots().outputSlots : 0; m_fsOut = fs != nullptr ? fs->interfaceSlots().outputSlots : 0;
if (gs != nullptr && gs->hasCapability(spv::CapabilityTransformFeedback))
m_flags.set(DxvkGraphicsPipelineFlag::HasTransformFeedback);
m_common.msSampleShadingEnable = fs != nullptr && fs->hasCapability(spv::CapabilitySampleRateShading); m_common.msSampleShadingEnable = fs != nullptr && fs->hasCapability(spv::CapabilitySampleRateShading);
m_common.msSampleShadingFactor = 1.0f; m_common.msSampleShadingFactor = 1.0f;
} }
@ -227,6 +230,10 @@ namespace dxvk {
} }
} }
int32_t rasterizedStream = m_gs != nullptr
? m_gs->shader()->shaderOptions().rasterizedStream
: 0;
VkPipelineVertexInputDivisorStateCreateInfoEXT viDivisorInfo; VkPipelineVertexInputDivisorStateCreateInfoEXT viDivisorInfo;
viDivisorInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT; viDivisorInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT;
viDivisorInfo.pNext = nullptr; viDivisorInfo.pNext = nullptr;
@ -271,12 +278,18 @@ namespace dxvk {
vpInfo.scissorCount = state.rsViewportCount; vpInfo.scissorCount = state.rsViewportCount;
vpInfo.pScissors = nullptr; vpInfo.pScissors = nullptr;
VkPipelineRasterizationStateStreamCreateInfoEXT xfbStreamInfo;
xfbStreamInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_STREAM_CREATE_INFO_EXT;
xfbStreamInfo.pNext = nullptr;
xfbStreamInfo.flags = 0;
xfbStreamInfo.rasterizationStream = uint32_t(rasterizedStream);
VkPipelineRasterizationStateCreateInfo rsInfo; VkPipelineRasterizationStateCreateInfo rsInfo;
rsInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; rsInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
rsInfo.pNext = nullptr; rsInfo.pNext = nullptr;
rsInfo.flags = 0; rsInfo.flags = 0;
rsInfo.depthClampEnable = state.rsDepthClampEnable; rsInfo.depthClampEnable = state.rsDepthClampEnable;
rsInfo.rasterizerDiscardEnable= VK_FALSE; rsInfo.rasterizerDiscardEnable = rasterizedStream < 0;
rsInfo.polygonMode = state.rsPolygonMode; rsInfo.polygonMode = state.rsPolygonMode;
rsInfo.cullMode = state.rsCullMode; rsInfo.cullMode = state.rsCullMode;
rsInfo.frontFace = state.rsFrontFace; rsInfo.frontFace = state.rsFrontFace;
@ -286,6 +299,9 @@ namespace dxvk {
rsInfo.depthBiasSlopeFactor = 0.0f; rsInfo.depthBiasSlopeFactor = 0.0f;
rsInfo.lineWidth = 1.0f; rsInfo.lineWidth = 1.0f;
if (rasterizedStream > 0)
rsInfo.pNext = &xfbStreamInfo;
VkPipelineMultisampleStateCreateInfo msInfo; VkPipelineMultisampleStateCreateInfo msInfo;
msInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; msInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
msInfo.pNext = nullptr; msInfo.pNext = nullptr;

View File

@ -16,6 +16,16 @@ namespace dxvk {
class DxvkDevice; class DxvkDevice;
class DxvkPipelineManager; class DxvkPipelineManager;
/**
* \brief Flags that describe pipeline properties
*/
enum class DxvkGraphicsPipelineFlag {
HasTransformFeedback,
};
using DxvkGraphicsCommonPipelineFlags = Flags<DxvkGraphicsPipelineFlag>;
/** /**
* \brief Graphics pipeline state info * \brief Graphics pipeline state info
* *
@ -156,6 +166,14 @@ namespace dxvk {
const Rc<DxvkShader>& fs); const Rc<DxvkShader>& fs);
~DxvkGraphicsPipeline(); ~DxvkGraphicsPipeline();
/**
* \brief Returns graphics pipeline flags
* \returns Graphics pipeline property flags
*/
DxvkGraphicsCommonPipelineFlags flags() const {
return m_flags;
}
/** /**
* \brief Pipeline layout * \brief Pipeline layout
* *
@ -213,6 +231,7 @@ namespace dxvk {
uint32_t m_vsIn = 0; uint32_t m_vsIn = 0;
uint32_t m_fsOut = 0; uint32_t m_fsOut = 0;
DxvkGraphicsCommonPipelineFlags m_flags;
DxvkGraphicsCommonPipelineStateInfo m_common; DxvkGraphicsCommonPipelineStateInfo m_common;
// List of pipeline instances, shared between threads // List of pipeline instances, shared between threads

View File

@ -59,6 +59,8 @@ namespace dxvk {
struct DxvkShaderOptions { struct DxvkShaderOptions {
/// Rasterized stream, or -1 /// Rasterized stream, or -1
int32_t rasterizedStream; int32_t rasterizedStream;
/// Xfb vertex strides
uint32_t xfbStrides[MaxNumXfbBuffers];
}; };