Remove glstate usage except in the GPU implementation. Prepare for moving it into PPSSPP.

This commit is contained in:
Henrik Rydgard 2015-09-06 12:23:14 +02:00
parent cfe4c033b9
commit 72ae497350
17 changed files with 31 additions and 67 deletions

View File

@ -33,9 +33,7 @@
#include "base/timeutil.h"
#include "profiler/profiler.h"
#ifndef _XBOX
#include "gfx_es2/gl_state.h"
#endif
#include "gfx_es2/gpu_features.h"
#include "Common/ChunkFile.h"
#include "Core/CoreTiming.h"

View File

@ -775,7 +775,7 @@ namespace DX9 {
fbo_bind_as_render_target(extraFBOs_[0]);
int fbo_w, fbo_h;
fbo_get_dimensions(extraFBOs_[0], &fbo_w, &fbo_h);
glstate.viewport.set(0, 0, fbo_w, fbo_h);
dxstate.viewport.set(0, 0, fbo_w, fbo_h);
DrawActiveTexture(colorTexture, 0, 0, fbo_w, fbo_h, fbo_w, fbo_h, true, 1.0f, 1.0f, postShaderProgram_);
fbo_unbind();
@ -787,12 +787,12 @@ namespace DX9 {
return;
}
colorTexture = fbo_get_color_texture(extraFBOs_[0]);
glstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
dxstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
// These are in the output display coordinates
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, 480.0f / (float)vfb->width, 272.0f / (float)vfb->height);
} else {
// Use post-shader, but run shader at output resolution.
glstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
dxstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
// These are in the output display coordinates
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, 480.0f / (float)vfb->width, 272.0f / (float)vfb->height, postShaderProgram_);
}

View File

@ -509,6 +509,11 @@ void DIRECTX9_GPU::BeginFrame() {
ScheduleEvent(GPU_EVENT_BEGIN_FRAME);
}
void DIRECTX9_GPU::ReapplyGfxStateInternal() {
DX9::dxstate.Restore();
GPUCommon::ReapplyGfxStateInternal();
}
void DIRECTX9_GPU::BeginFrameInternal() {
if (resized_) {
UpdateCmdInfo();

View File

@ -41,6 +41,7 @@ public:
void PreExecuteOp(u32 op, u32 diff) override;
void ExecuteOp(u32 op, u32 diff) override;
void ReapplyGfxStateInternal() override;
void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) override;
void CopyDisplayToOutput() override;
void BeginFrame() override;

View File

@ -678,6 +678,11 @@ void GLES_GPU::UpdateCmdInfo() {
}
}
void GLES_GPU::ReapplyGfxStateInternal() {
glstate.Restore();
GPUCommon::ReapplyGfxStateInternal();
}
void GLES_GPU::BeginFrameInternal() {
if (resized_) {
CheckGPUFeatures();

View File

@ -46,6 +46,7 @@ public:
void Execute_Generic(u32 op, u32 diff);
void ExecuteOp(u32 op, u32 diff) override;
void ReapplyGfxStateInternal() override;
void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) override;
void CopyDisplayToOutput() override;
void BeginFrame() override;

View File

@ -620,7 +620,6 @@ void GPUCommon::ReapplyGfxState() {
}
void GPUCommon::ReapplyGfxStateInternal() {
// ShaderManager_DirtyShader();
// The commands are embedded in the command memory so we can just reexecute the words. Convenient.
// To be safe we pass 0xFFFFFFFF as the diff.

View File

@ -133,7 +133,7 @@ protected:
void CheckDrawSync();
int GetNextListIndex();
void ProcessDLQueueInternal();
void ReapplyGfxStateInternal();
virtual void ReapplyGfxStateInternal();
virtual void FastLoadBoneMatrix(u32 target);
virtual void ProcessEvent(GPUEvent ev);
virtual bool ShouldExitEventLoop() {

View File

@ -29,7 +29,7 @@
#include "Core/MIPS/MIPS.h"
#include "Core/Reporting.h"
#include "gfx/gl_common.h"
#include "gfx_es2/gl_state.h"
// #include "gfx_es2/gl_state.h"
#include "profiler/profiler.h"
#include "GPU/Software/SoftGpu.h"
@ -187,9 +187,9 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight)
float dstwidth = (float)PSP_CoreParameter().pixelWidth;
float dstheight = (float)PSP_CoreParameter().pixelHeight;
glstate.blend.disable();
glstate.viewport.set(0, 0, dstwidth, dstheight);
glstate.scissorTest.disable();
glDisable(GL_BLEND);
glViewport(0, 0, dstwidth, dstheight);
glDisable(GL_SCISSOR_TEST);
glBindTexture(GL_TEXTURE_2D, temp_texture);
@ -275,8 +275,8 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight)
{texvert_u, 1}
};
glstate.arrayBuffer.unbind();
glstate.elementArrayBuffer.unbind();
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glVertexAttribPointer(attr_pos, 2, GL_FLOAT, GL_FALSE, 0, verts);
glVertexAttribPointer(attr_tex, 2, GL_FLOAT, GL_FALSE, 0, texverts);
glEnableVertexAttribArray(attr_pos);

View File

@ -18,7 +18,6 @@
#include <algorithm>
#include "base/compat.h"
#include "gfx_es2/gl_state.h"
#include "gfx_es2/gpu_features.h"
#include "i18n/i18n.h"
#include "ui/ui_context.h"

View File

@ -23,8 +23,7 @@
#include "base/timeutil.h"
#include "profiler/profiler.h"
#include "gfx_es2/glsl_program.h"
#include "gfx_es2/gl_state.h"
#include "gfx_es2/gpu_features.h"
#include "gfx_es2/draw_text.h"
#include "gfx_es2/fbo.h"

View File

@ -51,7 +51,6 @@
#include "base/timeutil.h"
#include "base/colorutil.h"
#include "gfx_es2/draw_buffer.h"
#include "gfx_es2/gl_state.h"
#include "util/random/rng.h"
#include "UI/ui_atlas.h"

View File

@ -48,8 +48,8 @@
#include "file/zip_read.h"
#include "thread/thread.h"
#include "net/http_client.h"
#include "gfx_es2/gl_state.h" // TODO: Get rid of this from here
#include "gfx_es2/draw_text.h"
#include "gfx_es2/gpu_features.h"
#include "gfx/gl_lost_manager.h"
#include "gfx/texture.h"
#include "i18n/i18n.h"
@ -85,9 +85,6 @@
#include "EmuScreen.h"
#include "GameInfoCache.h"
#include "HostTypes.h"
#ifdef _WIN32
#include "GPU/Directx9/helper/dx_state.h"
#endif
#include "UI/OnScreenDisplay.h"
#include "UI/MiscScreens.h"
#include "UI/TiltEventProcessor.h"
@ -571,11 +568,6 @@ void NativeInitGraphics() {
screenManager->setUIContext(uiContext);
screenManager->setThin3DContext(thin3d);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
#ifdef _WIN32
winAudioBackend = CreateAudioBackend((AudioBackendType)g_Config.iAudioBackend);
winAudioBackend->Init(MainWindow::GetHWND(), &Win32Mix, 44100);
@ -684,19 +676,6 @@ void NativeRender() {
viewport.MaxDepth = 1.0;
viewport.MinDepth = 0.0;
thin3d->SetViewports(1, &viewport);
if (g_Config.iGPUBackend == GPU_BACKEND_OPENGL) {
glstate.depthWrite.set(GL_TRUE);
glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glstate.Restore();
} else {
#ifdef _WIN32
DX9::dxstate.depthWrite.set(true);
DX9::dxstate.colorMask.set(true, true, true, true);
DX9::dxstate.Restore();
#endif
}
thin3d->SetTargetSize(pixel_xres, pixel_yres);
float xres = dp_xres;
@ -727,17 +706,6 @@ void NativeRender() {
TakeScreenshot();
}
thin3d->SetScissorEnabled(false);
if (g_Config.iGPUBackend == GPU_BACKEND_OPENGL) {
glstate.depthWrite.set(GL_TRUE);
glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
} else {
#ifdef _WIN32
DX9::dxstate.depthWrite.set(true);
DX9::dxstate.colorMask.set(true, true, true, true);
#endif
}
if (resized) {
resized = false;
if (g_Config.iGPUBackend == GPU_BACKEND_DIRECT3D9) {
@ -780,7 +748,6 @@ void NativeDeviceLost() {
if (g_Config.iGPUBackend == GPU_BACKEND_OPENGL) {
gl_lost();
glstate.Restore();
}
// Should dirty EVERYTHING
}

View File

@ -1,6 +1,6 @@
#include "Common/CommonWindows.h"
#include "native/gfx_es2/gl_state.h"
#include "native/gfx/gl_common.h"
#include "native/gfx_es2/gpu_features.h"
#include "GL/gl.h"
#include "GL/wglew.h"
#include "Core/Config.h"
@ -237,7 +237,6 @@ bool GL_Init(HWND window, std::string *error_message) {
return false;
}
if (!m_hrc) {
*error_message = "No m_hrc";
return false;
@ -245,7 +244,6 @@ bool GL_Init(HWND window, std::string *error_message) {
hRC = m_hrc;
glstate.Initialize();
if (wglSwapIntervalEXT)
wglSwapIntervalEXT(0);
if (enableGLDebug && glewIsSupported("GL_ARB_debug_output")) {

View File

@ -15,7 +15,6 @@
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
// TO USE:
// Simply copy pspautotests to the root of the USB memory / SD card of your android device.
// Then go to Settings / Developer Menu / Run CPU tests.
@ -29,7 +28,7 @@
#include "base/basictypes.h"
#include "base/display.h"
#include "base/logging.h"
#include "gfx_es2/gl_state.h"
#include "gfx/gl_common.h"
#include "Core/Core.h"
#include "Core/System.h"
@ -38,7 +37,6 @@
#include "Core/MIPS/MIPS.h"
#include "TestRunner.h"
static const char * const testsToRun[] = {
"cpu/cpu_alu/cpu_alu",
"cpu/fpu/fpu",
@ -153,8 +151,7 @@ void RunTests()
}
PSP_Shutdown();
}
glstate.Restore();
glstate.viewport.set(0,0,pixel_xres,pixel_yres);
glViewport(0,0,pixel_xres,pixel_yres);
PSP_CoreParameter().pixelWidth = pixel_xres;
PSP_CoreParameter().pixelHeight = pixel_yres;
PSP_CoreParameter().headLess = false;

View File

@ -28,7 +28,6 @@
#include "GPU/GPUState.h"
#include "base/logging.h"
#include "gfx_es2/gl_state.h"
#include "gfx/gl_common.h"
#include "file/vfs.h"
#include "file/zip_read.h"
@ -40,8 +39,7 @@ const int WINDOW_HEIGHT = 272;
typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALFARPROC)(int value);
PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT = NULL;
HWND CreateHiddenWindow()
{
HWND CreateHiddenWindow() {
static WNDCLASSEX wndClass = {
sizeof(WNDCLASSEX),
CS_HREDRAW | CS_VREDRAW | CS_OWNDC,
@ -187,7 +185,6 @@ bool WindowsHeadlessHost::InitGraphics(std::string *error_message)
SetVSync(0);
glewInit();
glstate.Initialize();
LoadNativeAssets();
@ -218,8 +215,7 @@ bool WindowsHeadlessHost::ResizeGL()
RECT rc;
GetWindowRect(hWnd, &rc);
glstate.viewport.set(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
glstate.viewport.restore();
glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0f, WINDOW_WIDTH, WINDOW_HEIGHT, 0.0f, -1.0f, 1.0f);

2
native

@ -1 +1 @@
Subproject commit e875f0a0c3932fb7b80846e78c318fa36b2b5c6f
Subproject commit 3f05c8d99031931149a072c64cae51eb5635202b