Pass the texture type to CalculateSampleGather

This commit is contained in:
baldurk
2020-04-10 18:15:54 +01:00
parent 39b28a7780
commit 4b830d4a66
4 changed files with 47 additions and 8 deletions
+11 -3
View File
@@ -1566,13 +1566,21 @@ void ThreadState::StepNext(ShaderDebugState *state,
RDCASSERT(sampler.type == VarType::Unknown || sampler.type == VarType::ReadOnlyResource ||
sampler.type == VarType::Sampler);
// at setup time we stored the texture type for easy access here
DebugAPIWrapper::TextureType texType =
(DebugAPIWrapper::TextureType)img.value.uv[TextureTypeVariableSlot];
ShaderVariable result;
result.type = resultType.scalar().Type();
if(!debugger.GetAPIWrapper()->CalculateSampleGather(*this, opdata.op, img.GetBinding(),
sampler.GetBinding(), uv, ddxCalc, ddyCalc,
compare, gather, operands, result))
BindpointIndex samplerIndex = BindpointIndex(~0U, ~0U, ~0U);
if(sampler.type == VarType::Sampler)
samplerIndex = sampler.GetBinding();
if(!debugger.GetAPIWrapper()->CalculateSampleGather(
*this, opdata.op, texType, img.GetBinding(), samplerIndex, uv, ddxCalc, ddyCalc,
compare, gather, operands, result))
{
// sample failed. Pretend we got 0 columns back
+17 -4
View File
@@ -58,10 +58,21 @@ public:
virtual void FillInputValue(ShaderVariable &var, ShaderBuiltin builtin, uint32_t location,
uint32_t component) = 0;
virtual bool CalculateSampleGather(ThreadState &thread, rdcspv::Op opcode, BindpointIndex imageBind,
BindpointIndex samplerBind, const ShaderVariable &uv,
const ShaderVariable &ddxCalc, const ShaderVariable &ddyCalc,
const ShaderVariable &compare, GatherChannel gatherChannel,
enum TextureType
{
Float_Texture = 0x00,
UInt_Texture = 0x01,
SInt_Texture = 0x02,
Buffer_Texture = 0x10,
};
virtual bool CalculateSampleGather(ThreadState &lane, rdcspv::Op opcode, TextureType texType,
BindpointIndex imageBind, BindpointIndex samplerBind,
const ShaderVariable &uv, const ShaderVariable &ddxCalc,
const ShaderVariable &ddyCalc, const ShaderVariable &compare,
GatherChannel gatherChannel,
const ImageOperandsAndParamDatas &operands,
ShaderVariable &output) = 0;
@@ -77,6 +88,8 @@ public:
uint32_t component) = 0;
};
static const uint32_t TextureTypeVariableSlot = 8;
typedef ShaderVariable (*ExtInstImpl)(ThreadState &, const rdcarray<Id> &);
struct ExtInstDispatcher
@@ -406,6 +406,23 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *apiWrapper, const Shader
var.type = VarType::ReadOnlyResource;
debugType = DebugVariableType::ReadOnlyResource;
// store the texture type here, since the image may be copied around and combined with a
// sampler, so accessing the original type might be non-trivial at point of access
uint32_t texType = DebugAPIWrapper::Float_Texture;
if(imageTypes[type.InnerType()].dim == Dim::Buffer)
texType |= DebugAPIWrapper::Buffer_Texture;
if(imageTypes[type.InnerType()].retType.type == Op::TypeInt)
{
if(imageTypes[type.InnerType()].retType.signedness)
texType |= DebugAPIWrapper::SInt_Texture;
else
texType |= DebugAPIWrapper::UInt_Texture;
}
var.value.uv[TextureTypeVariableSlot] = texType;
global.readOnlyResources.push_back(var);
readOnlyIDs.push_back(v.id);
}
+2 -1
View File
@@ -266,7 +266,8 @@ public:
return DerivativeDeltas();
}
bool CalculateSampleGather(rdcspv::ThreadState &thread, rdcspv::Op opcode, BindpointIndex imageBind,
bool CalculateSampleGather(rdcspv::ThreadState &lane, rdcspv::Op opcode,
DebugAPIWrapper::TextureType texType, BindpointIndex imageBind,
BindpointIndex samplerBind, const ShaderVariable &uv,
const ShaderVariable &ddxCalc, const ShaderVariable &ddyCalc,
const ShaderVariable &compare, rdcspv::GatherChannel gatherChannel,