diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index b8a5862ac8..23ec492dee 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -38,6 +38,13 @@ const int FB_WIDTH = 480; const int FB_HEIGHT = 272; + +struct Vertex { + float x, y, z; + float u, v; + uint32_t rgba; +}; + FormatBuffer fb; FormatBuffer depthbuf; u32 clut[4096]; @@ -62,7 +69,7 @@ SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Draw::DrawContext *draw) InputLayoutDesc inputDesc = { { - { 24, false }, + { sizeof(Vertex), false }, }, { { 0, SEM_POSITION, DataFormat::R32G32B32_FLOAT, 0 }, @@ -73,7 +80,7 @@ SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Draw::DrawContext *draw) ShaderModule *vshader = draw_->GetVshaderPreset(VS_TEXTURE_COLOR_2D); - vdata = draw_->CreateBuffer(24 * 4, BufferUsageFlag::DYNAMIC | BufferUsageFlag::VERTEXDATA); + vdata = draw_->CreateBuffer(sizeof(Vertex) * 4, BufferUsageFlag::DYNAMIC | BufferUsageFlag::VERTEXDATA); idata = draw_->CreateBuffer(sizeof(int) * 6, BufferUsageFlag::DYNAMIC | BufferUsageFlag::INDEXDATA); InputLayout *inputLayout = draw_->CreateInputLayout(inputDesc); @@ -213,12 +220,6 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) { x2 -= 1.0f; y2 -= 1.0f; - struct Vertex { - float x, y, z; - float u, v; - uint32_t rgba; - }; - if (hasImage) { float v0 = 1.0f; float v1 = 0.0f; @@ -235,10 +236,10 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) { { x2, y2, 0, u1, v1, 0xFFFFFFFF }, // BR { x2, y, 0, u1, v0, 0xFFFFFFFF }, // TR }; - vdata->SetData((const uint8_t *)verts, sizeof(verts)); + vdata->SubData((const uint8_t *)verts, 0, sizeof(verts)); int indexes[] = { 0, 1, 2, 0, 2, 3 }; - idata->SetData((const uint8_t *)indexes, sizeof(indexes)); + idata->SubData((const uint8_t *)indexes, 0, sizeof(indexes)); draw_->BindTexture(0, fbTex); diff --git a/ext/native/thin3d/thin3d.h b/ext/native/thin3d/thin3d.h index 67f14cda6c..7d76cab3ca 100644 --- a/ext/native/thin3d/thin3d.h +++ b/ext/native/thin3d/thin3d.h @@ -388,7 +388,6 @@ public: class Buffer : public RefCountedObject { public: - virtual void SetData(const uint8_t *data, size_t size) = 0; virtual void SubData(const uint8_t *data, size_t offset, size_t size) = 0; }; diff --git a/ext/native/thin3d/thin3d_d3d11.cpp b/ext/native/thin3d/thin3d_d3d11.cpp index 5ad5252ab9..027bffad70 100644 --- a/ext/native/thin3d/thin3d_d3d11.cpp +++ b/ext/native/thin3d/thin3d_d3d11.cpp @@ -701,9 +701,6 @@ public: buf->Release(); if (srView) srView->Release(); - } - virtual void SetData(const uint8_t *data, size_t size) override { - } virtual void SubData(const uint8_t *data, size_t offset, size_t size) override { diff --git a/ext/native/thin3d/thin3d_d3d9.cpp b/ext/native/thin3d/thin3d_d3d9.cpp index 6a1eabbd12..0db6bd7f3b 100644 --- a/ext/native/thin3d/thin3d_d3d9.cpp +++ b/ext/native/thin3d/thin3d_d3d9.cpp @@ -241,30 +241,11 @@ public: } } - void SetData(const uint8_t *data, size_t size) override { - if (!size) - return; - if (size > maxSize_) { - ELOG("Can't SetData with bigger size than buffer was created with on D3D"); - return; - } - if (vbuffer_) { - void *ptr; - vbuffer_->Lock(0, (UINT)size, &ptr, D3DLOCK_DISCARD); - memcpy(ptr, data, size); - vbuffer_->Unlock(); - } else if (ibuffer_) { - void *ptr; - ibuffer_->Lock(0, (UINT)size, &ptr, D3DLOCK_DISCARD); - memcpy(ptr, data, size); - ibuffer_->Unlock(); - } - } void SubData(const uint8_t *data, size_t offset, size_t size) override { if (!size) return; if (offset + size > maxSize_) { - ELOG("Can't SubData with bigger size than buffer was created with on D3D"); + ELOG("Can't SubData with bigger size than buffer was created with"); return; } if (vbuffer_) { diff --git a/ext/native/thin3d/thin3d_gl.cpp b/ext/native/thin3d/thin3d_gl.cpp index e9f1a0ff82..1c4f79496b 100644 --- a/ext/native/thin3d/thin3d_gl.cpp +++ b/ext/native/thin3d/thin3d_gl.cpp @@ -281,6 +281,7 @@ public: else usage_ = GL_STATIC_DRAW; totalSize_ = size; + glBindBuffer(target_, buffer_); glBufferData(target_, size, NULL, usage_); register_gl_resource_holder(this); } @@ -289,14 +290,6 @@ public: glDeleteBuffers(1, &buffer_); } - void SetData(const uint8_t *data, size_t size) override { - if (size > totalSize_) { - Crash(); - } - Bind(0); - glBufferData(target_, size, data, usage_); - } - void SubData(const uint8_t *data, size_t offset, size_t size) override { Bind(0); if (size + offset > totalSize_) { diff --git a/ext/native/thin3d/thin3d_vulkan.cpp b/ext/native/thin3d/thin3d_vulkan.cpp index 3f569faffe..68db2637b4 100644 --- a/ext/native/thin3d/thin3d_vulkan.cpp +++ b/ext/native/thin3d/thin3d_vulkan.cpp @@ -187,15 +187,6 @@ public: delete[] data_; } - void SetData(const uint8_t *data, size_t size) override { - delete[] data_; - dataSize_ = size; - data_ = new uint8_t[size]; - if (data) { - memcpy(data_, data, size); - } - } - void SubData(const uint8_t *data, size_t offset, size_t size) override { memcpy(data_, data_ + offset, size); }