1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-13 19:29:14 +01:00

[dxvk] Apply spec constants to compute shaders as well

This commit is contained in:
Philip Rebohle 2019-09-21 13:38:00 +02:00
parent e926ceb9cc
commit e253183bc2
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 43 additions and 4 deletions

View File

@ -9,6 +9,24 @@
namespace dxvk {
DxvkComputePipelineStateInfo::DxvkComputePipelineStateInfo() {
std::memset(this, 0, sizeof(*this));
}
DxvkComputePipelineStateInfo::DxvkComputePipelineStateInfo(
const DxvkComputePipelineStateInfo& other) {
std::memcpy(this, &other, sizeof(*this));
}
DxvkComputePipelineStateInfo& DxvkComputePipelineStateInfo::operator = (
const DxvkComputePipelineStateInfo& other) {
std::memcpy(this, &other, sizeof(*this));
return *this;
}
bool DxvkComputePipelineStateInfo::operator == (const DxvkComputePipelineStateInfo& other) const {
return std::memcmp(this, &other, sizeof(DxvkComputePipelineStateInfo)) == 0;
}
@ -107,6 +125,9 @@ namespace dxvk {
for (uint32_t i = 0; i < m_layout->bindingCount(); i++)
specData.set(i, state.bsBindingMask.test(i), true);
for (uint32_t i = 0; i < MaxNumSpecConstants; i++)
specData.set(getSpecId(i), state.scSpecConstants[i], 0u);
VkSpecializationInfo specInfo = specData.getSpecInfo();
DxvkShaderModuleCreateInfo moduleInfo;

View File

@ -27,10 +27,18 @@ namespace dxvk {
* \brief Compute pipeline state info
*/
struct DxvkComputePipelineStateInfo {
DxvkComputePipelineStateInfo();
DxvkComputePipelineStateInfo(
const DxvkComputePipelineStateInfo& other);
DxvkComputePipelineStateInfo& operator = (
const DxvkComputePipelineStateInfo& other);
bool operator == (const DxvkComputePipelineStateInfo& other) const;
bool operator != (const DxvkComputePipelineStateInfo& other) const;
DxvkBindingMask bsBindingMask;
DxvkBindingMask bsBindingMask;
uint32_t scSpecConstants[MaxNumSpecConstants];
};

View File

@ -2344,11 +2344,19 @@ namespace dxvk {
void DxvkContext::setSpecConstant(
VkPipelineBindPoint pipeline,
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);
auto& specConst = pipeline == VK_PIPELINE_BIND_POINT_GRAPHICS
? m_state.gp.state.scSpecConstants[index]
: m_state.cp.state.scSpecConstants[index];
if (specConst != value) {
specConst = value;
m_flags.set(pipeline == VK_PIPELINE_BIND_POINT_GRAPHICS
? DxvkContextFlag::GpDirtyPipelineState
: DxvkContextFlag::CpDirtyPipelineState);
}
}

View File

@ -917,10 +917,12 @@ namespace dxvk {
* Replaces current specialization constants with
* the given list of constant entries. The specId
* in the shader can be computed with \c getSpecId.
* \param [in] pipeline Graphics or Compute pipeline
* \param [in] index Constant index
* \param [in] value Constant value
*/
void setSpecConstant(
VkPipelineBindPoint pipeline,
uint32_t index,
uint32_t value);