1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-18 02:52:10 +01:00

[dxvk] Replaced DxvkResourceType by VkImageViewType

This commit is contained in:
Philip Rebohle 2018-01-09 20:35:29 +01:00
parent 3419d55dee
commit da867d4bca
7 changed files with 43 additions and 51 deletions

View File

@ -552,7 +552,7 @@ namespace dxvk {
DxvkResourceSlot resource;
resource.slot = bindingId;
resource.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
resource.dim = DxvkResourceDim::Buffer;
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
m_resourceSlots.push_back(resource);
}
@ -588,7 +588,7 @@ namespace dxvk {
DxvkResourceSlot resource;
resource.slot = bindingId;
resource.type = VK_DESCRIPTOR_TYPE_SAMPLER;
resource.dim = DxvkResourceDim::Opaque;
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
m_resourceSlots.push_back(resource);
}
@ -649,8 +649,7 @@ namespace dxvk {
case DxbcResourceDim::Texture2DMs: return { spv::Dim2D, 0, 1, isUav ? 2u : 1u };
case DxbcResourceDim::Texture2DMsArr: return { spv::Dim2D, 1, 1, isUav ? 2u : 1u };
case DxbcResourceDim::Texture3D: return { spv::Dim3D, 0, 0, isUav ? 2u : 1u };
// Some applications bind non-array cube maps to cube map array slots
case DxbcResourceDim::TextureCube: return { spv::DimCube, 1, 0, isUav ? 2u : 1u };
case DxbcResourceDim::TextureCube: return { spv::DimCube, 0, 0, isUav ? 2u : 1u };
case DxbcResourceDim::TextureCubeArr: return { spv::DimCube, 1, 0, isUav ? 2u : 1u };
default: throw DxvkError(str::format("DxbcCompiler: Unsupported resource type: ", resourceType));
}
@ -661,7 +660,6 @@ namespace dxvk {
case DxbcResourceDim::Buffer: m_module.enableCapability(spv::CapabilityImageBuffer); break;
case DxbcResourceDim::Texture1D: m_module.enableCapability(spv::CapabilityImage1D); break;
case DxbcResourceDim::Texture1DArr: m_module.enableCapability(spv::CapabilityImage1D); break;
case DxbcResourceDim::TextureCube:
case DxbcResourceDim::TextureCubeArr: m_module.enableCapability(spv::CapabilityImageCubeArray); break;
case DxbcResourceDim::Texture2DMsArr: m_module.enableCapability(spv::CapabilityImageMSArray); break;
default: break; // No additional capabilities required
@ -727,7 +725,7 @@ namespace dxvk {
// Store descriptor info for the shader interface
DxvkResourceSlot resource;
resource.slot = bindingId;
resource.dim = getDxvkResourceDim(resourceType);
resource.view = getViewType(resourceType);
if (isUav) {
resource.type = resourceType == DxbcResourceDim::Buffer
@ -827,7 +825,7 @@ namespace dxvk {
resource.type = isUav
? VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
: VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
resource.dim = DxvkResourceDim::Buffer;
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
m_resourceSlots.push_back(resource);
}
@ -4349,22 +4347,22 @@ namespace dxvk {
}
DxvkResourceDim DxbcCompiler::getDxvkResourceDim(DxbcResourceDim dim) const {
VkImageViewType DxbcCompiler::getViewType(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;
case DxbcResourceDim::Unknown:
case DxbcResourceDim::Buffer:
case DxbcResourceDim::RawBuffer:
case DxbcResourceDim::StructuredBuffer: return VK_IMAGE_VIEW_TYPE_MAX_ENUM;
case DxbcResourceDim::Texture1D: return VK_IMAGE_VIEW_TYPE_1D;
case DxbcResourceDim::Texture1DArr: return VK_IMAGE_VIEW_TYPE_1D_ARRAY;
case DxbcResourceDim::Texture2D: return VK_IMAGE_VIEW_TYPE_2D;
case DxbcResourceDim::Texture2DMs: return VK_IMAGE_VIEW_TYPE_2D;
case DxbcResourceDim::Texture2DArr: return VK_IMAGE_VIEW_TYPE_2D_ARRAY;
case DxbcResourceDim::Texture2DMsArr: return VK_IMAGE_VIEW_TYPE_2D_ARRAY;
case DxbcResourceDim::TextureCube: return VK_IMAGE_VIEW_TYPE_CUBE;
case DxbcResourceDim::TextureCubeArr: return VK_IMAGE_VIEW_TYPE_CUBE_ARRAY;
case DxbcResourceDim::Texture3D: return VK_IMAGE_VIEW_TYPE_3D;
}
}

View File

@ -731,7 +731,7 @@ namespace dxvk {
DxbcVectorType getInputRegType(
uint32_t regIdx) const;
DxvkResourceDim getDxvkResourceDim(
VkImageViewType getViewType(
DxbcResourceDim dim) const;
///////////////////////////

View File

@ -1064,7 +1064,8 @@ namespace dxvk {
m_cmd->trackResource(res.imageView);
m_cmd->trackResource(res.imageView->image());
} else {
Logger::err("DxvkContext: Unbound image descriptor");
Logger::err("DxvkContext: Unbound or incompatible image descriptor");
Logger::err(str::format(res.imageView->type(), " ", binding.view));
m_descriptors[i].image.sampler = VK_NULL_HANDLE;
m_descriptors[i].image.imageView = VK_NULL_HANDLE;
m_descriptors[i].image.imageLayout = VK_IMAGE_LAYOUT_UNDEFINED;

View File

@ -219,6 +219,18 @@ namespace dxvk {
return m_view;
}
/**
* \brief Image view type
*
* Convenience method to query the
* view type in order to check for
* resource compatibility.
* \returns Image view type
*/
VkImageViewType type() const {
return m_info.type;
}
/**
* \brief Image view properties
* \returns Image view properties

View File

@ -11,7 +11,7 @@ namespace dxvk {
void DxvkDescriptorSlotMapping::defineSlot(
uint32_t slot,
VkDescriptorType type,
DxvkResourceDim dim,
VkImageViewType view,
VkShaderStageFlagBits stage) {
uint32_t bindingId = this->getBindingId(slot);
@ -21,7 +21,7 @@ namespace dxvk {
DxvkDescriptorSlot slotInfo;
slotInfo.slot = slot;
slotInfo.type = type;
slotInfo.dim = dim;
slotInfo.view = view;
slotInfo.stages = stage;
m_descriptorSlots.push_back(slotInfo);
}

View File

@ -6,25 +6,6 @@
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
*
@ -32,9 +13,9 @@ namespace dxvk {
* binding that a shader can access.
*/
struct DxvkResourceSlot {
uint32_t slot;
VkDescriptorType type;
DxvkResourceDim dim;
uint32_t slot;
VkDescriptorType type;
VkImageViewType view;
};
/**
@ -47,7 +28,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)
VkImageViewType view; ///< Compatible image view type
VkShaderStageFlags stages; ///< Stages that can use the resource
};
@ -92,13 +73,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] view Image view type
* \param [in] stage Shader stage
*/
void defineSlot(
uint32_t slot,
VkDescriptorType type,
DxvkResourceDim dim,
VkImageViewType view,
VkShaderStageFlagBits stage);
/**

View File

@ -59,7 +59,7 @@ namespace dxvk {
void DxvkShader::defineResourceSlots(
DxvkDescriptorSlotMapping& mapping) const {
for (const auto& slot : m_slots)
mapping.defineSlot(slot.slot, slot.type, slot.dim, m_stage);
mapping.defineSlot(slot.slot, slot.type, slot.view, m_stage);
}