mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[dxvk] Add API for specialization constants
This commit is contained in:
parent
7687db0303
commit
37f1087783
@ -2142,6 +2142,16 @@ namespace dxvk {
|
|||||||
|
|
||||||
m_flags.set(DxvkContextFlag::GpDirtyPipelineState);
|
m_flags.set(DxvkContextFlag::GpDirtyPipelineState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DxvkContext::setSpecConstant(
|
||||||
|
uint32_t index,
|
||||||
|
uint32_t value) {
|
||||||
|
if (m_state.gp.state.scSpecConstants[index] != value) {
|
||||||
|
m_state.gp.state.scSpecConstants[index] = value;
|
||||||
|
m_flags.set(DxvkContextFlag::GpDirtyPipelineState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkContext::setPredicate(
|
void DxvkContext::setPredicate(
|
||||||
|
@ -856,6 +856,19 @@ namespace dxvk {
|
|||||||
uint32_t attachment,
|
uint32_t attachment,
|
||||||
const DxvkBlendMode& blendMode);
|
const DxvkBlendMode& blendMode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Sets specialization constants
|
||||||
|
*
|
||||||
|
* Replaces current specialization constants with
|
||||||
|
* the given list of constant entries. The specId
|
||||||
|
* in the shader can be computed with \c getSpecId.
|
||||||
|
* \param [in] index Constant index
|
||||||
|
* \param [in] value Constant value
|
||||||
|
*/
|
||||||
|
void setSpecConstant(
|
||||||
|
uint32_t index,
|
||||||
|
uint32_t value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Sets predicate
|
* \brief Sets predicate
|
||||||
*
|
*
|
||||||
|
@ -205,6 +205,9 @@ namespace dxvk {
|
|||||||
specData.set(specId + 3, util::getComponentIndex(state.omComponentMapping[i].a, 3), 3u);
|
specData.set(specId + 3, util::getComponentIndex(state.omComponentMapping[i].a, 3), 3u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < MaxNumSpecConstants; i++)
|
||||||
|
specData.set(getSpecId(i), state.scSpecConstants[i], 0u);
|
||||||
|
|
||||||
VkSpecializationInfo specInfo = specData.getSpecInfo();
|
VkSpecializationInfo specInfo = specData.getSpecInfo();
|
||||||
|
|
||||||
|
@ -109,6 +109,8 @@ namespace dxvk {
|
|||||||
VkLogicOp omLogicOp;
|
VkLogicOp omLogicOp;
|
||||||
VkPipelineColorBlendAttachmentState omBlendAttachments[MaxNumRenderTargets];
|
VkPipelineColorBlendAttachmentState omBlendAttachments[MaxNumRenderTargets];
|
||||||
VkComponentMapping omComponentMapping[MaxNumRenderTargets];
|
VkComponentMapping omComponentMapping[MaxNumRenderTargets];
|
||||||
|
|
||||||
|
uint32_t scSpecConstants[MaxNumSpecConstants];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ namespace dxvk {
|
|||||||
MaxNumActiveBindings = 128,
|
MaxNumActiveBindings = 128,
|
||||||
MaxNumQueuedCommandBuffers = 8,
|
MaxNumQueuedCommandBuffers = 8,
|
||||||
MaxNumQueryCountPerPool = 128,
|
MaxNumQueryCountPerPool = 128,
|
||||||
|
MaxNumSpecConstants = 8,
|
||||||
MaxUniformBufferSize = 65536,
|
MaxUniformBufferSize = 65536,
|
||||||
MaxVertexBindingStride = 2048,
|
MaxVertexBindingStride = 2048,
|
||||||
MaxPushConstantSize = 128,
|
MaxPushConstantSize = 128,
|
||||||
|
@ -30,7 +30,8 @@ namespace dxvk {
|
|||||||
|
|
||||||
// Specialization constants for pipeline state
|
// Specialization constants for pipeline state
|
||||||
SpecConstantRangeStart = ColorComponentMappings + MaxNumRenderTargets * 4,
|
SpecConstantRangeStart = ColorComponentMappings + MaxNumRenderTargets * 4,
|
||||||
RasterizerSampleCount = SpecConstantRangeStart,
|
RasterizerSampleCount = SpecConstantRangeStart + 0,
|
||||||
|
FirstPipelineConstant
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,6 +4,18 @@
|
|||||||
#include "dxvk_shader.h"
|
#include "dxvk_shader.h"
|
||||||
|
|
||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \briefS Specialization constant entry
|
||||||
|
*
|
||||||
|
* Used to pass a list of user-defined
|
||||||
|
* specialization constants to shaders.
|
||||||
|
*/
|
||||||
|
struct DxvkSpecConstant {
|
||||||
|
uint32_t specId;
|
||||||
|
uint32_t value;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Specialization constant info
|
* \brief Specialization constant info
|
||||||
@ -36,6 +48,18 @@ namespace dxvk {
|
|||||||
setAsUint32(specId, uint32_t(value));
|
setAsUint32(specId, uint32_t(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Sets specialization constant value
|
||||||
|
*
|
||||||
|
* Always passes the constant value to the driver.
|
||||||
|
* \param [in] specId Specialization constant ID
|
||||||
|
* \param [in] value Specialization constant value
|
||||||
|
*/
|
||||||
|
template<typename T>
|
||||||
|
void set(uint32_t specId, T value) {
|
||||||
|
setAsUint32(specId, uint32_t(value));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Generates specialization info structure
|
* \brief Generates specialization info structure
|
||||||
* \returns Specialization info for shader module
|
* \returns Specialization info for shader module
|
||||||
@ -50,5 +74,18 @@ namespace dxvk {
|
|||||||
void setAsUint32(uint32_t specId, uint32_t value);
|
void setAsUint32(uint32_t specId, uint32_t value);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Computes specialization constant ID
|
||||||
|
*
|
||||||
|
* Computest the specId to use within shaders
|
||||||
|
* for a given pipeline specialization constant.
|
||||||
|
* \param [in] index Spec constant index
|
||||||
|
* \returns Specialization constant ID
|
||||||
|
*/
|
||||||
|
inline uint32_t getSpecId(uint32_t index) {
|
||||||
|
return uint32_t(DxvkSpecConstantId::FirstPipelineConstant) + index;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user