diff --git a/renderdoc/api/replay/d3d12_pipestate.h b/renderdoc/api/replay/d3d12_pipestate.h index 513633932..90dca1acb 100644 --- a/renderdoc/api/replay/d3d12_pipestate.h +++ b/renderdoc/api/replay/d3d12_pipestate.h @@ -28,10 +28,14 @@ struct D3D12PipelineState { - D3D12PipelineState() {} + D3D12PipelineState() : customName(false) {} + ResourceId pipeline; + bool32 customName; + rdctype::str PipelineName; + struct InputAssembler { - InputAssembler() : Bytecode(NULL), customName(false) {} + InputAssembler() : indexStripCutValue(0) {} struct LayoutInput { LayoutInput() @@ -47,17 +51,14 @@ struct D3D12PipelineState uint32_t InstanceDataStepRate; }; rdctype::array layouts; - ResourceId layout; - ShaderReflection *Bytecode; - bool32 customName; - rdctype::str LayoutName; struct VertexBuffer { VertexBuffer() : Buffer(), Stride(0), Offset(0) {} ResourceId Buffer; + uint64_t Offset; + uint32_t Size; uint32_t Stride; - uint32_t Offset; }; rdctype::array vbuffers; @@ -65,137 +66,163 @@ struct D3D12PipelineState { IndexBuffer() : Buffer(), Offset(0) {} ResourceId Buffer; - uint32_t Offset; + uint64_t Offset; + uint32_t Size; } ibuffer; + + uint32_t indexStripCutValue; } m_IA; struct ShaderStage { - ShaderStage() : Shader(), customName(false), ShaderDetails(NULL), stage(eShaderStage_Vertex) {} - ResourceId Shader; - rdctype::str ShaderName; - bool32 customName; + ShaderStage() : Present(false), ShaderDetails(NULL), stage(eShaderStage_Vertex) {} + bool32 Present; ShaderReflection *ShaderDetails; ShaderBindpointMapping BindpointMapping; ShaderStageType stage; - - struct ResourceView - { - ResourceView() - : View(), - Resource(), - Format(), - Structured(false), - BufferStructCount(0), - ElementSize(0), - ElementOffset(0), - ElementWidth(0), - FirstElement(0), - NumElements(1), - Flags(0), - HighestMip(0), - NumMipLevels(1), - ArraySize(1), - FirstArraySlice(0) - { - } - - ResourceId View; - ResourceId Resource; - rdctype::str Type; - ResourceFormat Format; - - bool32 Structured; - uint32_t BufferStructCount; - uint32_t ElementSize; - - // Buffer (SRV) - uint32_t ElementOffset; - uint32_t ElementWidth; - - // Buffer (UAV) - uint32_t FirstElement; - uint32_t NumElements; - - // BufferEx - uint32_t Flags; - - // Texture - uint32_t HighestMip; - uint32_t NumMipLevels; - - // Texture Array - uint32_t ArraySize; - uint32_t FirstArraySlice; - }; - rdctype::array SRVs; - rdctype::array UAVs; - - struct Sampler - { - Sampler() - : Samp(), - customSamplerName(false), - UseBorder(false), - UseComparison(false), - MaxAniso(0), - MaxLOD(0.0f), - MinLOD(0.0f), - MipLODBias(0.0f) - { - BorderColor[0] = BorderColor[1] = BorderColor[2] = BorderColor[3] = 0.0f; - } - ResourceId Samp; - rdctype::str SamplerName; - bool32 customSamplerName; - rdctype::str AddressU, AddressV, AddressW; - float BorderColor[4]; - rdctype::str Comparison; - rdctype::str Filter; - bool32 UseBorder; - bool32 UseComparison; - uint32_t MaxAniso; - float MaxLOD; - float MinLOD; - float MipLODBias; - }; - rdctype::array Samplers; - - struct CBuffer - { - CBuffer() : Buffer(), VecOffset(0), VecCount(0) {} - ResourceId Buffer; - uint32_t VecOffset; - uint32_t VecCount; - }; - rdctype::array ConstantBuffers; - - rdctype::array ClassInstances; } m_VS, m_HS, m_DS, m_GS, m_PS, m_CS; + struct ResourceView + { + ResourceView() + : Resource(), + Format(), + BufferFlags(0), + BufferStructCount(0), + ElementSize(0), + FirstElement(0), + NumElements(1), + CounterByteOffset(0), + HighestMip(0), + NumMipLevels(1), + ArraySize(1), + FirstArraySlice(0), + MinLODClamp(0.0f) + { + swizzle[0] = eSwizzle_Red; + swizzle[1] = eSwizzle_Green; + swizzle[2] = eSwizzle_Blue; + swizzle[3] = eSwizzle_Alpha; + } + + ResourceId Resource; + rdctype::str Type; + ResourceFormat Format; + + TextureSwizzle swizzle[4]; + uint32_t BufferFlags; + uint32_t BufferStructCount; + uint32_t ElementSize; + uint64_t FirstElement; + uint32_t NumElements; + + ResourceId CounterResource; + uint64_t CounterByteOffset; + + // Texture + uint32_t HighestMip; + uint32_t NumMipLevels; + + // Texture Array + uint32_t ArraySize; + uint32_t FirstArraySlice; + + float MinLODClamp; + }; + + struct Sampler + { + Sampler() + : UseBorder(false), + UseComparison(false), + MaxAniso(0), + MaxLOD(0.0f), + MinLOD(0.0f), + MipLODBias(0.0f) + { + BorderColor[0] = BorderColor[1] = BorderColor[2] = BorderColor[3] = 0.0f; + } + rdctype::str AddressU, AddressV, AddressW; + float BorderColor[4]; + rdctype::str Comparison; + rdctype::str Filter; + bool32 UseBorder; + bool32 UseComparison; + uint32_t MaxAniso; + float MaxLOD; + float MinLOD; + float MipLODBias; + }; + + struct CBuffer + { + CBuffer() : Buffer(), Offset(0), ByteSize(0) {} + ResourceId Buffer; + uint64_t Offset; + uint32_t ByteSize; + }; + + struct RootSignature + { + ResourceId obj; + + struct RootElem + { + ShaderStageBits VisibilityMask; + + // true for root constants and root descriptors + bool32 RootElement; + + // for tables this is the expanded list of all the ranges and their values, for + // root constants and root descriptors there's only one element with their value + struct Descriptor + { + uint32_t RegSpace; + uint32_t RegIndex; + + ShaderBindType Type; + + rdctype::array Constants; + + CBuffer ConstantBuffer; + ResourceView View; + }; + rdctype::array Descriptors; + }; + + rdctype::array Elements; + } m_RootSig; + struct Streamout { struct Output { - Output() : Buffer(), Offset(0) {} + Output() : Buffer(), Offset(0), Size(0), WrittenCountBuffer(), WrittenCountOffset(0) {} ResourceId Buffer; - uint32_t Offset; + uint64_t Offset; + uint64_t Size; + + ResourceId WrittenCountBuffer; + uint64_t WrittenCountOffset; }; rdctype::array Outputs; } m_SO; struct Rasterizer { + Rasterizer() : SampleMask(~0U) {} + uint32_t SampleMask; + struct Viewport { - Viewport() : Width(0.0f), Height(0.0f), MinDepth(0.0f), MaxDepth(0.0f), Enabled(false) + Viewport() : Width(0.0f), Height(0.0f), MinDepth(0.0f), MaxDepth(0.0f) { TopLeft[0] = 0.0f; TopLeft[1] = 0.0f; } - Viewport(float TX, float TY, float W, float H, float MN, float MX, bool en) - : Width(W), Height(H), MinDepth(MN), MaxDepth(MX), Enabled(en) + Viewport(float TX, float TY, float W, float H, float MN, float MX) + : Width(W), Height(H), MinDepth(MN), MaxDepth(MX) { TopLeft[0] = TX; TopLeft[1] = TY; @@ -203,41 +230,33 @@ struct D3D12PipelineState float TopLeft[2]; float Width, Height; float MinDepth, MaxDepth; - bool32 Enabled; }; rdctype::array Viewports; struct Scissor { - Scissor() : left(0), top(0), right(0), bottom(0), Enabled(false) {} - Scissor(int l, int t, int r, int b, bool en) - : left(l), top(t), right(r), bottom(b), Enabled(en) - { - } + Scissor() : left(0), top(0), right(0), bottom(0) {} + Scissor(int l, int t, int r, int b) : left(l), top(t), right(r), bottom(b) {} int32_t left, top, right, bottom; - bool32 Enabled; }; rdctype::array Scissors; struct RasterizerState { RasterizerState() - : State(), - FillMode(eFill_Solid), + : FillMode(eFill_Solid), CullMode(eCull_None), FrontCCW(false), DepthBias(0), DepthBiasClamp(0.0f), SlopeScaledDepthBias(0.0f), DepthClip(false), - ScissorEnable(false), MultisampleEnable(false), AntialiasedLineEnable(false), ForcedSampleCount(0), ConservativeRasterization(false) { } - ResourceId State; TriangleFillMode FillMode; TriangleCullMode CullMode; bool32 FrontCCW; @@ -245,7 +264,6 @@ struct D3D12PipelineState float DepthBiasClamp; float SlopeScaledDepthBias; bool32 DepthClip; - bool32 ScissorEnable; bool32 MultisampleEnable; bool32 AntialiasedLineEnable; uint32_t ForcedSampleCount; @@ -255,23 +273,24 @@ struct D3D12PipelineState struct OutputMerger { - OutputMerger() : UAVStartSlot(0), DepthReadOnly(false), StencilReadOnly(false) {} + OutputMerger() + : DepthReadOnly(false), StencilReadOnly(false), multiSampleCount(1), multiSampleQuality(0) + { + } struct DepthStencilState { DepthStencilState() - : State(), + : DepthWrites(false), DepthEnable(false), - DepthWrites(false), StencilEnable(false), StencilReadMask(0), StencilWriteMask(0), StencilRef(0) { } - ResourceId State; bool32 DepthEnable; - rdctype::str DepthFunc; bool32 DepthWrites; + rdctype::str DepthFunc; bool32 StencilEnable; byte StencilReadMask; byte StencilWriteMask; @@ -289,13 +308,11 @@ struct D3D12PipelineState struct BlendState { - BlendState() : AlphaToCoverage(false), IndependentBlend(false), SampleMask(0) + BlendState() : AlphaToCoverage(false), IndependentBlend(false) { BlendFactor[0] = BlendFactor[1] = BlendFactor[2] = BlendFactor[3] = 0.0f; } - ResourceId State; - bool32 AlphaToCoverage; bool32 IndependentBlend; @@ -318,16 +335,15 @@ struct D3D12PipelineState rdctype::array Blends; float BlendFactor[4]; - uint32_t SampleMask; } m_BlendState; - rdctype::array RenderTargets; + rdctype::array RenderTargets; - uint32_t UAVStartSlot; - rdctype::array UAVs; - - ShaderStage::ResourceView DepthTarget; + ResourceView DepthTarget; bool32 DepthReadOnly; bool32 StencilReadOnly; + + uint32_t multiSampleCount; + uint32_t multiSampleQuality; } m_OM; }; diff --git a/renderdoc/api/replay/replay_enums.h b/renderdoc/api/replay/replay_enums.h index 0ba890f47..e16b44553 100644 --- a/renderdoc/api/replay/replay_enums.h +++ b/renderdoc/api/replay/replay_enums.h @@ -90,6 +90,7 @@ enum ShaderResourceType enum ShaderBindType { eBindType_Unknown = 0, + eBindType_ConstantBuffer, eBindType_Sampler, eBindType_ImageSampler, eBindType_ReadOnlyImage, diff --git a/renderdoc/driver/d3d12/d3d12_replay.cpp b/renderdoc/driver/d3d12/d3d12_replay.cpp index 78976a2dc..80b1dfc6c 100644 --- a/renderdoc/driver/d3d12/d3d12_replay.cpp +++ b/renderdoc/driver/d3d12/d3d12_replay.cpp @@ -326,8 +326,8 @@ APIProperties D3D12Replay::GetAPIProperties() { APIProperties ret; - ret.pipelineType = eGraphicsAPI_D3D11; - ret.localRenderer = eGraphicsAPI_D3D11; + ret.pipelineType = eGraphicsAPI_D3D12; + ret.localRenderer = eGraphicsAPI_D3D12; ret.degraded = false; return ret; diff --git a/renderdoc/driver/vulkan/vk_replay.cpp b/renderdoc/driver/vulkan/vk_replay.cpp index 27f22873b..644f5cd71 100644 --- a/renderdoc/driver/vulkan/vk_replay.cpp +++ b/renderdoc/driver/vulkan/vk_replay.cpp @@ -3527,13 +3527,13 @@ void VulkanReplay::SavePipelineState() dst.bindings[b].type = eBindType_ReadWriteTBuffer; break; case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: - dst.bindings[b].type = eBindType_ReadOnlyBuffer; + dst.bindings[b].type = eBindType_ConstantBuffer; break; case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: dst.bindings[b].type = eBindType_ReadWriteBuffer; break; case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: - dst.bindings[b].type = eBindType_ReadOnlyBuffer; + dst.bindings[b].type = eBindType_ConstantBuffer; dynamicOffset = true; break; case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: diff --git a/renderdoc/replay/replay_renderer.cpp b/renderdoc/replay/replay_renderer.cpp index f5ae9cb4c..06c0f20cc 100644 --- a/renderdoc/replay/replay_renderer.cpp +++ b/renderdoc/replay/replay_renderer.cpp @@ -1643,9 +1643,12 @@ void ReplayRenderer::FetchPipelineState() &m_D3D12PipelineState.m_GS, &m_D3D12PipelineState.m_PS, &m_D3D12PipelineState.m_CS, }; + const char *stageNames[] = {"VS", "HS", "DS", "GS", "PS", "CS"}; + for(int i = 0; i < 6; i++) - if(stages[i]->Shader != ResourceId()) - stages[i]->ShaderDetails = m_pDevice->GetShader(m_pDevice->GetLiveID(stages[i]->Shader), ""); + if(stages[i]->Present) + stages[i]->ShaderDetails = + m_pDevice->GetShader(m_pDevice->GetLiveID(m_D3D12PipelineState.pipeline), stageNames[i]); } { diff --git a/renderdocui/Interop/D3D12PipelineState.cs b/renderdocui/Interop/D3D12PipelineState.cs index 0aa4cc7df..c82d691db 100644 --- a/renderdocui/Interop/D3D12PipelineState.cs +++ b/renderdocui/Interop/D3D12PipelineState.cs @@ -31,19 +31,14 @@ namespace renderdoc [StructLayout(LayoutKind.Sequential)] public class D3D12PipelineState { + public ResourceId pipeline; + public bool customName; + [CustomMarshalAs(CustomUnmanagedType.UTF8TemplatedString)] + public string PipelineName; + [StructLayout(LayoutKind.Sequential)] public class InputAssembler { - private void PostMarshal() - { - if (_ptr_Bytecode != IntPtr.Zero) - Bytecode = (ShaderReflection)CustomMarshal.PtrToStructure(_ptr_Bytecode, typeof(ShaderReflection), false); - else - Bytecode = null; - - _ptr_Bytecode = IntPtr.Zero; - } - [StructLayout(LayoutKind.Sequential)] public class LayoutInput { @@ -59,20 +54,14 @@ namespace renderdoc }; [CustomMarshalAs(CustomUnmanagedType.TemplatedArray)] public LayoutInput[] layouts; - public ResourceId layout; - private IntPtr _ptr_Bytecode; - [CustomMarshalAs(CustomUnmanagedType.Skip)] - public ShaderReflection Bytecode; - public bool customName; - [CustomMarshalAs(CustomUnmanagedType.UTF8TemplatedString)] - public string LayoutName; [StructLayout(LayoutKind.Sequential)] public class VertexBuffer { public ResourceId Buffer; + public UInt64 Offset; + public UInt32 Size; public UInt32 Stride; - public UInt32 Offset; }; [CustomMarshalAs(CustomUnmanagedType.TemplatedArray)] public VertexBuffer[] vbuffers; @@ -81,10 +70,13 @@ namespace renderdoc public class IndexBuffer { public ResourceId Buffer; - public UInt32 Offset; + public UInt64 Offset; + public UInt32 Size; }; [CustomMarshalAs(CustomUnmanagedType.CustomClass)] public IndexBuffer ibuffer; + + public UInt32 indexStripCutValue; }; [CustomMarshalAs(CustomUnmanagedType.CustomClass)] public InputAssembler m_IA; @@ -103,9 +95,7 @@ namespace renderdoc } public ResourceId Shader; - [CustomMarshalAs(CustomUnmanagedType.UTF8TemplatedString)] - public string ShaderName; - public bool customName; + public bool Present; private IntPtr _ptr_ShaderDetails; [CustomMarshalAs(CustomUnmanagedType.Skip)] public ShaderReflection ShaderDetails; @@ -113,95 +103,106 @@ namespace renderdoc public ShaderBindpointMapping BindpointMapping; public ShaderStageType stage; - - [StructLayout(LayoutKind.Sequential)] - public class ResourceView - { - public ResourceId View; - public ResourceId Resource; - [CustomMarshalAs(CustomUnmanagedType.UTF8TemplatedString)] - public string Type; - [CustomMarshalAs(CustomUnmanagedType.CustomClass)] - public ResourceFormat Format; - - public bool Structured; - public UInt32 BufferStructCount; - public UInt32 ElementSize; - - // Buffer (SRV) - public UInt32 ElementOffset; - public UInt32 ElementWidth; - - // Buffer (UAV) - public UInt32 FirstElement; - public UInt32 NumElements; - - // BufferEx - public D3DBufferViewFlags Flags; - - // Texture - public UInt32 HighestMip; - public UInt32 NumMipLevels; - - // Texture Array - public UInt32 ArraySize; - public UInt32 FirstArraySlice; - }; - [CustomMarshalAs(CustomUnmanagedType.TemplatedArray)] - public ResourceView[] SRVs; - [CustomMarshalAs(CustomUnmanagedType.TemplatedArray)] - public ResourceView[] UAVs; - - [StructLayout(LayoutKind.Sequential)] - public class Sampler - { - public ResourceId Samp; - - [CustomMarshalAs(CustomUnmanagedType.UTF8TemplatedString)] - public string SamplerName; - public bool customSamplerName; - - [CustomMarshalAs(CustomUnmanagedType.UTF8TemplatedString)] - public string AddressU, AddressV, AddressW; - [CustomMarshalAs(CustomUnmanagedType.FixedArray, FixedLength = 4)] - public float[] BorderColor; - [CustomMarshalAs(CustomUnmanagedType.UTF8TemplatedString)] - public string Comparison; - [CustomMarshalAs(CustomUnmanagedType.UTF8TemplatedString)] - public string Filter; - public bool UseBorder; - public bool UseComparison; - public UInt32 MaxAniso; - public float MaxLOD; - public float MinLOD; - public float MipLODBias; - }; - [CustomMarshalAs(CustomUnmanagedType.TemplatedArray)] - public Sampler[] Samplers; - - [StructLayout(LayoutKind.Sequential)] - public class CBuffer - { - public ResourceId Buffer; - public UInt32 VecOffset; - public UInt32 VecCount; - }; - [CustomMarshalAs(CustomUnmanagedType.TemplatedArray)] - public CBuffer[] ConstantBuffers; - - [StructLayout(LayoutKind.Sequential)] - public class ClassInstance - { - [CustomMarshalAs(CustomUnmanagedType.UTF8TemplatedString)] - string name; - }; - - [CustomMarshalAs(CustomUnmanagedType.TemplatedArray)] - public ClassInstance[] ClassInstances; }; [CustomMarshalAs(CustomUnmanagedType.CustomClass)] public ShaderStage m_VS, m_HS, m_DS, m_GS, m_PS, m_CS; + [StructLayout(LayoutKind.Sequential)] + public class ResourceView + { + public ResourceId Resource; + [CustomMarshalAs(CustomUnmanagedType.UTF8TemplatedString)] + public string Type; + [CustomMarshalAs(CustomUnmanagedType.CustomClass)] + public ResourceFormat Format; + + [CustomMarshalAs(CustomUnmanagedType.FixedArray, FixedLength = 4)] + public TextureSwizzle[] swizzle; + + public D3DBufferViewFlags BufferFlags; + public UInt32 BufferStructCount; + public UInt32 ElementSize; + public UInt32 FirstElement; + public UInt32 NumElements; + + public ResourceId CounterResource; + public UInt64 CounterByteOffset; + + // Texture + public UInt32 HighestMip; + public UInt32 NumMipLevels; + + // Texture Array + public UInt32 ArraySize; + public UInt32 FirstArraySlice; + + public float MinLODClamp; + }; + + [StructLayout(LayoutKind.Sequential)] + public class Sampler + { + [CustomMarshalAs(CustomUnmanagedType.UTF8TemplatedString)] + public string AddressU, AddressV, AddressW; + [CustomMarshalAs(CustomUnmanagedType.FixedArray, FixedLength = 4)] + public float[] BorderColor; + [CustomMarshalAs(CustomUnmanagedType.UTF8TemplatedString)] + public string Comparison; + [CustomMarshalAs(CustomUnmanagedType.UTF8TemplatedString)] + public string Filter; + public bool UseBorder; + public bool UseComparison; + public UInt32 MaxAniso; + public float MaxLOD; + public float MinLOD; + public float MipLODBias; + }; + + [StructLayout(LayoutKind.Sequential)] + public class CBuffer + { + public ResourceId Buffer; + public UInt64 Offset; + public UInt32 ByteSize; + }; + + [StructLayout(LayoutKind.Sequential)] + public class RootSignature + { + public ResourceId Obj; + + [StructLayout(LayoutKind.Sequential)] + public class RootElem + { + public ShaderStageBits VisibilityMask; + + public bool RootElement; + + [StructLayout(LayoutKind.Sequential)] + public class Descriptor + { + public UInt32 RegSpace; + public UInt32 RegIndex; + + public ShaderBindType Type; + + [CustomMarshalAs(CustomUnmanagedType.TemplatedArray)] + public UInt32[] Constants; + + [CustomMarshalAs(CustomUnmanagedType.CustomClass)] + CBuffer ConstantBuffer; + [CustomMarshalAs(CustomUnmanagedType.CustomClass)] + ResourceView View; + }; + [CustomMarshalAs(CustomUnmanagedType.TemplatedArray)] + public Descriptor[] Descriptors; + }; + [CustomMarshalAs(CustomUnmanagedType.TemplatedArray)] + public RootElem[] Elements; + }; + [CustomMarshalAs(CustomUnmanagedType.CustomClass)] + public RootSignature m_RootSig; + [StructLayout(LayoutKind.Sequential)] public class Streamout { @@ -209,7 +210,11 @@ namespace renderdoc public class Output { public ResourceId Buffer; - public UInt32 Offset; + public UInt64 Offset; + public UInt64 Size; + + public ResourceId WrittenCountBuffer; + public UInt64 WrittenCountOffset; }; [CustomMarshalAs(CustomUnmanagedType.TemplatedArray)] public Output[] Outputs; @@ -220,6 +225,8 @@ namespace renderdoc [StructLayout(LayoutKind.Sequential)] public class Rasterizer { + public UInt32 SampleMask; + [StructLayout(LayoutKind.Sequential)] public class Viewport { @@ -227,7 +234,6 @@ namespace renderdoc public float[] TopLeft; public float Width, Height; public float MinDepth, MaxDepth; - public bool Enabled; }; [CustomMarshalAs(CustomUnmanagedType.TemplatedArray)] public Viewport[] Viewports; @@ -236,7 +242,6 @@ namespace renderdoc public class Scissor { public Int32 left, top, right, bottom; - public bool Enabled; }; [CustomMarshalAs(CustomUnmanagedType.TemplatedArray)] public Scissor[] Scissors; @@ -244,7 +249,6 @@ namespace renderdoc [StructLayout(LayoutKind.Sequential)] public class RasterizerState { - public ResourceId State; public TriangleFillMode FillMode; public TriangleCullMode CullMode; public bool FrontCCW; @@ -252,7 +256,6 @@ namespace renderdoc public float DepthBiasClamp; public float SlopeScaledDepthBias; public bool DepthClip; - public bool ScissorEnable; public bool MultisampleEnable; public bool AntialiasedLineEnable; public UInt32 ForcedSampleCount; @@ -270,11 +273,10 @@ namespace renderdoc [StructLayout(LayoutKind.Sequential)] public class DepthStencilState { - public ResourceId State; public bool DepthEnable; + public bool DepthWrites; [CustomMarshalAs(CustomUnmanagedType.UTF8TemplatedString)] public string DepthFunc; - public bool DepthWrites; public bool StencilEnable; public byte StencilReadMask; public byte StencilWriteMask; @@ -302,8 +304,6 @@ namespace renderdoc [StructLayout(LayoutKind.Sequential)] public class BlendState { - public ResourceId State; - public bool AlphaToCoverage; public bool IndependentBlend; @@ -335,22 +335,20 @@ namespace renderdoc [CustomMarshalAs(CustomUnmanagedType.FixedArray, FixedLength = 4)] public float[] BlendFactor; - public UInt32 SampleMask; }; [CustomMarshalAs(CustomUnmanagedType.CustomClass)] public BlendState m_BlendState; [CustomMarshalAs(CustomUnmanagedType.TemplatedArray)] - public ShaderStage.ResourceView[] RenderTargets; - - public UInt32 UAVStartSlot; - [CustomMarshalAs(CustomUnmanagedType.TemplatedArray)] - public ShaderStage.ResourceView[] UAVs; + public ResourceView[] RenderTargets; [CustomMarshalAs(CustomUnmanagedType.CustomClass)] - public ShaderStage.ResourceView DepthTarget; + public ResourceView DepthTarget; public bool DepthReadOnly; public bool StencilReadOnly; + + public UInt32 multiSampleCount; + public UInt32 multiSampleQuality; }; [CustomMarshalAs(CustomUnmanagedType.CustomClass)] public OutputMerger m_OM; diff --git a/renderdocui/Interop/Enums.cs b/renderdocui/Interop/Enums.cs index 9ef52ee9c..55aa63aea 100644 --- a/renderdocui/Interop/Enums.cs +++ b/renderdocui/Interop/Enums.cs @@ -93,6 +93,7 @@ namespace renderdoc public enum ShaderBindType { Unknown = 0, + ConstantBuffer, Sampler, ImageSampler, ReadOnlyImage, @@ -856,6 +857,7 @@ namespace renderdoc { switch (bindType) { + case ShaderBindType.ConstantBuffer: return "Constants"; case ShaderBindType.Sampler: return "Sampler"; case ShaderBindType.ImageSampler: return "Image&Sampler"; case ShaderBindType.ReadOnlyImage: return "Image"; diff --git a/renderdocui/Windows/PipelineState/D3D12PipelineStateViewer.cs b/renderdocui/Windows/PipelineState/D3D12PipelineStateViewer.cs index ccf704df5..db6408b8f 100644 --- a/renderdocui/Windows/PipelineState/D3D12PipelineStateViewer.cs +++ b/renderdocui/Windows/PipelineState/D3D12PipelineStateViewer.cs @@ -66,25 +66,25 @@ namespace renderdocui.Windows.PipelineState private class ViewTexTag { - public ViewTexTag(D3D12PipelineState.ShaderStage.ResourceView v, FetchTexture t) + public ViewTexTag(D3D12PipelineState.ResourceView v, FetchTexture t) { view = v; tex = t; } - public D3D12PipelineState.ShaderStage.ResourceView view; + public D3D12PipelineState.ResourceView view; public FetchTexture tex; }; private class ViewBufTag { - public ViewBufTag(D3D12PipelineState.ShaderStage.ResourceView v, FetchBuffer b) + public ViewBufTag(D3D12PipelineState.ResourceView v, FetchBuffer b) { view = v; buf = b; } - public D3D12PipelineState.ShaderStage.ResourceView view; + public D3D12PipelineState.ResourceView view; public FetchBuffer buf; }; @@ -253,7 +253,7 @@ namespace renderdocui.Windows.PipelineState m_ViewDetailNodes.Add(node); } - private bool HasImportantViewParams(D3D12PipelineState.ShaderStage.ResourceView view, FetchTexture tex) + private bool HasImportantViewParams(D3D12PipelineState.ResourceView view, FetchTexture tex) { // we don't count 'upgrade typeless to typed' as important, we just display the typed format // in the row since there's no real hidden important information there. The formats can't be @@ -273,7 +273,7 @@ namespace renderdocui.Windows.PipelineState return false; } - private bool HasImportantViewParams(D3D12PipelineState.ShaderStage.ResourceView view, FetchBuffer buf) + private bool HasImportantViewParams(D3D12PipelineState.ResourceView view, FetchBuffer buf) { if (view.FirstElement > 0 || view.NumElements*view.ElementSize < buf.length) return true; @@ -297,12 +297,15 @@ namespace renderdocui.Windows.PipelineState Label shader, TreelistView.TreeListView resources, TreelistView.TreeListView samplers, TreelistView.TreeListView cbuffers, TreelistView.TreeListView classes) { + D3D12PipelineState state = m_Core.CurD3D12PipelineState; ShaderReflection shaderDetails = stage.ShaderDetails; - if (stage.Shader == ResourceId.Null) + if (!stage.Present) shader.Text = "Unbound"; + else if (state.customName) + shader.Text = state.PipelineName + " - " + m_Core.CurPipelineState.Abbrev(stage.stage); else - shader.Text = stage.ShaderName; + shader.Text = stage.stage.Str(GraphicsAPI.D3D12); if (shaderDetails != null && shaderDetails.DebugInfo.entryFunc.Length > 0 && shaderDetails.DebugInfo.files.Length > 0) { @@ -322,157 +325,7 @@ namespace renderdocui.Windows.PipelineState vs = resources.VScrollValue(); resources.BeginUpdate(); resources.Nodes.Clear(); - if (stage.SRVs != null) - { - int i = 0; - foreach (var r in stage.SRVs) - { - ShaderResource shaderInput = null; - if (shaderDetails != null) - { - foreach (var bind in shaderDetails.ReadOnlyResources) - { - if (bind.IsSRV && bind.bindPoint == i) - { - shaderInput = bind; - break; - } - } - } - - bool filledSlot = (r.Resource != ResourceId.Null); - bool usedSlot = (shaderInput != null); - - // show if - if (usedSlot || // it's referenced by the shader - regardless of empty or not - (showDisabled.Checked && !usedSlot && filledSlot) || // it's bound, but not referenced, and we have "show disabled" - (showEmpty.Checked && !filledSlot) // it's empty, and we have "show empty" - ) - { - string slotname = i.ToString(); - - if (shaderInput != null && shaderInput.name.Length > 0) - slotname += ": " + shaderInput.name; - - UInt64 w = 1; - UInt32 h = 1, d = 1; - UInt32 a = 1; - string format = "Unknown"; - string name = "Shader Resource " + r.Resource.ToString(); - string typename = "Unknown"; - object tag = null; - bool viewDetails = false; - - if (!filledSlot) - { - name = "Empty"; - format = "-"; - typename = "-"; - w = h = d = a = 0; - } - - // check to see if it's a texture - for (int t = 0; t < texs.Length; t++) - { - if (texs[t].ID == r.Resource) - { - w = texs[t].width; - h = texs[t].height; - d = texs[t].depth; - a = texs[t].arraysize; - format = texs[t].format.ToString(); - name = texs[t].name; - typename = texs[t].resType.Str(); - - if (texs[t].resType == ShaderResourceType.Texture2DMS || - texs[t].resType == ShaderResourceType.Texture2DMSArray) - { - typename += String.Format(" {0}x", texs[t].msSamp); - } - - // if it's a typeless format, show the format of the view - if (texs[t].format != r.Format) - { - format = "Viewed as " + r.Format.ToString(); - } - - tag = new ViewTexTag(r, texs[t]); - - if (HasImportantViewParams(r, texs[t])) - viewDetails = true; - } - } - - // if not a texture, it must be a buffer - for (int t = 0; t < bufs.Length; t++) - { - if (bufs[t].ID == r.Resource) - { - w = bufs[t].length; - h = 0; - d = 0; - a = 0; - format = ""; - name = bufs[t].name; - typename = "Buffer"; - - if (r.Flags.HasFlag(D3DBufferViewFlags.Raw)) - { - typename = "ByteAddressBuffer"; - } - else if (r.ElementSize > 0) - { - // for structured buffers, display how many 'elements' there are in the buffer - typename = "StructuredBuffer[" + (bufs[t].length / r.ElementSize) + "]"; - } - - if (r.Flags.HasFlag(D3DBufferViewFlags.Append) || r.Flags.HasFlag(D3DBufferViewFlags.Counter)) - { - typename += " (Count: " + r.BufferStructCount + ")"; - } - - // get the buffer type, whether it's just a basic type or a complex struct - if (shaderInput != null && !shaderInput.IsTexture) - { - if (r.Format.compType == FormatComponentType.None) - { - if (shaderInput.variableType.members.Length > 0) - format = "struct " + shaderInput.variableType.Name; - else - format = shaderInput.variableType.Name; - } - else - { - format = r.Format.ToString(); - } - } - - tag = new ViewBufTag(r, bufs[t]); - - if (HasImportantViewParams(r, bufs[t])) - viewDetails = true; - } - } - - var node = resources.Nodes.Add(new object[] { slotname, name, typename, w, h, d, a, format }); - - node.Image = global::renderdocui.Properties.Resources.action; - node.HoverImage = global::renderdocui.Properties.Resources.action_hover; - node.Tag = tag; - - if (!filledSlot) - EmptyRow(node); - - if (!usedSlot) - InactiveRow(node); - - if (viewDetails) - ViewDetailsRow(node); - } - i++; - } - } resources.EndUpdate(); resources.NodesSelection.Clear(); resources.SetVScrollValue(vs); @@ -480,101 +333,7 @@ namespace renderdocui.Windows.PipelineState vs = samplers.VScrollValue(); samplers.BeginUpdate(); samplers.Nodes.Clear(); - if (stage.Samplers != null) - { - int i = 0; - foreach (var s in stage.Samplers) - { - ShaderResource shaderInput = null; - if (shaderDetails != null) - { - foreach (var bind in shaderDetails.ReadOnlyResources) - { - if (bind.IsSampler && bind.bindPoint == i) - { - shaderInput = bind; - break; - } - } - } - - bool filledSlot = (s.AddressU.Length > 0); - bool usedSlot = (shaderInput != null); - - // show if - if (usedSlot || // it's referenced by the shader - regardless of empty or not - (showDisabled.Checked && !usedSlot && filledSlot) || // it's bound, but not referenced, and we have "show disabled" - (showEmpty.Checked && !filledSlot) // it's empty, and we have "show empty" - ) - { - string slotname = i.ToString(); - - if (shaderInput != null && shaderInput.name.Length > 0) - slotname += ": " + shaderInput.name; - - if (s.customSamplerName) - slotname += "(" + s.SamplerName + ")"; - - string borderColor = s.BorderColor[0].ToString() + ", " + - s.BorderColor[1].ToString() + ", " + - s.BorderColor[2].ToString() + ", " + - s.BorderColor[3].ToString(); - - string addressing = ""; - - string addPrefix = ""; - string addVal = ""; - - string[] addr = { s.AddressU, s.AddressV, s.AddressW }; - - // arrange like either UVW: WRAP or UV: WRAP, W: CLAMP - for (int a = 0; a < 3; a++) - { - string prefix = "" + "UVW"[a]; - - if (a == 0 || addr[a] == addr[a - 1]) - { - addPrefix += prefix; - } - else - { - addressing += addPrefix + ": " + addVal + ", "; - - addPrefix = prefix; - } - addVal = addr[a]; - } - - addressing += addPrefix + ": " + addVal; - - if(s.UseBorder) - addressing += String.Format("<{0}>", borderColor); - - string filter = s.Filter; - - if (s.MaxAniso > 0) - filter += String.Format(" {0}x", s.MaxAniso); - - if (s.UseComparison) - filter += String.Format(" ({0})", s.Comparison); - - var node = samplers.Nodes.Add(new object[] { slotname, addressing, - filter, - (s.MinLOD == -float.MaxValue ? "0" : s.MinLOD.ToString()) + " - " + - (s.MaxLOD == float.MaxValue ? "FLT_MAX" : s.MaxLOD.ToString()), - s.MipLODBias.ToString() }); - - if (!filledSlot) - EmptyRow(node); - - if (!usedSlot) - InactiveRow(node); - } - - i++; - } - } samplers.EndUpdate(); samplers.NodesSelection.Clear(); samplers.SetVScrollValue(vs); @@ -582,102 +341,10 @@ namespace renderdocui.Windows.PipelineState vs = cbuffers.VScrollValue(); cbuffers.BeginUpdate(); cbuffers.Nodes.Clear(); - if (stage.ConstantBuffers != null) - { - UInt32 i = 0; - foreach (var b in stage.ConstantBuffers) - { - ConstantBlock shaderCBuf = null; - if (shaderDetails != null && i < shaderDetails.ConstantBlocks.Length && shaderDetails.ConstantBlocks[i].name.Length > 0) - shaderCBuf = shaderDetails.ConstantBlocks[i]; - - bool filledSlot = (b.Buffer != ResourceId.Null); - bool usedSlot = (shaderCBuf != null); - - // show if - if (usedSlot || // it's referenced by the shader - regardless of empty or not - (showDisabled.Checked && !usedSlot && filledSlot) || // it's bound, but not referenced, and we have "show disabled" - (showEmpty.Checked && !filledSlot) // it's empty, and we have "show empty" - ) - { - string name = "Constant Buffer " + b.Buffer.ToString(); - UInt64 length = 1; - int numvars = shaderCBuf != null ? shaderCBuf.variables.Length : 0; - UInt32 byteSize = shaderCBuf != null ? shaderCBuf.byteSize : 0; - - if (!filledSlot) - { - name = "Empty"; - length = 0; - } - - for (int t = 0; t < bufs.Length; t++) - { - if (bufs[t].ID == b.Buffer) - { - name = bufs[t].name; - length = bufs[t].length; - } - } - - string slotname = i.ToString(); - - if (shaderCBuf != null && shaderCBuf.name.Length > 0) - slotname += ": " + shaderCBuf.name; - - string sizestr; - if (byteSize == length) - sizestr = String.Format("{0} Variables, {1} bytes", numvars, length); - else - sizestr = String.Format("{0} Variables, {1} bytes needed, {2} provided", numvars, byteSize, length); - - if (length < byteSize) - filledSlot = false; - - string vecrange = String.Format("{0} - {1}", b.VecOffset, b.VecOffset + b.VecCount); - - var node = cbuffers.Nodes.Add(new object[] { slotname, name, vecrange, sizestr }); - - node.Image = global::renderdocui.Properties.Resources.action; - node.HoverImage = global::renderdocui.Properties.Resources.action_hover; - node.Tag = i; - - if (!filledSlot) - EmptyRow(node); - - if (!usedSlot) - InactiveRow(node); - } - i++; - } - } cbuffers.EndUpdate(); cbuffers.NodesSelection.Clear(); cbuffers.SetVScrollValue(vs); - - vs = classes.VScrollValue(); - classes.BeginUpdate(); - classes.Nodes.Clear(); - { - UInt32 i = 0; - foreach (var inst in stage.ClassInstances) - { - string interfaceName = String.Format("Interface {0}", i); - - if (shaderDetails != null && i < shaderDetails.Interfaces.Length) - interfaceName = shaderDetails.Interfaces[i].Name; - - classes.Nodes.Add(new object[] { i.ToString(), interfaceName, inst }); - - i++; - } - } - classes.EndUpdate(); - classes.NodesSelection.Clear(); - classes.SetVScrollValue(vs); - - classes.Visible = classes.Parent.Visible = (stage.ClassInstances.Length > 0); } // from https://gist.github.com/mjijackson/5311256 @@ -746,80 +413,6 @@ namespace renderdocui.Windows.PipelineState //////////////////////////////////////////////// // Input Assembler - if(state.m_IA.Bytecode == null) - iaBytecode.Text = "None"; - else - iaBytecode.Text = state.m_IA.LayoutName; - - if (state.m_IA.Bytecode != null && state.m_IA.Bytecode.DebugInfo != null && state.m_IA.Bytecode.DebugInfo.entryFunc.Length > 0) - iaBytecode.Text += " (" + state.m_IA.Bytecode.DebugInfo.entryFunc + ")"; - - iaBytecodeMismatch.Text = ""; - iaBytecodeMismatch.Visible = false; - - // check for IA-VS mismatches here. - // This should be moved to a "Render Doctor" window reporting problems - if (state.m_IA.Bytecode != null && state.m_VS.ShaderDetails != null) - { - string mismatchDetails = ""; - - // VS wants more elements - if (state.m_IA.Bytecode.InputSig.Length < state.m_VS.ShaderDetails.InputSig.Length) - { - int excess = state.m_VS.ShaderDetails.InputSig.Length - state.m_IA.Bytecode.InputSig.Length; - - bool allSystem = true; - - // The VS signature can consume more elements as long as they are all system value types - // (ie. SV_VertexID or SV_InstanceID) - for (int e = 0; e < excess; e++) - { - if(state.m_VS.ShaderDetails.InputSig[state.m_VS.ShaderDetails.InputSig.Length - 1 - e].systemValue == SystemAttribute.None) - { - allSystem = false; - break; - } - } - - if (!allSystem) - mismatchDetails += "IA bytecode provides fewer elements than VS wants.\n"; - } - - { - var IA = state.m_IA.Bytecode.InputSig; - var VS = state.m_VS.ShaderDetails.InputSig; - - int count = Math.Min(IA.Length, VS.Length); - - for (int i = 0; i < count; i++) - { - // misorder or misnamed semantics - if (IA[i].semanticIdxName.ToUpperInvariant() != VS[i].semanticIdxName.ToUpperInvariant()) - mismatchDetails += String.Format("IA bytecode semantic {0}: {1} != VS bytecode semantic {0}: {2}\n", i, - IA[i].semanticIdxName, VS[i].semanticIdxName); - - // VS wants more components - if (IA[i].compCount < VS[i].compCount) - mismatchDetails += String.Format("IA bytecode semantic {0} ({1}) is {3}-wide, VS bytecode semantic {0} ({1}) {2} is {4}-wide\n", i, - IA[i].semanticIdxName, VS[i].semanticIdxName, - IA[i].compCount, VS[i].compCount); - - // VS wants different types - if (IA[i].compType != VS[i].compType) - mismatchDetails += String.Format("IA bytecode semantic {0} ({1}) is {3}, VS bytecode semantic {0} ({2}) is {4}\n", i, - IA[i].semanticIdxName, VS[i].semanticIdxName, - IA[i].compType, VS[i].compType); - } - } - - if (mismatchDetails.Length != 0) - { - iaBytecodeMismatch.Text = "Warning: Mismatch detected between bytecode used to create IA and currently bound VS inputs"; - toolTip.SetToolTip(iaBytecodeMismatch, mismatchDetails.Trim()); - iaBytecodeMismatch.Visible = true; - } - } - int vs = 0; vs = inputLayouts.VScrollValue(); @@ -846,12 +439,12 @@ namespace renderdocui.Windows.PipelineState bool iaUsed = false; - if (state.m_IA.Bytecode != null) + if (state.m_VS.Present) { - for (int ia = 0; ia < state.m_IA.Bytecode.InputSig.Length; ia++) + for (int ia = 0; ia < state.m_VS.ShaderDetails.InputSig.Length; ia++) { - if (state.m_IA.Bytecode.InputSig[ia].semanticName.ToUpperInvariant() == l.SemanticName.ToUpperInvariant() && - state.m_IA.Bytecode.InputSig[ia].semanticIndex == l.SemanticIndex) + if (state.m_VS.ShaderDetails.InputSig[ia].semanticName.ToUpperInvariant() == l.SemanticName.ToUpperInvariant() && + state.m_VS.ShaderDetails.InputSig[ia].semanticIndex == l.SemanticIndex) { iaUsed = true; break; @@ -1050,156 +643,7 @@ namespace renderdocui.Windows.PipelineState csUAVs.Nodes.Clear(); csUAVs.BeginUpdate(); - if (state.m_CS.UAVs != null) - { - int i = 0; - foreach (var r in state.m_CS.UAVs) - { - ShaderResource shaderInput = null; - if (state.m_CS.ShaderDetails != null) - { - foreach (var bind in state.m_CS.ShaderDetails.ReadWriteResources) - { - if (bind.bindPoint == i) - { - shaderInput = bind; - break; - } - } - } - - bool filledSlot = (r.Resource != ResourceId.Null); - bool usedSlot = (shaderInput != null); - - // show if - if (usedSlot || // it's referenced by the shader - regardless of empty or not - (showDisabled.Checked && !usedSlot && filledSlot) || // it's bound, but not referenced, and we have "show disabled" - (showEmpty.Checked && !filledSlot) // it's empty, and we have "show empty" - ) - { - string slotname = i.ToString(); - - if (shaderInput != null && shaderInput.name.Length > 0) - slotname += ": " + shaderInput.name; - - UInt64 w = 1; - UInt32 h = 1, d = 1; - UInt32 a = 1; - string format = "Unknown"; - string name = "UAV " + r.Resource.ToString(); - string typename = "Unknown"; - object tag = null; - bool viewDetails = false; - - if (!filledSlot) - { - name = "Empty"; - format = "-"; - typename = "-"; - w = h = d = a = 0; - } - - for (int t = 0; t < texs.Length; t++) - { - if (texs[t].ID == r.Resource) - { - w = texs[t].width; - h = texs[t].height; - d = texs[t].depth; - a = texs[t].arraysize; - format = texs[t].format.ToString(); - name = texs[t].name; - typename = texs[t].resType.Str(); - - if (texs[t].resType == ShaderResourceType.Texture2DMS || - texs[t].resType == ShaderResourceType.Texture2DMSArray) - { - typename += String.Format(" {0}x", texs[t].msSamp); - } - - // if it's a typeless format, show the format of the view - if (texs[t].format != r.Format) - { - format = "Viewed as " + r.Format.ToString(); - } - - if (HasImportantViewParams(r, texs[t])) - viewDetails = true; - - tag = new ViewTexTag(r, texs[t]); - } - } - - for (int t = 0; t < bufs.Length; t++) - { - if (bufs[t].ID == r.Resource) - { - w = bufs[t].length; - h = 0; - d = 0; - a = 0; - format = ""; - name = bufs[t].name; - typename = "Buffer"; - - if (r.Flags.HasFlag(D3DBufferViewFlags.Raw)) - { - typename = "RWByteAddressBuffer"; - } - else if (r.ElementSize > 0) - { - // for structured buffers, display how many 'elements' there are in the buffer - typename = "RWStructuredBuffer[" + (bufs[t].length / r.ElementSize) + "]"; - } - - if (r.Flags.HasFlag(D3DBufferViewFlags.Append) || r.Flags.HasFlag(D3DBufferViewFlags.Counter)) - { - typename += " (Count: " + r.BufferStructCount + ")"; - } - - if (shaderInput != null && !shaderInput.IsTexture) - { - if (r.Format.compType == FormatComponentType.None) - { - if (shaderInput.variableType.members.Length > 0) - format = "struct " + shaderInput.variableType.Name; - else - format = shaderInput.variableType.Name; - } - else - { - format = r.Format.ToString(); - } - } - - if (HasImportantViewParams(r, bufs[t])) - viewDetails = true; - - tag = new ViewBufTag(r, bufs[t]); - } - } - - var node = csUAVs.Nodes.Add(new object[] { slotname, name, typename, w, h, d, a, format }); - - node.Tag = tag; - - node.Image = global::renderdocui.Properties.Resources.action; - node.HoverImage = global::renderdocui.Properties.Resources.action_hover; - - if (!filledSlot) - EmptyRow(node); - - if (!usedSlot) - InactiveRow(node); - - if (viewDetails) - ViewDetailsRow(node); - } - - i++; - } - } csUAVs.NodesSelection.Clear(); csUAVs.EndUpdate(); csUAVs.SetVScrollValue(vs); @@ -1281,16 +725,10 @@ namespace renderdocui.Windows.PipelineState int i = 0; foreach (var v in state.m_RS.Viewports) { - if (v.Enabled || showEmpty.Checked) - { - var node = viewports.Nodes.Add(new object[] { i, v.TopLeft[0], v.TopLeft[1], v.Width, v.Height, v.MinDepth, v.MaxDepth }); + var node = viewports.Nodes.Add(new object[] { i, v.TopLeft[0], v.TopLeft[1], v.Width, v.Height, v.MinDepth, v.MaxDepth }); - if (v.Width == 0 || v.Height == 0 || v.MinDepth == v.MaxDepth) - EmptyRow(node); - - if (!v.Enabled) - InactiveRow(node); - } + if (v.Width == 0 || v.Height == 0 || v.MinDepth == v.MaxDepth) + EmptyRow(node); i++; } @@ -1307,16 +745,10 @@ namespace renderdocui.Windows.PipelineState int i = 0; foreach (var s in state.m_RS.Scissors) { - if (s.Enabled || showEmpty.Checked) - { - var node = scissors.Nodes.Add(new object[] { i, s.left, s.top, s.right - s.left, s.bottom - s.top }); + var node = scissors.Nodes.Add(new object[] { i, s.left, s.top, s.right - s.left, s.bottom - s.top }); - if (s.right == s.left || s.bottom == s.top) - EmptyRow(node); - - if (!s.Enabled) - InactiveRow(node); - } + if (s.right == s.left || s.bottom == s.top) + EmptyRow(node); i++; } @@ -1329,7 +761,6 @@ namespace renderdocui.Windows.PipelineState cullMode.Text = state.m_RS.m_State.CullMode.ToString(); frontCCW.Image = state.m_RS.m_State.FrontCCW ? tick : cross; - scissorEnable.Image = state.m_RS.m_State.ScissorEnable ? tick : cross; lineAAEnable.Image = state.m_RS.m_State.AntialiasedLineEnable ? tick : cross; multisampleEnable.Image = state.m_RS.m_State.MultisampleEnable ? tick : cross; @@ -1428,149 +859,6 @@ namespace renderdocui.Windows.PipelineState } } - if (state.m_OM.UAVs != null) - { - int i = 0; - foreach (var r in state.m_OM.UAVs) - { - ShaderResource shaderInput = null; - - if (state.m_PS.ShaderDetails != null) - { - foreach (var bind in state.m_PS.ShaderDetails.ReadWriteResources) - { - if (bind.bindPoint == i + state.m_OM.UAVStartSlot) - { - shaderInput = bind; - break; - } - } - } - - bool filledSlot = (r.Resource != ResourceId.Null); - bool usedSlot = (shaderInput != null); - - // note: we don't show empty UAVs as these "slots" are already showed as empty RTs. - - // show if - if (usedSlot || // it's referenced by the shader - regardless of empty or not - (showDisabled.Checked && !usedSlot && filledSlot) // it's bound, but not referenced, and we have "show disabled" - ) - { - UInt64 w = 1; - UInt32 h = 1, d = 1; - UInt32 a = 1; - string format = "Unknown"; - string name = "UAV " + r.Resource.ToString(); - string typename = "Unknown"; - object tag = null; - bool viewDetails = false; - - if (!filledSlot) - { - name = "Empty"; - format = "-"; - typename = "-"; - w = h = d = a = 0; - } - - for (int t = 0; t < texs.Length; t++) - { - if (texs[t].ID == r.Resource) - { - w = texs[t].width; - h = texs[t].height; - d = texs[t].depth; - a = texs[t].arraysize; - format = texs[t].format.ToString(); - name = texs[t].name; - typename = texs[t].resType.Str(); - - if (texs[t].resType == ShaderResourceType.Texture2DMS || - texs[t].resType == ShaderResourceType.Texture2DMSArray) - { - typename += String.Format(" {0}x", texs[t].msSamp); - } - - // if it's a typeless format, show the format of the view - if (texs[t].format != r.Format) - { - format = "Viewed as " + r.Format.ToString(); - } - - if (HasImportantViewParams(r, texs[t])) - viewDetails = true; - - tag = new ViewTexTag(r, texs[t]); - } - } - - for (int t = 0; t < bufs.Length; t++) - { - if (bufs[t].ID == r.Resource) - { - w = bufs[t].length; - h = 0; - d = 0; - a = 0; - format = ""; - name = bufs[t].name; - typename = "Buffer"; - - if (r.Flags.HasFlag(D3DBufferViewFlags.Raw)) - { - typename = "RWByteAddressBuffer"; - } - else if (r.ElementSize > 0) - { - // for structured buffers, display how many 'elements' there are in the buffer - typename = "RWStructuredBuffer[" + (bufs[t].length / r.ElementSize) + "]"; - } - - if (r.Flags.HasFlag(D3DBufferViewFlags.Append) || r.Flags.HasFlag(D3DBufferViewFlags.Counter)) - { - typename += " (Count: " + r.BufferStructCount + ")"; - } - - if (shaderInput != null && !shaderInput.IsTexture) - { - if (r.Format.compType == FormatComponentType.None) - { - if (shaderInput.variableType.members.Length > 0) - format = "struct " + shaderInput.variableType.Name; - else - format = shaderInput.variableType.Name; - } - else - { - format = r.Format.ToString(); - } - } - - if (HasImportantViewParams(r, bufs[t])) - viewDetails = true; - - tag = new ViewBufTag(r, bufs[t]); - } - } - - var node = targetOutputs.Nodes.Add(new object[] { i + state.m_OM.UAVStartSlot, name, typename, w, h, d, a, format }); - - node.Image = global::renderdocui.Properties.Resources.action; - node.HoverImage = global::renderdocui.Properties.Resources.action_hover; - node.Tag = tag; - - if (r.Resource == ResourceId.Null) - EmptyRow(node); - - if (viewDetails) - ViewDetailsRow(node); - } - - i++; - } - } - if (state.m_OM.DepthTarget.Resource != ResourceId.Null || showEmpty.Checked) { UInt32 w = 1, h = 1, d = 1; @@ -1696,7 +984,7 @@ namespace renderdocui.Windows.PipelineState state.m_OM.m_BlendState.BlendFactor[2].ToString("F2") + ", " + state.m_OM.m_BlendState.BlendFactor[3].ToString("F2"); - sampleMask.Text = state.m_OM.m_BlendState.SampleMask.ToString("X8"); + sampleMask.Text = state.m_RS.SampleMask.ToString("X8"); depthEnable.Image = state.m_OM.m_State.DepthEnable ? tick : cross; depthFunc.Text = state.m_OM.m_State.DepthFunc; @@ -1873,7 +1161,7 @@ namespace renderdocui.Windows.PipelineState if (stage == null) return; - D3D12PipelineState.ShaderStage.ResourceView view = null; + D3D12PipelineState.ResourceView view = null; if (tag is ViewTexTag) { @@ -1915,6 +1203,7 @@ namespace renderdocui.Windows.PipelineState int bind = -1; bool uav = false; + /* if (view == null) { for (int i = 0; i < stage.SRVs.Length; i++) @@ -1974,6 +1263,7 @@ namespace renderdocui.Windows.PipelineState } } } + */ ulong offs = 0; ulong size = buf.length; @@ -2052,7 +1342,7 @@ namespace renderdocui.Windows.PipelineState } } - if (view.Flags.HasFlag(D3DBufferViewFlags.Raw)) + if (view.BufferFlags.HasFlag(D3DBufferViewFlags.Raw)) format = "xint"; format += view.Format.compCount; @@ -2236,18 +1526,6 @@ namespace renderdocui.Windows.PipelineState private void shader_Click(object sender, EventArgs e) { - if (sender == iaBytecode || sender == iaBytecodeCog) - { - if(m_Core.CurD3D12PipelineState != null && - m_Core.CurD3D12PipelineState.m_IA.Bytecode != null) - { - (new ShaderViewer(m_Core, m_Core.CurD3D12PipelineState.m_IA.Bytecode, ShaderStageType.Vertex, null, "")) - .Show(m_DockContent.DockPanel); - } - - return; - } - D3D12PipelineState.ShaderStage stage = GetStageForSender(sender); if (stage == null) return; @@ -2582,45 +1860,13 @@ namespace renderdocui.Windows.PipelineState sv.Show(m_DockContent.DockPanel); } - private void ShowCBuffer(D3D12PipelineState.ShaderStage stage, UInt32 slot) - { - if (stage.ShaderDetails != null && - (stage.ShaderDetails.ConstantBlocks.Length <= slot || - stage.ShaderDetails.ConstantBlocks[slot].name.Length == 0) - ) - { - // unused cbuffer, open regular buffer viewer - var viewer = new BufferViewer(m_Core, false); - - if (stage.ConstantBuffers.Length < slot) - return; - - var buf = stage.ConstantBuffers[slot]; - viewer.ViewRawBuffer(true, buf.VecOffset * 4 * sizeof(float), buf.VecCount * 4 * sizeof(float), buf.Buffer); - viewer.Show(m_DockContent.DockPanel); - - return; - } - - var existing = ConstantBufferPreviewer.Has(stage.stage, slot, 0); - if (existing != null) - { - existing.Show(); - return; - } - - var prev = new ConstantBufferPreviewer(m_Core, stage.stage, slot, 0); - - prev.ShowDock(m_DockContent.Pane, DockAlignment.Right, 0.3); - } - private void cbuffers_NodeDoubleClicked(TreelistView.Node node) { D3D12PipelineState.ShaderStage stage = GetStageForSender(node.OwnerView); if (stage != null && node.Tag is UInt32) { - ShowCBuffer(stage, (UInt32)node.Tag); + //ShowCBuffer(stage, (UInt32)node.Tag); } } @@ -2632,7 +1878,7 @@ namespace renderdocui.Windows.PipelineState if (stage != null && tag is UInt32) { - ShowCBuffer(stage, (UInt32)tag); + //ShowCBuffer(stage, (UInt32)tag); } } @@ -2673,15 +1919,6 @@ namespace renderdocui.Windows.PipelineState private void shaderCog_MouseEnter(object sender, EventArgs e) { - if (sender == iaBytecode || sender == iaBytecodeCog) - { - if (m_Core.CurD3D12PipelineState != null && - m_Core.CurD3D12PipelineState.m_IA.Bytecode != null) - iaBytecodeCog.Image = global::renderdocui.Properties.Resources.action_hover; - - return; - } - if (sender is PictureBox) { D3D12PipelineState.ShaderStage stage = GetStageForSender(sender); @@ -2707,13 +1944,6 @@ namespace renderdocui.Windows.PipelineState private void shaderCog_MouseLeave(object sender, EventArgs e) { - if (sender == iaBytecode || sender == iaBytecodeCog) - { - iaBytecodeCog.Image = global::renderdocui.Properties.Resources.action; - - return; - } - if (sender is PictureBox) { (sender as PictureBox).Image = global::renderdocui.Properties.Resources.action; @@ -2987,7 +2217,7 @@ namespace renderdocui.Windows.PipelineState ExportHTMLTable(writer, cols, new object[][] { rows }); } - private object[] ExportViewHTML(D3D12PipelineState.ShaderStage.ResourceView view, int i, ShaderReflection refl, string extraParams) + private object[] ExportViewHTML(D3D12PipelineState.ResourceView view, int i, ShaderReflection refl, string extraParams) { FetchTexture[] texs = m_Core.CurTextures; FetchBuffer[] bufs = m_Core.CurBuffers; @@ -3059,7 +2289,7 @@ namespace renderdocui.Windows.PipelineState name = bufs[t].name; typename = "Buffer"; - if (view.Flags.HasFlag(D3DBufferViewFlags.Raw)) + if (view.BufferFlags.HasFlag(D3DBufferViewFlags.Raw)) { typename = rw ? "RWByteAddressBuffer" : "ByteAddressBuffer"; } @@ -3069,7 +2299,7 @@ namespace renderdocui.Windows.PipelineState typename = (rw ? "RWStructuredBuffer" : "StructuredBuffer") + "[" + (bufs[t].length / view.ElementSize) + "]"; } - if (view.Flags.HasFlag(D3DBufferViewFlags.Append) || view.Flags.HasFlag(D3DBufferViewFlags.Counter)) + if (view.CounterResource != ResourceId.Null) { typename += " (Count: " + view.BufferStructCount + ")"; } @@ -3097,7 +2327,7 @@ namespace renderdocui.Windows.PipelineState if(buf != null) { - viewParams = String.Format("First Element: {0}, Num Elements {1}, Flags {2}", view.FirstElement, view.NumElements, view.Flags); + viewParams = String.Format("First Element: {0}, Num Elements {1}, Flags {2}", view.FirstElement, view.NumElements, view.BufferFlags); } if (tex != null) @@ -3235,13 +2465,16 @@ namespace renderdocui.Windows.PipelineState writer.WriteEndElement(); ShaderReflection shaderDetails = sh.ShaderDetails; + D3D12PipelineState state = m_Core.CurD3D12PipelineState; string shadername = "Unknown"; - if (sh.Shader == ResourceId.Null) + if (!sh.Present) shadername = "Unbound"; + else if (state.customName) + shadername = state.PipelineName + " - " + m_Core.CurPipelineState.Abbrev(sh.stage); else - shadername = sh.ShaderName; + shadername = sh.stage.Str(GraphicsAPI.D3D12); if (shaderDetails != null && shaderDetails.DebugInfo.entryFunc.Length > 0 && shaderDetails.DebugInfo.files.Length > 0) shadername = shaderDetails.DebugInfo.entryFunc + "()" + " - " + @@ -3254,182 +2487,6 @@ namespace renderdocui.Windows.PipelineState if (sh.Shader == ResourceId.Null) return; } - - { - writer.WriteStartElement("h3"); - writer.WriteString("Resources"); - writer.WriteEndElement(); - - List rows = new List(); - - for (int i = 0; i < sh.SRVs.Length; i++) - { - if (sh.SRVs[i].View == ResourceId.Null) continue; - - rows.Add(ExportViewHTML(sh.SRVs[i], i, sh.ShaderDetails, "")); - } - - ExportHTMLTable(writer, - new string[] { - "Slot", "Name", - "View Type", "Resource Type", - "Width", "Height", "Depth", "Array Size", - "View Format", "Resource Format", - "View Parameters", - }, - rows.ToArray()); - } - - if (sh.stage == ShaderStageType.Compute) - { - writer.WriteStartElement("h3"); - writer.WriteString("Unordered Access Views"); - writer.WriteEndElement(); - - List rows = new List(); - - for (int i = 0; i < sh.UAVs.Length; i++) - { - if (sh.UAVs[i].View == ResourceId.Null) continue; - - rows.Add(ExportViewHTML(sh.UAVs[i], i, sh.ShaderDetails, "")); - } - - ExportHTMLTable(writer, - new string[] { - "Slot", "Name", - "View Type", "Resource Type", - "Width", "Height", "Depth", "Array Size", - "View Format", "Resource Format", - "View Parameters", - }, - rows.ToArray()); - } - - { - writer.WriteStartElement("h3"); - writer.WriteString("Samplers"); - writer.WriteEndElement(); - - List rows = new List(); - - for (int i = 0; i < sh.Samplers.Length; i++) - { - D3D12PipelineState.ShaderStage.Sampler s = sh.Samplers[i]; - - if (s.Samp == ResourceId.Null) continue; - - string borderColor = s.BorderColor[0].ToString() + ", " + - s.BorderColor[1].ToString() + ", " + - s.BorderColor[2].ToString() + ", " + - s.BorderColor[3].ToString(); - - string addressing = ""; - - string addPrefix = ""; - string addVal = ""; - - string[] addr = { s.AddressU, s.AddressV, s.AddressW }; - - // arrange like either UVW: WRAP or UV: WRAP, W: CLAMP - for (int a = 0; a < 3; a++) - { - string prefix = "" + "UVW"[a]; - - if (a == 0 || addr[a] == addr[a - 1]) - { - addPrefix += prefix; - } - else - { - addressing += addPrefix + ": " + addVal + ", "; - - addPrefix = prefix; - } - addVal = addr[a]; - } - - addressing += addPrefix + ": " + addVal; - - rows.Add(new object[] { i, addressing, borderColor, - s.Comparison, s.Filter, s.MaxAniso.ToString(), - s.MinLOD == -float.MaxValue ? "-FLT_MAX" : s.MinLOD.ToString(), - s.MaxLOD == float.MaxValue ? "FLT_MAX" : s.MaxLOD.ToString(), - s.MipLODBias.ToString() }); - } - - ExportHTMLTable(writer, - new string[] { - "Slot", "Addressing", "Border Colour", - "Comparison", "Filter", "Max Anisotropy", - "Min LOD", "Max LOD", "Mip Bias", - }, - rows.ToArray()); - } - - { - writer.WriteStartElement("h3"); - writer.WriteString("Constant Buffers"); - writer.WriteEndElement(); - - List rows = new List(); - - for (int i = 0; i < sh.ConstantBuffers.Length; i++) - { - ConstantBlock shaderCBuf = null; - - if (sh.ConstantBuffers[i].Buffer == ResourceId.Null) continue; - - if (sh.ShaderDetails != null && i < sh.ShaderDetails.ConstantBlocks.Length && - sh.ShaderDetails.ConstantBlocks[i].name.Length > 0) - shaderCBuf = sh.ShaderDetails.ConstantBlocks[i]; - - string name = "Constant Buffer " + sh.ConstantBuffers[i].Buffer.ToString(); - UInt64 length = 1; - int numvars = shaderCBuf != null ? shaderCBuf.variables.Length : 0; - UInt32 byteSize = shaderCBuf != null ? shaderCBuf.byteSize : 0; - - if (sh.ConstantBuffers[i].Buffer == ResourceId.Null) - { - name = "Empty"; - length = 0; - } - - for (int t = 0; t < bufs.Length; t++) - { - if (bufs[t].ID == sh.ConstantBuffers[i].Buffer) - { - name = bufs[t].name; - length = bufs[t].length; - } - } - - rows.Add(new object[] { i, name, sh.ConstantBuffers[i].VecOffset, sh.ConstantBuffers[i].VecCount, numvars, byteSize, length }); - } - - ExportHTMLTable(writer, new string[] { "Slot", "Buffer", "Vector Offset", "Vector Count", "Number of Variables", "Bytes Needed", "Bytes Provided" }, rows.ToArray()); - } - - if (sh.ClassInstances.Length > 0) - { - writer.WriteStartElement("h3"); - writer.WriteString("Class Instances"); - writer.WriteEndElement(); - - List rows = new List(); - - for (int i = 0; i < sh.ClassInstances.Length; i++) - { - string interfaceName = String.Format("Interface {0}", i); - - if (sh.ShaderDetails != null && i < sh.ShaderDetails.Interfaces.Length) - interfaceName = sh.ShaderDetails.Interfaces[i].Name; - - rows.Add(new object[] { i, interfaceName, sh.ClassInstances[i] }); - } - - ExportHTMLTable(writer, new string[] { "Slot", "Interface Name", "Instance Name", }, rows.ToArray()); - } } private void ExportHTML(XmlTextWriter writer, D3D12PipelineState.Streamout so) @@ -3489,8 +2546,8 @@ namespace renderdocui.Windows.PipelineState writer.WriteEndElement(); ExportHTMLTable(writer, - new string[] { "Scissor Enable", "Line AA Enable", "Multisample Enable", "Forced Sample Count", "Conservative Raster" }, - new object[] { rs.m_State.ScissorEnable ? "Yes" : "No", rs.m_State.AntialiasedLineEnable ? "Yes" : "No", + new string[] { "Line AA Enable", "Multisample Enable", "Forced Sample Count", "Conservative Raster" }, + new object[] { rs.m_State.AntialiasedLineEnable ? "Yes" : "No", rs.m_State.MultisampleEnable ? "Yes" : "No", rs.m_State.ForcedSampleCount, rs.m_State.ConservativeRasterization ? "Yes" : "No" }); @@ -3557,9 +2614,9 @@ namespace renderdocui.Windows.PipelineState om.m_BlendState.BlendFactor[3].ToString("F2"); ExportHTMLTable(writer, - new string[] { "Independent Blend Enable", "Alpha to Coverage", "Sample Mask", "Blend Factor" }, + new string[] { "Independent Blend Enable", "Alpha to Coverage", "Blend Factor" }, new object[] { om.m_BlendState.IndependentBlend ? "Yes" : "No", om.m_BlendState.AlphaToCoverage ? "Yes" : "No", - om.m_BlendState.SampleMask.ToString("X8"), blendFactor, }); + blendFactor, }); writer.WriteStartElement("h3"); writer.WriteString("Target Blends"); @@ -3636,7 +2693,7 @@ namespace renderdocui.Windows.PipelineState for (int i = 0; i < om.RenderTargets.Length; i++) { - if (om.RenderTargets[i].View == ResourceId.Null) continue; + if (om.RenderTargets[i].Resource == ResourceId.Null) continue; rows.Add(ExportViewHTML(om.RenderTargets[i], i, null, "")); } @@ -3652,37 +2709,6 @@ namespace renderdocui.Windows.PipelineState rows.ToArray()); } - if(om.UAVs.Length > 0 && om.UAVs[0].View != ResourceId.Null) - { - writer.WriteStartElement("h3"); - writer.WriteString("Unordered Access Views"); - writer.WriteEndElement(); - - List rows = new List(); - - int i = 0; - - for (; i < om.UAVStartSlot; i++) - rows.Add(new object[] { i, "Empty", "", "", "", "", 0, 0, 0, 0, "", "", "" }); - - for (; i < om.RenderTargets.Length; i++) - { - if (om.UAVs[i - om.UAVStartSlot].View == ResourceId.Null) continue; - - rows.Add(ExportViewHTML(om.UAVs[i - om.UAVStartSlot], i, m_Core.CurD3D12PipelineState.m_PS.ShaderDetails, "")); - } - - ExportHTMLTable(writer, - new string[] { - "Slot", "Name", - "View Type", "Resource Type", - "Width", "Height", "Depth", "Array Size", - "View Format", "Resource Format", - "View Parameters", - }, - rows.ToArray()); - } - { writer.WriteStartElement("h3"); writer.WriteString("Depth target"); diff --git a/renderdocui/Windows/PipelineState/VulkanPipelineStateViewer.cs b/renderdocui/Windows/PipelineState/VulkanPipelineStateViewer.cs index c79d7d001..8cd32df1e 100644 --- a/renderdocui/Windows/PipelineState/VulkanPipelineStateViewer.cs +++ b/renderdocui/Windows/PipelineState/VulkanPipelineStateViewer.cs @@ -453,8 +453,7 @@ namespace renderdocui.Windows.PipelineState if (!usedSlot && !stageBitsIncluded) return; - // these are treated as uniform buffers - if (bindType == ShaderBindType.ReadOnlyBuffer) + if (bindType == ShaderBindType.ConstantBuffer) return; // TODO - check compatibility between bindType and shaderRes.resType ? @@ -808,7 +807,7 @@ namespace renderdocui.Windows.PipelineState } VulkanPipelineState.Pipeline.DescriptorSet.DescriptorBinding.BindingElement[] slotBinds = null; - ShaderBindType bindType = ShaderBindType.ReadOnlyBuffer; + ShaderBindType bindType = ShaderBindType.ConstantBuffer; ShaderStageBits stageBits = (ShaderStageBits)0; if (bindset < pipe.DescSets.Length && bind < pipe.DescSets[bindset].bindings.Length) @@ -825,8 +824,7 @@ namespace renderdocui.Windows.PipelineState if (!usedSlot && !stageBitsIncluded) return; - // these are treated as uniform buffers - if (bindType != ShaderBindType.ReadOnlyBuffer) + if (bindType != ShaderBindType.ConstantBuffer) return; // consider it filled if any array element is filled (or it's push constants) @@ -1493,12 +1491,12 @@ namespace renderdocui.Windows.PipelineState if (v.vp.Width == 0 || v.vp.Height == 0 || v.vp.MinDepth == v.vp.MaxDepth) EmptyRow(node); - i++; - node = scissors.Nodes.Add(new object[] { i, v.scissor.x, v.scissor.y, v.scissor.width, v.scissor.height }); if (v.scissor.width == 0 || v.scissor.height == 0) EmptyRow(node); + + i++; } }