mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-26 15:53:35 +01:00
Vulkan: Make sure textures/samplers are unbound at the end of PresentationCommon::CopyToOutput.
Validation caught an issue where old stuff lingered in sampler 1 and texture 1. Bug probably introduced in #12921, but could also be others.
This commit is contained in:
1 parent
53b2ab191b
commit
131a1eedfb
6 files changed
+48
-2
No files matched your search
@@ -748,6 +748,7 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u
|
||||
DoRelease(srcFramebuffer_);
|
||||
DoRelease(srcTexture_);
|
||||
|
||||
// Unbinds all textures and samplers too, needed since sometimes a MakePixelTexture is deleted etc.
|
||||
draw_->BindPipeline(nullptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -643,7 +643,7 @@ public:
|
||||
BindTextures(stage, 1, textures);
|
||||
} // from sampler 0 and upwards
|
||||
|
||||
// Call this with 0 to signal that you have been drawing on your own, and need the state reset on the next pipeline bind.
|
||||
// Call this with nullptr to signal that you're done with the stuff you've bound, like textures and samplers and stuff.
|
||||
virtual void BindPipeline(Pipeline *pipeline) = 0;
|
||||
|
||||
virtual void Draw(int vertexCount, int offset) = 0;
|
||||
@@ -652,7 +652,7 @@ public:
|
||||
|
||||
// Frame management (for the purposes of sync and resource management, necessary with modern APIs). Default implementations here.
|
||||
virtual void BeginFrame() {}
|
||||
virtual void EndFrame() {}
|
||||
virtual void EndFrame() = 0;
|
||||
virtual void WipeQueue() {}
|
||||
|
||||
// This should be avoided as much as possible, in favor of clearing when binding a render target, which is native
|
||||
|
||||
@@ -100,6 +100,8 @@ public:
|
||||
stencilRefDirty_ = true;
|
||||
}
|
||||
|
||||
void EndFrame() override;
|
||||
|
||||
void Draw(int vertexCount, int offset) override;
|
||||
void DrawIndexed(int vertexCount, int offset) override;
|
||||
void DrawUP(const void *vdata, int vertexCount) override;
|
||||
@@ -363,6 +365,10 @@ void D3D11DrawContext::HandleEvent(Event ev, int width, int height, void *param1
|
||||
}
|
||||
}
|
||||
|
||||
void D3D11DrawContext::EndFrame() {
|
||||
curPipeline_ = nullptr;
|
||||
}
|
||||
|
||||
void D3D11DrawContext::SetViewports(int count, Viewport *viewports) {
|
||||
D3D11_VIEWPORT vp[4];
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
||||
@@ -559,6 +559,8 @@ public:
|
||||
curPipeline_ = (D3D9Pipeline *)pipeline;
|
||||
}
|
||||
|
||||
void EndFrame() override;
|
||||
|
||||
void UpdateDynamicUniformBuffer(const void *ub, size_t size) override;
|
||||
|
||||
// Raster state
|
||||
@@ -802,6 +804,10 @@ void D3D9Context::BindTextures(int start, int count, Texture **textures) {
|
||||
}
|
||||
}
|
||||
|
||||
void D3D9Context::EndFrame() {
|
||||
curPipeline_ = nullptr;
|
||||
}
|
||||
|
||||
static void SemanticToD3D9UsageAndIndex(int semantic, BYTE *usage, BYTE *index) {
|
||||
*index = 0;
|
||||
switch (semantic) {
|
||||
|
||||
@@ -618,6 +618,15 @@ void OpenGLContext::EndFrame() {
|
||||
FrameData &frameData = frameData_[renderManager_.GetCurFrame()];
|
||||
renderManager_.EndPushBuffer(frameData.push); // upload the data!
|
||||
renderManager_.Finish();
|
||||
|
||||
// Unbind stuff.
|
||||
for (auto &texture : boundTextures_) {
|
||||
texture = nullptr;
|
||||
}
|
||||
for (auto &sampler : boundSamplers_) {
|
||||
sampler = nullptr;
|
||||
}
|
||||
curPipeline_ = nullptr;
|
||||
}
|
||||
|
||||
InputLayout *OpenGLContext::CreateInputLayout(const InputLayoutDesc &desc) {
|
||||
|
||||
@@ -406,8 +406,13 @@ public:
|
||||
|
||||
void BindSamplerStates(int start, int count, SamplerState **state) override;
|
||||
void BindTextures(int start, int count, Texture **textures) override;
|
||||
|
||||
void BindPipeline(Pipeline *pipeline) override {
|
||||
curPipeline_ = (VKPipeline *)pipeline;
|
||||
|
||||
if (!pipeline) {
|
||||
UnbindBoundState();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Make VKBuffers proper buffers, and do a proper binding model. This is just silly.
|
||||
@@ -494,6 +499,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void UnbindBoundState();
|
||||
|
||||
VulkanTexture *GetNullTexture();
|
||||
VulkanContext *vulkan_ = nullptr;
|
||||
|
||||
@@ -913,6 +920,23 @@ void VKContext::EndFrame() {
|
||||
renderManager_.Finish();
|
||||
|
||||
push_ = nullptr;
|
||||
|
||||
// Unbind stuff, to avoid accidentally relying on it across frames (and provide some protection against forgotten unbinds of deleted things).
|
||||
UnbindBoundState();
|
||||
}
|
||||
|
||||
void VKContext::UnbindBoundState() {
|
||||
curPipeline_ = nullptr;
|
||||
|
||||
for (auto &view : boundImageView_) {
|
||||
view = nullptr;
|
||||
}
|
||||
for (auto &sampler : boundSamplers_) {
|
||||
sampler = nullptr;
|
||||
}
|
||||
for (auto &texture : boundTextures_) {
|
||||
texture = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void VKContext::WipeQueue() {
|
||||
|
||||
Reference in new issue
Block a user