From 367f3a78a40731da45ee12b9a18c94707f1d1429 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 3 May 2018 14:25:13 -0400 Subject: Feature/vulkan first render (#545) * First pass at InputLayout for Vulkan Add support for RGBA_Float32 * Use VulkanModule and VulkanApi to handle accessing Vulkan types. * First pass at Vulkan swap chain/Device queue. * Added VulkanUtil for generic function functions. * Move more functionality to VulkanApi and VulkanUtil. Make Buffer able to initialize itself. * More tidy up around VulkanDeviceQueue * First pass use of VulkanDeviceQueue in VkRenderer * First pass use of VulkanSwapChain on VkRenderer * Added depth formats. Binding for constant and vertex buffers for Vulkan. * Setting up VkImageView on backbuffers. * First pass support for setting up vkRenderPass. * Fixes to work around Vulkan swap chain/verification issues. * Added support for Pipeline and a pipeline cache. * Working without waiting - because use of pipeline cache. * Added support for VkFramebuffer in Vulkan. * First pass at creating Vulkan graphics pipeline. * More efforts to get Vulkan to render. * Small improvement for checking of Binding flags. * Removed setConstantBuffers from the Renderer interface - so that all resource binding takes place through the BindingState. To make this work required a 'hack' in render-test main.cpp - so that the constant buffer binding that is needed in some tests is only added when it doesn't clash. * RendererID -> unified into RendererType. Added getRendererType to Renderer interface. Added ProjectionStyle, and function to get from RendererType. Added getIdentityProjection to RendererUtil - to get projection that is the 'identity' - but hits the same pixels for all projection styles. * Fix build problem on Win32 on Vulkan where should use VK_NULL_HANDLE. * Improve naming, comments. Remove dead code. * Remove unwanted comment. --- tools/render-test/render-d3d11.cpp | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) (limited to 'tools/render-test/render-d3d11.cpp') diff --git a/tools/render-test/render-d3d11.cpp b/tools/render-test/render-d3d11.cpp index 7018c223a..e2bcf1659 100644 --- a/tools/render-test/render-d3d11.cpp +++ b/tools/render-test/render-d3d11.cpp @@ -64,11 +64,11 @@ public: virtual void setBindingState(BindingState * state); virtual void setVertexBuffers(UInt startSlot, UInt slotCount, BufferResource*const* buffers, const UInt* strides, const UInt* offsets) override; virtual void setShaderProgram(ShaderProgram* inProgram) override; - virtual void setConstantBuffers(UInt startSlot, UInt slotCount, BufferResource*const* buffers, const UInt* offsets) override; virtual void draw(UInt vertexCount, UInt startVertex) override; virtual void dispatchCompute(int x, int y, int z) override; virtual void submitGpuWork() override {} virtual void waitForGpu() override {} + virtual RendererType getRendererType() const override { return RendererType::DirectX11; } // ShaderCompiler implementation virtual ShaderProgram* compileProgram(ShaderCompileRequest const& request) override; @@ -144,7 +144,7 @@ public: /// Capture a texture to a file static HRESULT captureTextureToFile(ID3D11Device* device, ID3D11DeviceContext* context, ID3D11Texture2D* texture, char const* outputPath); - void applyBindingState(bool isCompute); + void _applyBindingState(bool isCompute); ComPtr m_swapChain; ComPtr m_device; @@ -669,6 +669,9 @@ InputLayout* D3D11Renderer::createInputLayout(const InputElementDesc* inputEleme char const* typeName = "Unknown"; switch (inputElementsIn[ii].format) { + case Format::RGBA_Float32: + typeName = "float4"; + break; case Format::RGB_Float32: typeName = "float3"; break; @@ -794,29 +797,9 @@ void D3D11Renderer::setShaderProgram(ShaderProgram* programIn) m_immediateContext->PSSetShader(program->m_pixelShader, nullptr, 0); } -void D3D11Renderer::setConstantBuffers(UInt startSlot, UInt slotCount, BufferResource*const* buffersIn, const UInt* offsetsIn) -{ - static const int kMaxConstantBuffers = 16; - assert(slotCount <= kMaxConstantBuffers); - - // TODO: actually use those offsets - - auto buffers = (BufferResourceImpl*const*)buffersIn; - - // Copy out the actual dx buffers - ID3D11Buffer* dxBuffers[kMaxConstantBuffers]; - for (UInt i = 0; i < slotCount; i++) - { - dxBuffers[i] = buffers[i]->m_buffer; - } - - m_immediateContext->VSSetConstantBuffers((UINT)startSlot, (UINT)slotCount, dxBuffers); - m_immediateContext->VSSetConstantBuffers((UINT)startSlot, (UINT)slotCount, dxBuffers); -} - void D3D11Renderer::draw(UInt vertexCount, UInt startVertex) { - applyBindingState(false); + _applyBindingState(false); m_immediateContext->Draw((UINT)vertexCount, (UINT)startVertex); } @@ -855,7 +838,7 @@ ShaderProgram* D3D11Renderer::compileProgram(const ShaderCompileRequest& request void D3D11Renderer::dispatchCompute(int x, int y, int z) { - applyBindingState(true); + _applyBindingState(true); m_immediateContext->Dispatch(x, y, z); } @@ -1048,7 +1031,7 @@ BindingState* D3D11Renderer::createBindingState(const BindingState::Desc& bindin return bindingState.detach(); } -void D3D11Renderer::applyBindingState(bool isCompute) +void D3D11Renderer::_applyBindingState(bool isCompute) { auto context = m_immediateContext.get(); -- cgit v1.2.3