From 7652bc2d8bdb61cabf53828deb9531b887fd12fe Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Wed, 15 Feb 2017 12:50:15 +0100 Subject: [PATCH] Declare DrawActiveTexture in FramebufferCommon --- GPU/Common/FramebufferCommon.h | 1 + GPU/D3D11/FramebufferManagerD3D11.h | 2 +- GPU/Directx9/FramebufferDX9.cpp | 22 +++++++++++----------- GPU/Directx9/FramebufferDX9.h | 2 +- GPU/GLES/FramebufferManagerGLES.h | 2 +- GPU/Vulkan/FramebufferVulkan.cpp | 7 ++++--- GPU/Vulkan/FramebufferVulkan.h | 1 + 7 files changed, 20 insertions(+), 17 deletions(-) diff --git a/GPU/Common/FramebufferCommon.h b/GPU/Common/FramebufferCommon.h index 96ad6d0e6a..1b85572a2c 100644 --- a/GPU/Common/FramebufferCommon.h +++ b/GPU/Common/FramebufferCommon.h @@ -259,6 +259,7 @@ public: protected: void CalculatePostShaderUniforms(int bufferWidth, int bufferHeight, int renderWidth, int renderHeight, PostShaderUniforms *uniforms); + virtual void DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, bool linearFilter) = 0; virtual void BindPostShader(const PostShaderUniforms &uniforms) {} // Cardboard Settings Calculator diff --git a/GPU/D3D11/FramebufferManagerD3D11.h b/GPU/D3D11/FramebufferManagerD3D11.h index 4ec4de9b00..fe1c2eb54c 100644 --- a/GPU/D3D11/FramebufferManagerD3D11.h +++ b/GPU/D3D11/FramebufferManagerD3D11.h @@ -54,7 +54,7 @@ public: virtual void DrawPixels(VirtualFramebuffer *vfb, int dstX, int dstY, const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) override; virtual void DrawFramebufferToOutput(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, bool applyPostShader) override; - void DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, bool linearFilter); + void DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, bool linearFilter) override; void DestroyAllFBOs(bool forceDelete); diff --git a/GPU/Directx9/FramebufferDX9.cpp b/GPU/Directx9/FramebufferDX9.cpp index bb872c1f2f..49ba31c6df 100644 --- a/GPU/Directx9/FramebufferDX9.cpp +++ b/GPU/Directx9/FramebufferDX9.cpp @@ -279,7 +279,7 @@ static void DXSetViewport(float x, float y, float w, float h, float minZ, float MakePixelTexture(srcPixels, srcPixelFormat, srcStride, width, height); DisableState(); device_->SetTexture(0, drawPixelsTex_); - DrawActiveTexture(dstX, dstY, width, height, vfb->bufferWidth, vfb->bufferHeight, 0.0f, 0.0f, 1.0f, 1.0f, ROTATION_LOCKED_HORIZONTAL); + DrawActiveTexture(dstX, dstY, width, height, vfb->bufferWidth, vfb->bufferHeight, 0.0f, 0.0f, 1.0f, 1.0f, ROTATION_LOCKED_HORIZONTAL, true); textureCacheDX9_->ForgetLastTexture(); dxstate.viewport.restore(); } @@ -296,10 +296,10 @@ static void DXSetViewport(float x, float y, float w, float h, float minZ, float int uvRotation = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE) ? g_Config.iInternalScreenRotation : ROTATION_LOCKED_HORIZONTAL; CenterDisplayOutputRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)pixelWidth_, (float)pixelHeight_, uvRotation); device_->SetTexture(0, drawPixelsTex_); - DrawActiveTexture(x, y, w, h, (float)pixelWidth_, (float)pixelHeight_, 0.0f, 0.0f, 480.0f / 512.0f, 1.0f, uvRotation); + DrawActiveTexture(x, y, w, h, (float)pixelWidth_, (float)pixelHeight_, 0.0f, 0.0f, 480.0f / 512.0f, 1.0f, uvRotation, true); } - void FramebufferManagerDX9::DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation) { + void FramebufferManagerDX9::DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, bool linearFilter) { // TODO: StretchRect instead? float coord[20] = { x,y,0, u0,v0, @@ -339,6 +339,13 @@ static void DXSetViewport(float x, float y, float w, float h, float minZ, float coord[i * 5 + 1] = -(coord[i * 5 + 1] * invDestH - 1.0f - halfPixelY); } + if (linearFilter) { + dxstate.texMagFilter.set(D3DTEXF_LINEAR); + dxstate.texMinFilter.set(D3DTEXF_LINEAR); + } else { + dxstate.texMagFilter.set(D3DTEXF_POINT); + dxstate.texMinFilter.set(D3DTEXF_POINT); + } pD3Ddevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); pD3Ddevice->SetVertexDeclaration(pFramebufferVertexDecl); pD3Ddevice->SetPixelShader(pFramebufferPixelShader); @@ -701,16 +708,9 @@ static void DXSetViewport(float x, float y, float w, float h, float minZ, float ERROR_LOG_REPORT_ONCE(blit_fail, G3D, "fbo_blit_color failed on display"); DXSetViewport(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight, 0.0f, 1.0f); // These are in the output display coordinates - if (g_Config.iBufFilter == SCALE_LINEAR) { - dxstate.texMagFilter.set(D3DTEXF_LINEAR); - dxstate.texMinFilter.set(D3DTEXF_LINEAR); - } else { - dxstate.texMagFilter.set(D3DTEXF_POINT); - dxstate.texMinFilter.set(D3DTEXF_POINT); - } dxstate.texMipFilter.set(D3DTEXF_NONE); dxstate.texMipLodBias.set(0); - DrawActiveTexture(x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, u0, v0, u1, v1, uvRotation); + DrawActiveTexture(x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, u0, v0, u1, v1, uvRotation, g_Config.iBufFilter == SCALE_LINEAR); } } /* diff --git a/GPU/Directx9/FramebufferDX9.h b/GPU/Directx9/FramebufferDX9.h index cac1144940..46ada05644 100644 --- a/GPU/Directx9/FramebufferDX9.h +++ b/GPU/Directx9/FramebufferDX9.h @@ -56,7 +56,7 @@ public: virtual void DrawPixels(VirtualFramebuffer *vfb, int dstX, int dstY, const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) override; virtual void DrawFramebufferToOutput(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, bool applyPostShader) override; - void DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation); + void DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, bool linearFilter) override; void DestroyAllFBOs(bool forceDelete); diff --git a/GPU/GLES/FramebufferManagerGLES.h b/GPU/GLES/FramebufferManagerGLES.h index 3cda24600b..c505835d6a 100644 --- a/GPU/GLES/FramebufferManagerGLES.h +++ b/GPU/GLES/FramebufferManagerGLES.h @@ -68,7 +68,7 @@ public: void DrawFramebufferToOutput(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, bool applyPostShader) override; // x,y,w,h are relative to destW, destH which fill out the target completely. - void DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, bool linearFilter); + void DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, bool linearFilter) override; void DestroyAllFBOs(bool forceDelete); diff --git a/GPU/Vulkan/FramebufferVulkan.cpp b/GPU/Vulkan/FramebufferVulkan.cpp index 92d62e98a8..411201af14 100644 --- a/GPU/Vulkan/FramebufferVulkan.cpp +++ b/GPU/Vulkan/FramebufferVulkan.cpp @@ -480,11 +480,12 @@ void FramebufferManagerVulkan::DrawFramebufferToOutput(const u8 *srcPixels, GEBu } } +void FramebufferManagerVulkan::DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, bool linearFilter) { + // TODO +} + // x, y, w, h are relative coordinates against destW/destH, which is not very intuitive. void FramebufferManagerVulkan::DrawTexture(VulkanTexture *texture, float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, VkPipeline pipeline, int uvRotation) { - if (!texture) - return; - float texCoords[8] = { u0,v0, u1,v0, diff --git a/GPU/Vulkan/FramebufferVulkan.h b/GPU/Vulkan/FramebufferVulkan.h index ae06e6413d..cb8cd69bff 100644 --- a/GPU/Vulkan/FramebufferVulkan.h +++ b/GPU/Vulkan/FramebufferVulkan.h @@ -77,6 +77,7 @@ public: // If texture != 0, will bind it. // x,y,w,h are relative to destW, destH which fill out the target completely. void DrawTexture(VulkanTexture *texture, float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, VkPipeline pipeline, int uvRotation); + void DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, bool linearFilter) override; void DestroyAllFBOs(bool forceDelete);