softgpu: Enable postshader support.

This commit is contained in:
Unknown W. Brackets 2020-05-10 18:19:35 -07:00
parent 0e5b17eb9c
commit 3aa8287b74
5 changed files with 45 additions and 3 deletions

View File

@ -612,4 +612,6 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u
DoRelease(srcFramebuffer_);
DoRelease(srcTexture_);
draw_->BindPipeline(nullptr);
}

View File

@ -120,6 +120,8 @@ static const D3DVERTEXELEMENT9 g_FramebufferVertexElements[] = {
}
FramebufferManagerDX9::~FramebufferManagerDX9() {
ShaderTranslationShutdown();
if (pFramebufferVertexShader) {
pFramebufferVertexShader->Release();
pFramebufferVertexShader = nullptr;

View File

@ -16,6 +16,7 @@
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "base/display.h"
#include "gfx_es2/gpu_features.h"
#include "GPU/GPUState.h"
#include "GPU/ge_constants.h"
@ -40,6 +41,7 @@
#include "GPU/Software/TransformUnit.h"
#include "GPU/Common/DrawEngineCommon.h"
#include "GPU/Common/PresentationCommon.h"
#include "GPU/Common/ShaderTranslation.h"
#include "GPU/Common/SplineCommon.h"
#include "GPU/Debugger/Debugger.h"
#include "GPU/Debugger/Record.h"
@ -67,6 +69,24 @@ SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
drawEngine_ = new SoftwareDrawEngine();
drawEngineCommon_ = drawEngine_;
presentation_ = new PresentationCommon(draw_);
switch (GetGPUBackend()) {
case GPUBackend::OPENGL:
presentation_->SetLanguage(gl_extensions.IsCoreContext ? GLSL_300 : GLSL_140);
break;
case GPUBackend::DIRECT3D9:
ShaderTranslationInit();
presentation_->SetLanguage(HLSL_DX9);
break;
case GPUBackend::DIRECT3D11:
ShaderTranslationInit();
presentation_->SetLanguage(HLSL_D3D11);
break;
case GPUBackend::VULKAN:
presentation_->SetLanguage(GLSL_VULKAN);
break;
}
Resized();
}
void SoftGPU::DeviceLost() {
@ -90,6 +110,15 @@ SoftGPU::~SoftGPU() {
}
delete presentation_;
switch (GetGPUBackend()) {
case GPUBackend::DIRECT3D9:
case GPUBackend::DIRECT3D11:
ShaderTranslationShutdown();
break;
case GPUBackend::OPENGL:
case GPUBackend::VULKAN:
break;
}
Sampler::Shutdown();
}
@ -235,11 +264,15 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) {
if (GetGPUBackend() == GPUBackend::VULKAN) {
std::swap(v0, v1);
}
if (GetGPUBackend() == GPUBackend::OPENGL) {
std::swap(v0, v1);
outputFlags |= OutputFlags::BACKBUFFER_FLIPPED;
}
// TODO, also deal with RB swizzle.
PostShaderUniforms uniforms{};
presentation_->CalculatePostShaderUniforms(desc.width, desc.height, false, &uniforms);
presentation_->UpdateSize(PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight, PSP_CoreParameter().renderWidth, PSP_CoreParameter().renderHeight);
presentation_->SourceTexture(fbTex);
presentation_->CopyToOutput(outputFlags, g_Config.iInternalScreenRotation, u0, v0, u1, v1, uniforms);
}
@ -248,7 +281,9 @@ void SoftGPU::CopyDisplayToOutput(bool reallyDirty) {
// The display always shows 480x272.
CopyToCurrentFboFromDisplayRam(FB_WIDTH, FB_HEIGHT);
framebufferDirty_ = false;
}
void SoftGPU::Resized() {
// Force the render params to 480x272 so other things work.
if (g_Config.IsPortrait()) {
PSP_CoreParameter().renderWidth = 272;
@ -257,6 +292,9 @@ void SoftGPU::CopyDisplayToOutput(bool reallyDirty) {
PSP_CoreParameter().renderWidth = 480;
PSP_CoreParameter().renderHeight = 272;
}
presentation_->UpdateSize(PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight, PSP_CoreParameter().renderWidth, PSP_CoreParameter().renderHeight);
presentation_->UpdatePostShader();
}
void SoftGPU::FastRunLoop(DisplayList &list) {

View File

@ -77,7 +77,7 @@ public:
void DeviceLost() override;
void DeviceRestore() override;
void Resized() override {}
void Resized() override;
void GetReportingInfo(std::string &primaryInfo, std::string &fullInfo) override {
primaryInfo = "Software";
fullInfo = "Software";

View File

@ -287,7 +287,7 @@ void GameSettingsScreen::CreateViews() {
postProcChoice_ = graphicsSettings->Add(new ChoiceWithValueDisplay(&g_Config.sPostShaderName, gr->T("Postprocessing Shader"), &PostShaderTranslateName));
postProcChoice_->OnClick.Handle(this, &GameSettingsScreen::OnPostProcShader);
postProcChoice_->SetEnabledFunc([] {
return !g_Config.bSoftwareRendering && g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
});
#if !defined(MOBILE_DEVICE)