diff --git a/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp b/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp index 482eaec2f..bbc185794 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp +++ b/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp @@ -3009,7 +3009,8 @@ State State::GetNext(GlobalState &global, DebugAPIWrapper *apiWrapper, State qua gsm = (op.operands[0].type == TYPE_THREAD_GROUP_SHARED_MEMORY); } - elemIdx = srcOpers[0].value.u.x; + // the index is supposed to be a multiple of 4 but the behaviour seems to be to round down + elemIdx = (srcOpers[0].value.u.x & ~0x3); stride = 1; } @@ -3101,12 +3102,15 @@ State State::GetNext(GlobalState &global, DebugAPIWrapper *apiWrapper, State qua { ShaderVariable fetch = TypedUAVLoad(fmt, data); - // if we are assigning into a scalar, SetDst expects the result to be in .x (as normally - // we are assigning FROM a scalar also). - // to match this expectation, propogate the component across. - if(op.operands[0].comps[0] != 0xff && op.operands[0].comps[1] == 0xff && - op.operands[0].comps[2] == 0xff && op.operands[0].comps[3] == 0xff) - fetch.value.uv[0] = fetch.value.uv[op.operands[0].comps[0]]; + if(op.operation != OPCODE_LD_RAW) + { + // if we are assigning into a scalar, SetDst expects the result to be in .x (as normally + // we are assigning FROM a scalar also). + // to match this expectation, propogate the component across. + if(op.operands[0].comps[0] != 0xff && op.operands[0].comps[1] == 0xff && + op.operands[0].comps[2] == 0xff && op.operands[0].comps[3] == 0xff) + fetch.value.uv[0] = fetch.value.uv[op.operands[0].comps[0]]; + } s.SetDst(op.operands[0], op, fetch); } diff --git a/util/test/demos/d3d11/d3d11_helpers.cpp b/util/test/demos/d3d11/d3d11_helpers.cpp index 6dbc84947..30b6b28b5 100644 --- a/util/test/demos/d3d11/d3d11_helpers.cpp +++ b/util/test/demos/d3d11/d3d11_helpers.cpp @@ -760,8 +760,9 @@ D3D11ViewCreator::operator ID3D11ShaderResourceViewPtr() UINT elementStride = bufdesc.StructureByteStride; - if(bufdesc.StructureByteStride == 0 && desc.srv.Format == DXGI_FORMAT_UNKNOWN) - TEST_FATAL("Can't create SRV on non-structured buffer with no format"); + if(bufdesc.StructureByteStride == 0 && desc.srv.Format == DXGI_FORMAT_UNKNOWN && + (bufdesc.MiscFlags & D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS) == 0) + TEST_FATAL("Can't create SRV on non-structured non-view buffer with no format"); if(desc.srv.Format != DXGI_FORMAT_UNKNOWN) elementStride = formatStrides[desc.srv.Format]; diff --git a/util/test/demos/d3d11/d3d11_shader_debug_zoo.cpp b/util/test/demos/d3d11/d3d11_shader_debug_zoo.cpp index 415a57912..ed3e6564b 100644 --- a/util/test/demos/d3d11/d3d11_shader_debug_zoo.cpp +++ b/util/test/demos/d3d11/d3d11_shader_debug_zoo.cpp @@ -82,6 +82,8 @@ v2f main(consts IN, uint tri : SV_InstanceID) std::string pixel = R"EOSHADER( Buffer test : register(t0); +ByteAddressBuffer byterotest : register(t1); +RWByteAddressBuffer byterwtest : register(u1); float4 main(v2f IN) : SV_Target0 { @@ -201,12 +203,32 @@ float4 main(v2f IN) : SV_Target0 if(IN.tri == 34) return float4(tiny * 1.5e-8f, tiny * 1.5e-9f, asfloat(intval) == 0.0f ? 1.0f : 0.0f, 1.0f); + // test reading/writing byte address data + if(IN.tri == 35) + { + return float4(asfloat(byterotest.Load(0).x), asfloat(byterotest.Load(1).x), + asfloat(byterotest.Load(3).x), float(byterotest.Load(8).x)); + } + + if(IN.tri == 36) + { + byterwtest.Store(0, asuint(5.4321f)); + byterwtest.Store(4, asuint(9.8765f)); + byterwtest.Store(8, 0xbeef); + + // use this to ensure the compiler doesn't know we're loading from the same locations + uint zero = intval - IN.tri - 7; + + return float4(asfloat(byterwtest.Load(zero+0).x), asfloat(byterwtest.Load(zero+1).x), + asfloat(byterwtest.Load(zero+3).x), float(byterwtest.Load(zero+8).x)); + } + return float4(0.4f, 0.4f, 0.4f, 0.4f); } )EOSHADER"; - static const uint32_t numTests = 35; + static const uint32_t numTests = 37; int main() { @@ -257,15 +279,30 @@ float4 main(v2f IN) : SV_Target0 ID3D11BufferPtr vb = MakeBuffer().Vertex().Data(triangle); + union + { + float f; + uint32_t u; + } pun; + + pun.u = 0xdead; + float testdata[] = { - 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, - 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 120.0f, + 1.2345f, 2.345678f, pun.f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, + 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 120.0f, }; ID3D11BufferPtr srvBuf = MakeBuffer().SRV().Data(testdata); ID3D11ShaderResourceViewPtr srv = MakeSRV(srvBuf).Format(DXGI_FORMAT_R32_FLOAT); + ID3D11BufferPtr rawBuf = MakeBuffer().SRV().ByteAddressed().Data(testdata); + ID3D11ShaderResourceViewPtr rawsrv = MakeSRV(rawBuf).Format(DXGI_FORMAT_R32_TYPELESS); + + ID3D11BufferPtr rawBuf2 = MakeBuffer().UAV().ByteAddressed().Size(1024); + ID3D11UnorderedAccessViewPtr rawuav = MakeUAV(rawBuf2).Format(DXGI_FORMAT_R32_TYPELESS); + ctx->PSSetShaderResources(0, 1, &srv.GetInterfacePtr()); + ctx->PSSetShaderResources(1, 1, &rawsrv.GetInterfacePtr()); while(Running()) { @@ -281,7 +318,10 @@ float4 main(v2f IN) : SV_Target0 RSSetViewport({0.0f, 0.0f, (float)texDim, 4.0f, 0.0f, 1.0f}); - ctx->OMSetRenderTargets(1, &fltRT.GetInterfacePtr(), NULL); + UINT zero[4] = {}; + ctx->ClearUnorderedAccessViewUint(rawuav, zero); + ctx->OMSetRenderTargetsAndUnorderedAccessViews(1, &fltRT.GetInterfacePtr(), NULL, 1, 1, + &rawuav.GetInterfacePtr(), NULL); ctx->DrawInstanced(3, numTests, 0, 0);