mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-21 22:54:16 +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;
|
DxvkResourceSlot resource;
|
||||||
resource.slot = bindingId;
|
resource.slot = bindingId;
|
||||||
resource.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
resource.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||||
|
resource.dim = DxvkResourceDim::Buffer;
|
||||||
m_resourceSlots.push_back(resource);
|
m_resourceSlots.push_back(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -587,6 +588,7 @@ namespace dxvk {
|
|||||||
DxvkResourceSlot resource;
|
DxvkResourceSlot resource;
|
||||||
resource.slot = bindingId;
|
resource.slot = bindingId;
|
||||||
resource.type = VK_DESCRIPTOR_TYPE_SAMPLER;
|
resource.type = VK_DESCRIPTOR_TYPE_SAMPLER;
|
||||||
|
resource.dim = DxvkResourceDim::Opaque;
|
||||||
m_resourceSlots.push_back(resource);
|
m_resourceSlots.push_back(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -723,6 +725,7 @@ namespace dxvk {
|
|||||||
// Store descriptor info for the shader interface
|
// Store descriptor info for the shader interface
|
||||||
DxvkResourceSlot resource;
|
DxvkResourceSlot resource;
|
||||||
resource.slot = bindingId;
|
resource.slot = bindingId;
|
||||||
|
resource.dim = getDxvkResourceDim(resourceType);
|
||||||
|
|
||||||
if (isUav) {
|
if (isUav) {
|
||||||
resource.type = resourceType == DxbcResourceDim::Buffer
|
resource.type = resourceType == DxbcResourceDim::Buffer
|
||||||
@ -822,6 +825,7 @@ namespace dxvk {
|
|||||||
resource.type = isUav
|
resource.type = isUav
|
||||||
? VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
|
? VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
|
||||||
: VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
|
: VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
|
||||||
|
resource.dim = DxvkResourceDim::Buffer;
|
||||||
m_resourceSlots.push_back(resource);
|
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) {
|
uint32_t DxbcCompiler::getScalarTypeId(DxbcScalarType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DxbcScalarType::Uint32: return m_module.defIntType(32, 0);
|
case DxbcScalarType::Uint32: return m_module.defIntType(32, 0);
|
||||||
|
@ -728,6 +728,9 @@ namespace dxvk {
|
|||||||
DxbcVectorType getInputRegType(
|
DxbcVectorType getInputRegType(
|
||||||
uint32_t regIdx) const;
|
uint32_t regIdx) const;
|
||||||
|
|
||||||
|
DxvkResourceDim getDxvkResourceDim(
|
||||||
|
DxbcResourceDim dim) const;
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
// Type definition methods
|
// Type definition methods
|
||||||
uint32_t getScalarTypeId(
|
uint32_t getScalarTypeId(
|
||||||
|
@ -11,6 +11,7 @@ namespace dxvk {
|
|||||||
void DxvkDescriptorSlotMapping::defineSlot(
|
void DxvkDescriptorSlotMapping::defineSlot(
|
||||||
uint32_t slot,
|
uint32_t slot,
|
||||||
VkDescriptorType type,
|
VkDescriptorType type,
|
||||||
|
DxvkResourceDim dim,
|
||||||
VkShaderStageFlagBits stage) {
|
VkShaderStageFlagBits stage) {
|
||||||
uint32_t bindingId = this->getBindingId(slot);
|
uint32_t bindingId = this->getBindingId(slot);
|
||||||
|
|
||||||
@ -20,6 +21,7 @@ namespace dxvk {
|
|||||||
DxvkDescriptorSlot slotInfo;
|
DxvkDescriptorSlot slotInfo;
|
||||||
slotInfo.slot = slot;
|
slotInfo.slot = slot;
|
||||||
slotInfo.type = type;
|
slotInfo.type = type;
|
||||||
|
slotInfo.dim = dim;
|
||||||
slotInfo.stages = stage;
|
slotInfo.stages = stage;
|
||||||
m_descriptorSlots.push_back(slotInfo);
|
m_descriptorSlots.push_back(slotInfo);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,37 @@
|
|||||||
|
|
||||||
namespace dxvk {
|
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
|
* \brief Shader interface binding
|
||||||
*
|
*
|
||||||
@ -16,6 +47,7 @@ namespace dxvk {
|
|||||||
struct DxvkDescriptorSlot {
|
struct DxvkDescriptorSlot {
|
||||||
uint32_t slot; ///< Resource slot index for the context
|
uint32_t slot; ///< Resource slot index for the context
|
||||||
VkDescriptorType type; ///< Descriptor type (aka resource type)
|
VkDescriptorType type; ///< Descriptor type (aka resource type)
|
||||||
|
DxvkResourceDim dim; ///< Resource dimension (buffer or image)
|
||||||
VkShaderStageFlags stages; ///< Stages that can use the resource
|
VkShaderStageFlags stages; ///< Stages that can use the resource
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -60,11 +92,13 @@ namespace dxvk {
|
|||||||
* entirely new binding is added.
|
* entirely new binding is added.
|
||||||
* \param [in] slot Resource slot
|
* \param [in] slot Resource slot
|
||||||
* \param [in] type Resource type
|
* \param [in] type Resource type
|
||||||
|
* \param [in] dim Resource dimension
|
||||||
* \param [in] stage Shader stage
|
* \param [in] stage Shader stage
|
||||||
*/
|
*/
|
||||||
void defineSlot(
|
void defineSlot(
|
||||||
uint32_t slot,
|
uint32_t slot,
|
||||||
VkDescriptorType type,
|
VkDescriptorType type,
|
||||||
|
DxvkResourceDim dim,
|
||||||
VkShaderStageFlagBits stage);
|
VkShaderStageFlagBits stage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,7 +59,7 @@ namespace dxvk {
|
|||||||
void DxvkShader::defineResourceSlots(
|
void DxvkShader::defineResourceSlots(
|
||||||
DxvkDescriptorSlotMapping& mapping) const {
|
DxvkDescriptorSlotMapping& mapping) const {
|
||||||
for (const auto& slot : m_slots)
|
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 {
|
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
|
* \brief Shader module object
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user