mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-20 19:54:19 +01:00
[dxbc] Track dimension of resource slots
This shall help binding dummy resources in case an application binds none or an incompatible resource to a slot.
This commit is contained in:
parent
ad10ab07f8
commit
7912f6c604
@ -552,6 +552,7 @@ namespace dxvk {
|
||||
DxvkResourceSlot resource;
|
||||
resource.slot = bindingId;
|
||||
resource.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
resource.dim = DxvkResourceDim::Buffer;
|
||||
m_resourceSlots.push_back(resource);
|
||||
}
|
||||
|
||||
@ -587,6 +588,7 @@ namespace dxvk {
|
||||
DxvkResourceSlot resource;
|
||||
resource.slot = bindingId;
|
||||
resource.type = VK_DESCRIPTOR_TYPE_SAMPLER;
|
||||
resource.dim = DxvkResourceDim::Opaque;
|
||||
m_resourceSlots.push_back(resource);
|
||||
}
|
||||
|
||||
@ -723,6 +725,7 @@ namespace dxvk {
|
||||
// Store descriptor info for the shader interface
|
||||
DxvkResourceSlot resource;
|
||||
resource.slot = bindingId;
|
||||
resource.dim = getDxvkResourceDim(resourceType);
|
||||
|
||||
if (isUav) {
|
||||
resource.type = resourceType == DxbcResourceDim::Buffer
|
||||
@ -822,6 +825,7 @@ namespace dxvk {
|
||||
resource.type = isUav
|
||||
? VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
|
||||
: VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
|
||||
resource.dim = DxvkResourceDim::Buffer;
|
||||
m_resourceSlots.push_back(resource);
|
||||
}
|
||||
|
||||
@ -4299,6 +4303,26 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
DxvkResourceDim DxbcCompiler::getDxvkResourceDim(DxbcResourceDim dim) const {
|
||||
switch (dim) {
|
||||
default:
|
||||
case DxbcResourceDim::Unknown: return DxvkResourceDim::Opaque;
|
||||
case DxbcResourceDim::Buffer: return DxvkResourceDim::Buffer;
|
||||
case DxbcResourceDim::RawBuffer: return DxvkResourceDim::Buffer;
|
||||
case DxbcResourceDim::StructuredBuffer: return DxvkResourceDim::Buffer;
|
||||
case DxbcResourceDim::Texture1D: return DxvkResourceDim::Image1D;
|
||||
case DxbcResourceDim::Texture1DArr: return DxvkResourceDim::Image1DArray;
|
||||
case DxbcResourceDim::Texture2D: return DxvkResourceDim::Image2D;
|
||||
case DxbcResourceDim::Texture2DMs: return DxvkResourceDim::Image2D;
|
||||
case DxbcResourceDim::Texture2DArr: return DxvkResourceDim::Image2DArray;
|
||||
case DxbcResourceDim::Texture2DMsArr: return DxvkResourceDim::Image2DArray;
|
||||
case DxbcResourceDim::TextureCube: return DxvkResourceDim::ImageCube;
|
||||
case DxbcResourceDim::TextureCubeArr: return DxvkResourceDim::ImageCubeArray;
|
||||
case DxbcResourceDim::Texture3D: return DxvkResourceDim::Image3D;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint32_t DxbcCompiler::getScalarTypeId(DxbcScalarType type) {
|
||||
switch (type) {
|
||||
case DxbcScalarType::Uint32: return m_module.defIntType(32, 0);
|
||||
|
@ -728,6 +728,9 @@ namespace dxvk {
|
||||
DxbcVectorType getInputRegType(
|
||||
uint32_t regIdx) const;
|
||||
|
||||
DxvkResourceDim getDxvkResourceDim(
|
||||
DxbcResourceDim dim) const;
|
||||
|
||||
///////////////////////////
|
||||
// Type definition methods
|
||||
uint32_t getScalarTypeId(
|
||||
|
@ -11,6 +11,7 @@ namespace dxvk {
|
||||
void DxvkDescriptorSlotMapping::defineSlot(
|
||||
uint32_t slot,
|
||||
VkDescriptorType type,
|
||||
DxvkResourceDim dim,
|
||||
VkShaderStageFlagBits stage) {
|
||||
uint32_t bindingId = this->getBindingId(slot);
|
||||
|
||||
@ -20,6 +21,7 @@ namespace dxvk {
|
||||
DxvkDescriptorSlot slotInfo;
|
||||
slotInfo.slot = slot;
|
||||
slotInfo.type = type;
|
||||
slotInfo.dim = dim;
|
||||
slotInfo.stages = stage;
|
||||
m_descriptorSlots.push_back(slotInfo);
|
||||
}
|
||||
|
@ -6,6 +6,37 @@
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
/**
|
||||
* \brief Resource dimension
|
||||
*
|
||||
* Used to validate resource bindings and to
|
||||
* bind compatible dummy resource in case the
|
||||
* client API did not bind a resource.
|
||||
*/
|
||||
enum class DxvkResourceDim : uint32_t {
|
||||
Opaque,
|
||||
Buffer,
|
||||
Image1D,
|
||||
Image1DArray,
|
||||
Image2D,
|
||||
Image2DArray,
|
||||
ImageCube,
|
||||
ImageCubeArray,
|
||||
Image3D,
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Resource slot
|
||||
*
|
||||
* Describes the type of a single resource
|
||||
* binding that a shader can access.
|
||||
*/
|
||||
struct DxvkResourceSlot {
|
||||
uint32_t slot;
|
||||
VkDescriptorType type;
|
||||
DxvkResourceDim dim;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Shader interface binding
|
||||
*
|
||||
@ -16,6 +47,7 @@ namespace dxvk {
|
||||
struct DxvkDescriptorSlot {
|
||||
uint32_t slot; ///< Resource slot index for the context
|
||||
VkDescriptorType type; ///< Descriptor type (aka resource type)
|
||||
DxvkResourceDim dim; ///< Resource dimension (buffer or image)
|
||||
VkShaderStageFlags stages; ///< Stages that can use the resource
|
||||
};
|
||||
|
||||
@ -60,11 +92,13 @@ namespace dxvk {
|
||||
* entirely new binding is added.
|
||||
* \param [in] slot Resource slot
|
||||
* \param [in] type Resource type
|
||||
* \param [in] dim Resource dimension
|
||||
* \param [in] stage Shader stage
|
||||
*/
|
||||
void defineSlot(
|
||||
uint32_t slot,
|
||||
VkDescriptorType type,
|
||||
DxvkResourceDim dim,
|
||||
VkShaderStageFlagBits stage);
|
||||
|
||||
/**
|
||||
|
@ -59,7 +59,7 @@ namespace dxvk {
|
||||
void DxvkShader::defineResourceSlots(
|
||||
DxvkDescriptorSlotMapping& mapping) const {
|
||||
for (const auto& slot : m_slots)
|
||||
mapping.defineSlot(slot.slot, slot.type, m_stage);
|
||||
mapping.defineSlot(slot.slot, slot.type, slot.dim, m_stage);
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,18 +9,6 @@
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
/**
|
||||
* \brief Resource slot
|
||||
*
|
||||
* Describes the type of a single resource
|
||||
* binding that a shader can access.
|
||||
*/
|
||||
struct DxvkResourceSlot {
|
||||
uint32_t slot;
|
||||
VkDescriptorType type;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Shader module object
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user