diff --git a/Common/GPU/D3D11/thin3d_d3d11.cpp b/Common/GPU/D3D11/thin3d_d3d11.cpp index a9a922cf24..7dc6e7e17c 100644 --- a/Common/GPU/D3D11/thin3d_d3d11.cpp +++ b/Common/GPU/D3D11/thin3d_d3d11.cpp @@ -38,6 +38,7 @@ class D3D11Pipeline; class D3D11BlendState; class D3D11DepthStencilState; class D3D11SamplerState; +class D3D11Buffer; class D3D11RasterState; class D3D11Framebuffer; @@ -252,6 +253,7 @@ private: // Temporaries ID3D11Texture2D *packTexture_ = nullptr; + Buffer *upBuffer_ = nullptr; // System info D3D_FEATURE_LEVEL featureLevel_; @@ -338,9 +340,14 @@ D3D11DrawContext::D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *de _assert_(SUCCEEDED(hr)); shaderLanguageDesc_.Init(HLSL_D3D11); + + const size_t UP_MAX_BYTES = 65536 * 24; + + upBuffer_ = CreateBuffer(UP_MAX_BYTES, BufferUsageFlag::DYNAMIC | BufferUsageFlag::VERTEXDATA); } D3D11DrawContext::~D3D11DrawContext() { + upBuffer_->Release(); packTexture_->Release(); // Release references. @@ -756,9 +763,6 @@ public: shaderModule->Release(); } } - bool RequiresBuffer() override { - return true; - } AutoRef input; ID3D11InputLayout *il = nullptr; @@ -1248,7 +1252,13 @@ void D3D11DrawContext::DrawIndexed(int indexCount, int offset) { void D3D11DrawContext::DrawUP(const void *vdata, int vertexCount) { ApplyCurrentState(); - // TODO: Upload the data then draw.. + + int byteSize = vertexCount * curPipeline_->input->strides[0]; + + UpdateBuffer(upBuffer_, (const uint8_t *)vdata, 0, byteSize, Draw::UPDATE_DISCARD); + BindVertexBuffers(0, 1, &upBuffer_, nullptr); + int offset = 0; + Draw(vertexCount, offset); } uint32_t D3D11DrawContext::GetDataFormatSupport(DataFormat fmt) const { diff --git a/Common/GPU/D3D9/thin3d_d3d9.cpp b/Common/GPU/D3D9/thin3d_d3d9.cpp index 684b727cc5..d42833558a 100644 --- a/Common/GPU/D3D9/thin3d_d3d9.cpp +++ b/Common/GPU/D3D9/thin3d_d3d9.cpp @@ -272,9 +272,6 @@ public: D3D9Pipeline() {} ~D3D9Pipeline() { } - bool RequiresBuffer() override { - return false; - } D3D9ShaderModule *vshader; D3D9ShaderModule *pshader; diff --git a/Common/GPU/OpenGL/thin3d_gl.cpp b/Common/GPU/OpenGL/thin3d_gl.cpp index b48d900ab1..f25fe16ef9 100644 --- a/Common/GPU/OpenGL/thin3d_gl.cpp +++ b/Common/GPU/OpenGL/thin3d_gl.cpp @@ -261,9 +261,6 @@ public: ~OpenGLInputLayout(); void Compile(const InputLayoutDesc &desc); - bool RequiresBuffer() { - return false; - } GLRInputLayout *inputLayout_ = nullptr; int stride = 0; @@ -284,10 +281,6 @@ public: bool LinkShaders(); - bool RequiresBuffer() override { - return inputLayout && inputLayout->RequiresBuffer(); - } - GLuint prim = 0; std::vector shaders; AutoRef inputLayout; diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index e2cae4c906..2e329f1d45 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -271,9 +271,6 @@ public: int GetUBOSize() const { return uboSize_; } - bool RequiresBuffer() override { - return false; - } VkPipeline backbufferPipeline = VK_NULL_HANDLE; VkPipeline framebufferPipeline = VK_NULL_HANDLE; diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index 9a618df79e..185d8929fc 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -450,7 +450,6 @@ public: class Pipeline : public RefCountedObject { public: virtual ~Pipeline() {} - virtual bool RequiresBuffer() = 0; }; class RasterState : public RefCountedObject {}; diff --git a/Common/Render/DrawBuffer.cpp b/Common/Render/DrawBuffer.cpp index 35e3f0176b..9b09e7675b 100644 --- a/Common/Render/DrawBuffer.cpp +++ b/Common/Render/DrawBuffer.cpp @@ -32,12 +32,6 @@ void DrawBuffer::Init(Draw::DrawContext *t3d, Draw::Pipeline *pipeline) { draw_ = t3d; inited_ = true; - - if (pipeline->RequiresBuffer()) { - vbuf_ = draw_->CreateBuffer(MAX_VERTS * sizeof(Vertex), BufferUsageFlag::DYNAMIC | BufferUsageFlag::VERTEXDATA); - } else { - vbuf_ = nullptr; - } } Draw::InputLayout *DrawBuffer::CreateInputLayout(Draw::DrawContext *t3d) { @@ -57,10 +51,6 @@ Draw::InputLayout *DrawBuffer::CreateInputLayout(Draw::DrawContext *t3d) { } void DrawBuffer::Shutdown() { - if (vbuf_) { - vbuf_->Release(); - vbuf_ = nullptr; - } inited_ = false; alphaStack_.clear(); drawMatrixStack_.clear(); @@ -90,14 +80,7 @@ void DrawBuffer::Flush(bool set_blend_state) { ub.tint = tint_; ub.saturation = saturation_; draw_->UpdateDynamicUniformBuffer(&ub, sizeof(ub)); - if (vbuf_) { - draw_->UpdateBuffer(vbuf_, (const uint8_t *)verts_, 0, sizeof(Vertex) * count_, Draw::UPDATE_DISCARD); - draw_->BindVertexBuffers(0, 1, &vbuf_, nullptr); - int offset = 0; - draw_->Draw(count_, offset); - } else { - draw_->DrawUP((const void *)verts_, count_); - } + draw_->DrawUP((const void *)verts_, count_); count_ = 0; } diff --git a/Common/Render/DrawBuffer.h b/Common/Render/DrawBuffer.h index e103805d2e..4a29893c15 100644 --- a/Common/Render/DrawBuffer.h +++ b/Common/Render/DrawBuffer.h @@ -199,7 +199,6 @@ private: std::vector alphaStack_; Draw::DrawContext *draw_ = nullptr; - Draw::Buffer *vbuf_ = nullptr; Draw::Pipeline *pipeline_ = nullptr; Vertex *verts_;