mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
(Partially) slip thin3d underneath DrawBuffer.
This commit is contained in:
parent
dfbb0bdea2
commit
808f05da89
14 changed files with 31 additions and 177 deletions
|
@ -747,7 +747,7 @@ bool KeyFromPspButton(int btn, std::vector<KeyDef> *keys) {
|
|||
|
||||
bool AxisToPspButton(int deviceId, int axisId, int direction, std::vector<int> *pspKeys) {
|
||||
int key = TranslateKeyCodeFromAxis(axisId, direction);
|
||||
return KeyToPspButton(deviceId, key, pspKeys);
|
||||
return KeyToPspButton(deviceId, key, pspKeys);
|
||||
}
|
||||
|
||||
bool AxisFromPspButton(int btn, int *deviceId, int *axisId, int *direction) {
|
||||
|
|
|
@ -185,6 +185,7 @@ void SaveFileInfo::DoState(PointerWrap &p)
|
|||
p.Do(hasTexture);
|
||||
if (hasTexture) {
|
||||
if (p.mode == p.MODE_READ) {
|
||||
delete texture;
|
||||
texture = new PPGeImage("");
|
||||
}
|
||||
texture->DoState(p);
|
||||
|
|
|
@ -316,7 +316,7 @@ MIPSOpcode JitBlockCache::GetEmuHackOpForBlock(int blockNum) const {
|
|||
}
|
||||
|
||||
int JitBlockCache::GetBlockNumberFromStartAddress(u32 addr, bool realBlocksOnly) {
|
||||
if (!blocks_)
|
||||
if (!blocks_ || !Memory::IsValidAddress(addr))
|
||||
return -1;
|
||||
|
||||
MIPSOpcode inst = MIPSOpcode(Memory::Read_U32(addr));
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include "Core/Config.h"
|
||||
#include "UI/ui_atlas.h"
|
||||
#include "UI/ControlMappingScreen.h"
|
||||
#include "UI/UIShader.h"
|
||||
#include "UI/GameSettingsScreen.h"
|
||||
|
||||
class ControlMapper : public UI::LinearLayout {
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "UI/OnScreenDisplay.h"
|
||||
#include "UI/ui_atlas.h"
|
||||
#include "UI/GamepadEmu.h"
|
||||
#include "UI/UIShader.h"
|
||||
|
||||
#include "UI/MainScreen.h"
|
||||
#include "UI/EmuScreen.h"
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
#include "UI/ui_atlas.h"
|
||||
#include "UI/OnScreenDisplay.h"
|
||||
#include "UI/GamepadEmu.h"
|
||||
#include "UI/UIShader.h"
|
||||
#include "UI/MainScreen.h"
|
||||
#include "UI/EmuScreen.h"
|
||||
#include "UI/DevScreens.h"
|
||||
|
@ -705,14 +704,14 @@ void EmuScreen::render() {
|
|||
if (useBufferedRendering)
|
||||
fbo_unbind();
|
||||
|
||||
UIShader_Prepare();
|
||||
|
||||
uiTexture->Bind(0);
|
||||
screenManager()->getUIContext()->RebindTexture();
|
||||
Thin3DContext *thin3d = screenManager()->getThin3DContext();
|
||||
|
||||
glstate.viewport.set(0, 0, pixel_xres, pixel_yres);
|
||||
glstate.viewport.restore();
|
||||
|
||||
ui_draw2d.Begin(UIShader_Get(), DBMODE_NORMAL);
|
||||
thin3d->SetBlendState(thin3d->GetBlendStatePreset(BS_STANDARD_ALPHA));
|
||||
ui_draw2d.Begin(thin3d->GetShaderSetPreset(SS_TEXTURE_COLOR_2D), DBMODE_NORMAL);
|
||||
|
||||
if (root_) {
|
||||
UI::LayoutViewHierarchy(*screenManager()->getUIContext(), root_);
|
||||
|
@ -757,7 +756,6 @@ void EmuScreen::render() {
|
|||
ui_draw2d.SetFontScale(1.0f, 1.0f);
|
||||
}
|
||||
|
||||
glsl_bind(UIShader_Get());
|
||||
ui_draw2d.End();
|
||||
ui_draw2d.Flush();
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "base/colorutil.h"
|
||||
#include "base/timeutil.h"
|
||||
#include "gfx_es2/draw_buffer.h"
|
||||
#include "gfx_es2/gl_state.h"
|
||||
#include "file/vfs.h"
|
||||
#include "math/curves.h"
|
||||
#include "i18n/i18n.h"
|
||||
|
@ -85,11 +84,8 @@ void DrawBackground(UIContext &dc, float alpha = 1.0f) {
|
|||
last_xres = xres;
|
||||
last_yres = yres;
|
||||
}
|
||||
|
||||
glstate.depthWrite.set(GL_TRUE);
|
||||
glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glClearColor(0.1f, 0.2f, 0.43f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
dc.GetThin3DContext()->Clear(T3DClear::COLOR | T3DClear::DEPTH | T3DClear::STENCIL, 0xff224477, 0.0, 0);
|
||||
int img = I_BG;
|
||||
#ifdef GOLD
|
||||
img = I_BG_GOLD;
|
||||
|
@ -396,15 +392,16 @@ bool LogoScreen::key(const KeyInput &key) {
|
|||
|
||||
void LogoScreen::render() {
|
||||
UIScreen::render();
|
||||
|
||||
UIContext &dc = *screenManager()->getUIContext();
|
||||
|
||||
int error = glGetError();
|
||||
const Bounds &bounds = dc.GetBounds();
|
||||
|
||||
float xres = dc.GetBounds().w;
|
||||
float yres = dc.GetBounds().h;
|
||||
|
||||
dc.Begin();
|
||||
error = glGetError();
|
||||
float t = (float)frames_ / 60.0f;
|
||||
|
||||
float alpha = t;
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include "math/fast/fast_math.h"
|
||||
#include "math/math_util.h"
|
||||
#include "math/lin/matrix4x4.h"
|
||||
#include "thin3d/thin3d.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/screen.h"
|
||||
#include "ui/ui_context.h"
|
||||
|
@ -80,7 +81,6 @@
|
|||
#include "ui_atlas.h"
|
||||
#include "EmuScreen.h"
|
||||
#include "GameInfoCache.h"
|
||||
#include "UIShader.h"
|
||||
#include "HostTypes.h"
|
||||
|
||||
#include "UI/OnScreenDisplay.h"
|
||||
|
@ -132,6 +132,7 @@ struct PendingMessage {
|
|||
|
||||
static recursive_mutex pendingMutex;
|
||||
static std::vector<PendingMessage> pendingMessages;
|
||||
static Thin3DContext *thin3d;
|
||||
static UIContext *uiContext;
|
||||
|
||||
std::thread *graphicsLoadThread;
|
||||
|
@ -463,12 +464,13 @@ void NativeInit(int argc, const char *argv[],
|
|||
void NativeInitGraphics() {
|
||||
FPU_SetFastMode();
|
||||
|
||||
thin3d = T3DCreateGLContext();
|
||||
|
||||
CheckGLExtensions();
|
||||
|
||||
ui_draw2d.SetAtlas(&ui_atlas);
|
||||
ui_draw2d_front.SetAtlas(&ui_atlas);
|
||||
|
||||
UIShader_Init();
|
||||
|
||||
// memset(&ui_theme, 0, sizeof(ui_theme));
|
||||
// New style theme
|
||||
#ifdef _WIN32
|
||||
|
@ -526,8 +528,8 @@ void NativeInitGraphics() {
|
|||
ui_theme.popupTitle.fgColor = 0xFF59BEE3;
|
||||
#endif
|
||||
|
||||
ui_draw2d.Init();
|
||||
ui_draw2d_front.Init();
|
||||
ui_draw2d.Init(thin3d);
|
||||
ui_draw2d_front.Init(thin3d);
|
||||
|
||||
uiTexture = new Texture();
|
||||
#ifdef USING_QT_UI
|
||||
|
@ -542,11 +544,13 @@ void NativeInitGraphics() {
|
|||
|
||||
uiContext = new UIContext();
|
||||
uiContext->theme = &ui_theme;
|
||||
uiContext->Init(UIShader_Get(), UIShader_GetPlain(), uiTexture, &ui_draw2d, &ui_draw2d_front);
|
||||
|
||||
uiContext->Init(thin3d, thin3d->GetShaderSetPreset(SS_TEXTURE_COLOR_2D), thin3d->GetShaderSetPreset(SS_COLOR_2D), uiTexture, &ui_draw2d, &ui_draw2d_front);
|
||||
if (uiContext->Text())
|
||||
uiContext->Text()->SetFont("Tahoma", 20, 0);
|
||||
|
||||
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);
|
||||
|
@ -576,7 +580,7 @@ void NativeShutdownGraphics() {
|
|||
ui_draw2d.Shutdown();
|
||||
ui_draw2d_front.Shutdown();
|
||||
|
||||
UIShader_Shutdown();
|
||||
thin3d->Release();
|
||||
}
|
||||
|
||||
void TakeScreenshot() {
|
||||
|
@ -688,8 +692,11 @@ void NativeRender() {
|
|||
Matrix4x4 ortho;
|
||||
ortho.setOrtho(0.0f, xres, yres, 0.0f, -1.0f, 1.0f);
|
||||
|
||||
glsl_bind(UIShader_Get());
|
||||
glUniformMatrix4fv(UIShader_Get()->u_worldviewproj, 1, GL_FALSE, ortho.getReadPtr());
|
||||
ui_draw2d.SetDrawMatrix(ortho);
|
||||
ui_draw2d_front.SetDrawMatrix(ortho);
|
||||
|
||||
|
||||
// glsl_bind(UIShader_Get());
|
||||
|
||||
screenManager->render();
|
||||
if (screenManager->getUIContext()->Text()) {
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
<ClCompile Include="TouchControlLayoutScreen.cpp" />
|
||||
<ClCompile Include="TouchControlVisibilityScreen.cpp" />
|
||||
<ClCompile Include="InstallZipScreen.cpp" />
|
||||
<ClCompile Include="UIShader.cpp" />
|
||||
<ClCompile Include="ui_atlas.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -60,7 +59,6 @@
|
|||
<ClInclude Include="TouchControlLayoutScreen.h" />
|
||||
<ClInclude Include="TouchControlVisibilityScreen.h" />
|
||||
<ClInclude Include="InstallZipScreen.h" />
|
||||
<ClInclude Include="UIShader.h" />
|
||||
<ClInclude Include="ui_atlas.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
|
@ -192,4 +190,4 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
|
@ -5,7 +5,6 @@
|
|||
<ClCompile Include="GamepadEmu.cpp" />
|
||||
<ClCompile Include="NativeApp.cpp" />
|
||||
<ClCompile Include="ui_atlas.cpp" />
|
||||
<ClCompile Include="UIShader.cpp" />
|
||||
<ClCompile Include="OnScreenDisplay.cpp" />
|
||||
<ClCompile Include="EmuScreen.cpp">
|
||||
<Filter>Screens</Filter>
|
||||
|
@ -53,7 +52,6 @@
|
|||
<ClInclude Include="GameInfoCache.h" />
|
||||
<ClInclude Include="GamepadEmu.h" />
|
||||
<ClInclude Include="ui_atlas.h" />
|
||||
<ClInclude Include="UIShader.h" />
|
||||
<ClInclude Include="OnScreenDisplay.h" />
|
||||
<ClInclude Include="EmuScreen.h">
|
||||
<Filter>Screens</Filter>
|
||||
|
|
113
UI/UIShader.cpp
113
UI/UIShader.cpp
|
@ -1,113 +0,0 @@
|
|||
// Copyright (c) 2012- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include "gfx_es2/glsl_program.h"
|
||||
#include "gfx_es2/gl_state.h"
|
||||
#include "UIShader.h"
|
||||
|
||||
static GLSLProgram *glslModulate;
|
||||
static GLSLProgram *glslPlain;
|
||||
|
||||
static const char modulate_fs[] =
|
||||
"#ifdef GL_ES\n"
|
||||
"precision lowp float;\n"
|
||||
"#endif\n"
|
||||
"uniform sampler2D sampler0;\n"
|
||||
"varying vec2 v_texcoord0;\n"
|
||||
"varying vec4 v_color;\n"
|
||||
"void main() {\n"
|
||||
" gl_FragColor = texture2D(sampler0, v_texcoord0) * v_color;\n"
|
||||
"}\n";
|
||||
|
||||
static const char modulate_vs[] =
|
||||
"attribute vec4 a_position;\n"
|
||||
"attribute vec4 a_color;\n"
|
||||
"attribute vec2 a_texcoord0;\n"
|
||||
"uniform mat4 u_worldviewproj;\n"
|
||||
"varying vec2 v_texcoord0;\n"
|
||||
"varying vec4 v_color;\n"
|
||||
"void main() {\n"
|
||||
" v_texcoord0 = a_texcoord0;\n"
|
||||
" v_color = a_color;\n"
|
||||
" gl_Position = u_worldviewproj * a_position;\n"
|
||||
"}\n";
|
||||
|
||||
static const char plain_fs[] =
|
||||
"#ifdef GL_ES\n"
|
||||
"precision lowp float;\n"
|
||||
"#endif\n"
|
||||
"varying vec4 v_color;\n"
|
||||
"void main() {\n"
|
||||
" gl_FragColor = v_color;\n"
|
||||
"}\n";
|
||||
|
||||
static const char plain_vs[] =
|
||||
"attribute vec4 a_position;\n"
|
||||
"attribute vec4 a_color;\n"
|
||||
"uniform mat4 u_worldviewproj;\n"
|
||||
"varying vec4 v_color;\n"
|
||||
"void main() {\n"
|
||||
" v_color = a_color;\n"
|
||||
" gl_Position = u_worldviewproj * a_position;\n"
|
||||
"}\n";
|
||||
|
||||
void UIShader_Init() {
|
||||
// Compile UI shaders
|
||||
glslModulate = glsl_create_source(modulate_vs, modulate_fs);
|
||||
glslPlain = glsl_create_source(plain_vs, plain_fs);
|
||||
}
|
||||
|
||||
GLSLProgram *UIShader_Get()
|
||||
{
|
||||
return glslModulate;
|
||||
}
|
||||
|
||||
|
||||
GLSLProgram *UIShader_GetPlain()
|
||||
{
|
||||
return glslPlain;
|
||||
}
|
||||
|
||||
void UIShader_Shutdown()
|
||||
{
|
||||
glsl_destroy(glslModulate);
|
||||
glsl_destroy(glslPlain);
|
||||
}
|
||||
|
||||
void UIShader_Prepare()
|
||||
{
|
||||
// Draw 2D overlay stuff
|
||||
glstate.cullFace.disable();
|
||||
glstate.depthTest.disable();
|
||||
glstate.scissorTest.disable();
|
||||
glstate.stencilTest.disable();
|
||||
glstate.stencilMask.set(0xFF);
|
||||
#if !defined(USING_GLES2)
|
||||
glstate.colorLogicOp.disable();
|
||||
#endif
|
||||
glstate.dither.enable();
|
||||
|
||||
glstate.blend.enable();
|
||||
glstate.blendFuncSeparate.set(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glstate.blendEquationSeparate.set(GL_FUNC_ADD, GL_FUNC_ADD);
|
||||
|
||||
glstate.depthWrite.set(GL_TRUE);
|
||||
glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glstate.Restore();
|
||||
|
||||
uiTexture->Bind(0);
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
// Copyright (c) 2012- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gfx_es2/glsl_program.h"
|
||||
#include "gfx/texture.h"
|
||||
|
||||
void UIShader_Init();
|
||||
GLSLProgram *UIShader_Get();
|
||||
GLSLProgram *UIShader_GetPlain(); // Just color
|
||||
void UIShader_Shutdown();
|
||||
|
||||
void UIShader_Prepare();
|
||||
|
||||
// TODO: Remove
|
||||
extern Texture *uiTexture;
|
|
@ -19,7 +19,7 @@ static HWND hWnd; // Holds Our Window Handle
|
|||
static int xres, yres;
|
||||
|
||||
// TODO: Make config?
|
||||
static bool enableGLDebug = false;
|
||||
static bool enableGLDebug = true;
|
||||
|
||||
void GL_SwapBuffers() {
|
||||
SwapBuffers(hDC);
|
||||
|
@ -71,6 +71,7 @@ void DebugCallbackARB(GLenum source, GLenum type, GLuint id, GLenum severity,
|
|||
FILE *outFile = (FILE*)userParam;
|
||||
char finalMessage[256];
|
||||
FormatDebugOutputARB(finalMessage, 256, source, type, id, severity, message);
|
||||
OutputDebugStringA(finalMessage);
|
||||
ERROR_LOG(G3D, "GL: %s", finalMessage);
|
||||
}
|
||||
|
||||
|
|
2
native
2
native
|
@ -1 +1 @@
|
|||
Subproject commit 2ba8e36b2bde65021c9a5c0f937a0e3892c2ad62
|
||||
Subproject commit ff5df25135423a06357d5e455be19acfec81663f
|
Loading…
Add table
Reference in a new issue