From d421988f91d0d6fda78b9aea4cba763f9c662ffe Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 21 Mar 2018 14:28:43 -0400 Subject: First pass impls on ComPtr and reorganise Renderer (#450) * Fixed some small typos in api-users-guide.md * Fix some small typos in slang-test/main.cpp, render-test/render-d3d11.cpp * Remove exit() calls from test code. Added Slang::Result, which works in the same way as COM HRESULT. * FIx bug introduced when moving to Slang::Result - handling E_INVALIDARG on Dx11. * Fix the testing of feature levels on Dx11 renderer. * First attempt at README.md for slang-test. * Tidied up the slang-test README.md file. * Fix some small typos in tools/slang-test/main.cpp * Fix spaces -> tabs problems. Fix some small types. * Refactor Renderer implementations such that: * Class definition does not contain long implementation/s * Removed unused globals * Ordered implementation after class definition * Made renderer specific classes child classes, and use Impl postfix to differentiate * Converted tabs into spaces * First pass at Slang::ComPtr. Added slang-defines.h which sets up some fairly commonly used defines such as SLANG_FORCE_INLINE, compiler detection, os detection, and some other cross platform features. --- tools/render-test/render.h | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'tools/render-test/render.h') diff --git a/tools/render-test/render.h b/tools/render-test/render.h index 902067d62..bc63caa77 100644 --- a/tools/render-test/render.h +++ b/tools/render-test/render.h @@ -9,10 +9,12 @@ namespace renderer_test { -typedef struct Buffer Buffer; -typedef struct InputLayout InputLayout; -typedef struct ShaderProgram ShaderProgram; -typedef struct BindingState BindingState; +// Declare opaque type +struct Buffer; +struct InputLayout; +struct ShaderProgram; +struct BindingState; + struct ShaderCompileRequest { struct SourceInfo @@ -39,7 +41,7 @@ struct ShaderCompileRequest SourceInfo source; EntryPoint vertexShader; EntryPoint fragmentShader; - EntryPoint computeShader; + EntryPoint computeShader; Slang::List entryPointTypeArguments; }; @@ -79,8 +81,8 @@ struct InputElementDesc enum class MapFlavor { - HostRead, - HostWrite, + HostRead, + HostWrite, WriteDiscard, }; @@ -115,20 +117,28 @@ public: virtual void setBindingState(BindingState * state) = 0; virtual void setVertexBuffers(UInt startSlot, UInt slotCount, Buffer* const* buffers, UInt const* strides, UInt const* offsets) = 0; - inline void setVertexBuffer(UInt slot, Buffer* buffer, UInt stride, UInt offset = 0) - { - setVertexBuffers(slot, 1, &buffer, &stride, &offset); - } + inline void setVertexBuffer(UInt slot, Buffer* buffer, UInt stride, UInt offset = 0); virtual void setShaderProgram(ShaderProgram* program) = 0; virtual void setConstantBuffers(UInt startSlot, UInt slotCount, Buffer* const* buffers, UInt const* offsets) = 0; - inline void setConstantBuffer(UInt slot, Buffer* buffer, UInt offset = 0) - { - setConstantBuffers(slot, 1, &buffer, &offset); - } + inline void setConstantBuffer(UInt slot, Buffer* buffer, UInt offset = 0); + virtual void draw(UInt vertexCount, UInt startVertex = 0) = 0; - virtual void dispatchCompute(int x, int y, int z) = 0; + virtual void dispatchCompute(int x, int y, int z) = 0; }; + +// ---------------------------------------------------------------------------------------- +inline void Renderer::setVertexBuffer(UInt slot, Buffer* buffer, UInt stride, UInt offset) +{ + setVertexBuffers(slot, 1, &buffer, &stride, &offset); +} +// ---------------------------------------------------------------------------------------- +inline void Renderer::setConstantBuffer(UInt slot, Buffer* buffer, UInt offset) +{ + setConstantBuffers(slot, 1, &buffer, &offset); +} + + } // renderer_test -- cgit v1.2.3