From 1f803add1ed338928f5f7350a0ffa25683edc7b4 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 11 Mar 2024 14:03:49 +0000 Subject: [PATCH] Declare input attachments in shader reflection * This avoids the need to communicate this information in the descriptor type. Since descriptors must match the shader in this area, it's easier to communicate this through shader reflection. --- renderdoc/api/replay/shader_types.h | 6 +++++- renderdoc/driver/shaders/spirv/spirv_reflect.cpp | 1 + renderdoc/replay/renderdoc_serialise.inl | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/renderdoc/api/replay/shader_types.h b/renderdoc/api/replay/shader_types.h index 808266e37..aac7062ad 100644 --- a/renderdoc/api/replay/shader_types.h +++ b/renderdoc/api/replay/shader_types.h @@ -1243,7 +1243,7 @@ struct ShaderResource { return resType == o.resType && name == o.name && variableType == o.variableType && bindPoint == o.bindPoint && isTexture == o.isTexture && hasSampler == o.hasSampler && - isReadOnly == o.isReadOnly; + isInputAttachment == o.isInputAttachment && isReadOnly == o.isReadOnly; } bool operator<(const ShaderResource &o) const { @@ -1259,6 +1259,8 @@ struct ShaderResource return isTexture < o.isTexture; if(!(hasSampler == o.hasSampler)) return hasSampler < o.hasSampler; + if(!(isInputAttachment == o.isInputAttachment)) + return isInputAttachment < o.isInputAttachment; if(!(isReadOnly == o.isReadOnly)) return isReadOnly < o.isReadOnly; return false; @@ -1285,6 +1287,8 @@ struct ShaderResource bool isTexture; DOCUMENT("``True`` if this texture resource has a sampler as well."); bool hasSampler = false; + DOCUMENT("``True`` if this texture resource is a subpass input attachment."); + bool isInputAttachment = false; DOCUMENT(R"(``True`` if this resource is available to the shader for reading only, otherwise it is able to be read from and written to arbitrarily. )"); diff --git a/renderdoc/driver/shaders/spirv/spirv_reflect.cpp b/renderdoc/driver/shaders/spirv/spirv_reflect.cpp index 6399acd0b..3a2a86309 100644 --- a/renderdoc/driver/shaders/spirv/spirv_reflect.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_reflect.cpp @@ -1465,6 +1465,7 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st res.isTexture = res.resType != TextureType::Buffer; res.isReadOnly = imageType.sampled != 2 || imageType.dim == rdcspv::Dim::SubpassData; + res.isInputAttachment = imageType.dim == rdcspv::Dim::SubpassData; res.variableType.baseType = imageType.retType.Type(); diff --git a/renderdoc/replay/renderdoc_serialise.inl b/renderdoc/replay/renderdoc_serialise.inl index 6c21f9c85..42e658291 100644 --- a/renderdoc/replay/renderdoc_serialise.inl +++ b/renderdoc/replay/renderdoc_serialise.inl @@ -223,6 +223,7 @@ void DoSerialise(SerialiserType &ser, ShaderResource &el) SERIALISE_MEMBER(bindPoint); SERIALISE_MEMBER(isTexture); SERIALISE_MEMBER(hasSampler); + SERIALISE_MEMBER(isInputAttachment); SERIALISE_MEMBER(isReadOnly); SIZE_CHECK(112);