Prefer set/binding API
This commit is contained in:
parent
17bccc9f7e
commit
32bead81c8
@ -5546,18 +5546,21 @@ CompilerHLSL::BitcastType CompilerHLSL::get_bitcast_type(uint32_t result_type, u
|
|||||||
return BitcastType::TypeNormal;
|
return BitcastType::TypeNormal;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CompilerHLSL::is_hlsl_force_storage_buffer_as_uav(ID binding) const
|
bool CompilerHLSL::is_hlsl_force_storage_buffer_as_uav(ID id) const
|
||||||
{
|
{
|
||||||
if (hlsl_options.force_storage_buffer_as_uav)
|
if (hlsl_options.force_storage_buffer_as_uav)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
return (hlsl_options.force_storage_buffer_as_uav_by_id &&
|
|
||||||
force_uav_buffer_bindings.find(binding) != force_uav_buffer_bindings.end());
|
const uint32_t desc_set = get_decoration(id, spv::DecorationDescriptorSet);
|
||||||
|
const uint32_t binding = get_decoration(id, spv::DecorationBinding);
|
||||||
|
|
||||||
|
return (force_uav_buffer_bindings.find({desc_set, binding}) != force_uav_buffer_bindings.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompilerHLSL::set_hlsl_force_storage_buffer_as_uav(ID binding)
|
void CompilerHLSL::set_hlsl_force_storage_buffer_as_uav(uint32_t desc_set, uint32_t binding)
|
||||||
{
|
{
|
||||||
assert(hlsl_options.force_storage_buffer_as_uav_by_id);
|
SetBindingPair pair = { desc_set, binding };
|
||||||
force_uav_buffer_bindings.insert(binding);
|
force_uav_buffer_bindings.insert(pair);
|
||||||
}
|
}
|
||||||
|
@ -112,12 +112,9 @@ public:
|
|||||||
|
|
||||||
// Forces a storage buffer to always be declared as UAV, even if the readonly decoration is used.
|
// Forces a storage buffer to always be declared as UAV, even if the readonly decoration is used.
|
||||||
// By default, a readonly storage buffer will be declared as ByteAddressBuffer (SRV) instead.
|
// By default, a readonly storage buffer will be declared as ByteAddressBuffer (SRV) instead.
|
||||||
|
// Alternatively, use set_hlsl_force_storage_buffer_as_uav to specify individually.
|
||||||
bool force_storage_buffer_as_uav = false;
|
bool force_storage_buffer_as_uav = false;
|
||||||
|
|
||||||
// Similar to force_storage_buffer_as_uav but only forces set bindings.
|
|
||||||
// Use set_hlsl_force_storage_buffer_as_uav to specify the binding by ID.
|
|
||||||
bool force_storage_buffer_as_uav_by_id = false;
|
|
||||||
|
|
||||||
// Forces any storage image type marked as NonWritable to be considered an SRV instead.
|
// Forces any storage image type marked as NonWritable to be considered an SRV instead.
|
||||||
// For this to work with function call parameters, NonWritable must be considered to be part of the type system
|
// For this to work with function call parameters, NonWritable must be considered to be part of the type system
|
||||||
// so that NonWritable image arguments are also translated to Texture rather than RWTexture.
|
// so that NonWritable image arguments are also translated to Texture rather than RWTexture.
|
||||||
@ -191,7 +188,7 @@ public:
|
|||||||
bool is_hlsl_resource_binding_used(spv::ExecutionModel model, uint32_t set, uint32_t binding) const;
|
bool is_hlsl_resource_binding_used(spv::ExecutionModel model, uint32_t set, uint32_t binding) const;
|
||||||
|
|
||||||
// Controls which storage buffer bindings will be forced to be declared as UAVs.
|
// Controls which storage buffer bindings will be forced to be declared as UAVs.
|
||||||
void set_hlsl_force_storage_buffer_as_uav(ID binding);
|
void set_hlsl_force_storage_buffer_as_uav(uint32_t desc_set, uint32_t binding);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string type_to_glsl(const SPIRType &type, uint32_t id = 0) override;
|
std::string type_to_glsl(const SPIRType &type, uint32_t id = 0) override;
|
||||||
@ -252,7 +249,7 @@ private:
|
|||||||
const char *to_storage_qualifiers_glsl(const SPIRVariable &var) override;
|
const char *to_storage_qualifiers_glsl(const SPIRVariable &var) override;
|
||||||
void replace_illegal_names() override;
|
void replace_illegal_names() override;
|
||||||
|
|
||||||
bool is_hlsl_force_storage_buffer_as_uav(ID binding) const;
|
bool is_hlsl_force_storage_buffer_as_uav(ID id) const;
|
||||||
|
|
||||||
Options hlsl_options;
|
Options hlsl_options;
|
||||||
|
|
||||||
@ -348,7 +345,7 @@ private:
|
|||||||
std::unordered_map<StageSetBinding, std::pair<HLSLResourceBinding, bool>, InternalHasher> resource_bindings;
|
std::unordered_map<StageSetBinding, std::pair<HLSLResourceBinding, bool>, InternalHasher> resource_bindings;
|
||||||
void remap_hlsl_resource_binding(HLSLBindingFlagBits type, uint32_t &desc_set, uint32_t &binding);
|
void remap_hlsl_resource_binding(HLSLBindingFlagBits type, uint32_t &desc_set, uint32_t &binding);
|
||||||
|
|
||||||
std::unordered_set<ID> force_uav_buffer_bindings;
|
std::unordered_set<SetBindingPair, InternalHasher> force_uav_buffer_bindings;
|
||||||
};
|
};
|
||||||
} // namespace SPIRV_CROSS_NAMESPACE
|
} // namespace SPIRV_CROSS_NAMESPACE
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user