mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-18 03:44:32 +01:00
Merge pull request #14702 from unknownbrackets/reinterpret
GPU: Use an empty vertex buf for reinterpret
This commit is contained in:
7 files changed
+25
-19
No files matched your search
@@ -87,7 +87,7 @@ public:
|
||||
|
||||
void BindTextures(int start, int count, Texture **textures) override;
|
||||
void BindSamplerStates(int start, int count, SamplerState **states) override;
|
||||
void BindVertexBuffers(int start, int count, Buffer **buffers, int *offsets) override;
|
||||
void BindVertexBuffers(int start, int count, Buffer **buffers, const int *offsets) override;
|
||||
void BindIndexBuffer(Buffer *indexBuffer, int offset) override;
|
||||
void BindPipeline(Pipeline *pipeline) override;
|
||||
|
||||
@@ -1163,7 +1163,7 @@ void D3D11DrawContext::UpdateBuffer(Buffer *buffer, const uint8_t *data, size_t
|
||||
context_->UpdateSubresource(buf->buf, 0, &box, data, 0, 0);
|
||||
}
|
||||
|
||||
void D3D11DrawContext::BindVertexBuffers(int start, int count, Buffer **buffers, int *offsets) {
|
||||
void D3D11DrawContext::BindVertexBuffers(int start, int count, Buffer **buffers, const int *offsets) {
|
||||
_assert_(start + count <= ARRAY_SIZE(nextVertexBuffers_));
|
||||
// Lazy application
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
||||
@@ -533,7 +533,7 @@ public:
|
||||
s->Apply(device_, start + i);
|
||||
}
|
||||
}
|
||||
void BindVertexBuffers(int start, int count, Buffer **buffers, int *offsets) override {
|
||||
void BindVertexBuffers(int start, int count, Buffer **buffers, const int *offsets) override {
|
||||
_assert_(start + count <= ARRAY_SIZE(curVBuffers_));
|
||||
for (int i = 0; i < count; i++) {
|
||||
curVBuffers_[i + start] = (D3D9Buffer *)buffers[i];
|
||||
|
||||
@@ -399,7 +399,7 @@ public:
|
||||
|
||||
void BindTextures(int start, int count, Texture **textures) override;
|
||||
void BindPipeline(Pipeline *pipeline) override;
|
||||
void BindVertexBuffers(int start, int count, Buffer **buffers, int *offsets) override {
|
||||
void BindVertexBuffers(int start, int count, Buffer **buffers, const int *offsets) override {
|
||||
_assert_(start + count <= ARRAY_SIZE(curVBuffers_));
|
||||
for (int i = 0; i < count; i++) {
|
||||
curVBuffers_[i + start] = (OpenGLBuffer *)buffers[i];
|
||||
|
||||
@@ -415,7 +415,7 @@ public:
|
||||
}
|
||||
|
||||
// TODO: Make VKBuffers proper buffers, and do a proper binding model. This is just silly.
|
||||
void BindVertexBuffers(int start, int count, Buffer **buffers, int *offsets) override {
|
||||
void BindVertexBuffers(int start, int count, Buffer **buffers, const int *offsets) override {
|
||||
_assert_(start + count <= ARRAY_SIZE(curVBuffers_));
|
||||
for (int i = 0; i < count; i++) {
|
||||
curVBuffers_[i + start] = (VKBuffer *)buffers[i];
|
||||
|
||||
+1
-1
@@ -643,7 +643,7 @@ public:
|
||||
|
||||
virtual void BindSamplerStates(int start, int count, SamplerState **state) = 0;
|
||||
virtual void BindTextures(int start, int count, Texture **textures) = 0;
|
||||
virtual void BindVertexBuffers(int start, int count, Buffer **buffers, int *offsets) = 0;
|
||||
virtual void BindVertexBuffers(int start, int count, Buffer **buffers, const int *offsets) = 0;
|
||||
virtual void BindIndexBuffer(Buffer *indexBuffer, int offset) = 0;
|
||||
|
||||
// Only supports a single dynamic uniform buffer, for maximum compatibility with the old APIs and ease of emulation.
|
||||
|
||||
@@ -603,6 +603,10 @@ void FramebufferManagerCommon::ReinterpretFramebuffer(VirtualFramebuffer *vfb, G
|
||||
reinterpretSampler_ = draw_->CreateSamplerState(samplerDesc);
|
||||
}
|
||||
|
||||
if (!reinterpretVBuf_) {
|
||||
reinterpretVBuf_ = draw_->CreateBuffer(12 * 3, Draw::BufferUsageFlag::DYNAMIC | Draw::BufferUsageFlag::VERTEXDATA);
|
||||
}
|
||||
|
||||
// See if we need to create a new pipeline.
|
||||
|
||||
Draw::Pipeline *pipeline = reinterpretFromTo_[(int)oldFormat][(int)newFormat];
|
||||
@@ -650,7 +654,9 @@ void FramebufferManagerCommon::ReinterpretFramebuffer(VirtualFramebuffer *vfb, G
|
||||
draw_->SetScissorRect(0, 0, vfb->renderWidth, vfb->renderHeight);
|
||||
Draw::Viewport vp = Draw::Viewport{ 0.0f, 0.0f, (float)vfb->renderWidth, (float)vfb->renderHeight, 0.0f, 1.0f };
|
||||
draw_->SetViewports(1, &vp);
|
||||
// No vertex buffer - generate vertices in shader. TODO: Switch to a vertex buffer for GLES2/D3D9 compat.
|
||||
// Vertex buffer not used - vertices generated in shader.
|
||||
// TODO: Switch to a vertex buffer for GLES2/D3D9 compat.
|
||||
draw_->BindVertexBuffers(0, 1, &reinterpretVBuf_, nullptr);
|
||||
draw_->Draw(3, 0);
|
||||
draw_->InvalidateCachedState();
|
||||
|
||||
@@ -2318,24 +2324,23 @@ std::vector<FramebufferInfo> FramebufferManagerCommon::GetFramebufferList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static void DoRelease(T *&obj) {
|
||||
if (obj)
|
||||
obj->Release();
|
||||
obj = nullptr;
|
||||
}
|
||||
|
||||
void FramebufferManagerCommon::DeviceLost() {
|
||||
DestroyAllFBOs();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
if (reinterpretFromTo_[i][j]) {
|
||||
reinterpretFromTo_[i][j]->Release();
|
||||
reinterpretFromTo_[i][j] = nullptr;
|
||||
}
|
||||
DoRelease(reinterpretFromTo_[i][j]);
|
||||
}
|
||||
}
|
||||
if (reinterpretSampler_) {
|
||||
reinterpretSampler_->Release();
|
||||
reinterpretSampler_ = nullptr;
|
||||
}
|
||||
if (reinterpretVS_) {
|
||||
reinterpretVS_->Release();
|
||||
reinterpretVS_ = nullptr;
|
||||
}
|
||||
DoRelease(reinterpretVBuf_);
|
||||
DoRelease(reinterpretSampler_);
|
||||
DoRelease(reinterpretVS_);
|
||||
presentation_->DeviceLost();
|
||||
draw_ = nullptr;
|
||||
}
|
||||
|
||||
@@ -445,4 +445,5 @@ protected:
|
||||
Draw::Pipeline *reinterpretFromTo_[3][3]{};
|
||||
Draw::ShaderModule *reinterpretVS_ = nullptr;
|
||||
Draw::SamplerState *reinterpretSampler_ = nullptr;
|
||||
Draw::Buffer *reinterpretVBuf_ = nullptr;
|
||||
};
|
||||
Reference in new issue
Block a user