mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-08-31 17:55:23 +02:00
This is a leftover from the old "native" library. Its only users are the Win32 GE debugger's preview windows, which call glsl_create_source/destroy/bind/unbind and read four locations off the struct. Everything else was dead: glsl_create was declared but never defined anywhere, which made the entire file-loading and auto-reload half of glsl_recompile unreachable (glsl_create_source always passes empty filenames), along with the mtime fields, AutoCharArrayBuf and the VFS/stat includes. glsl_attrib_loc, glsl_uniform_loc and glsl_get_program had no callers, and the active_programs set was written and never read. The unused convenience locations cost a glGetUniformLocation round trip each at link time. The bug: the vertex shader was leaked when its own compile failed - the fragment path right below it already deleted it correctly. Failed links leaked the program object too. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vd8ntC2brCUtCrDJMqLbs8
36 lines
1.2 KiB
C++
36 lines
1.2 KiB
C++
// Utility code for loading GLSL shaders.
|
|
//
|
|
// This is a small leftover from the old "native" library, only used by the Win32 GE debugger's
|
|
// preview windows, which talk to GL directly rather than going through thin3d. Everything here
|
|
// works on shader source strings - the file loading and auto-reload support that used to live
|
|
// here was never used in PPSSPP and is gone.
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include "Common/GPU/OpenGL/GLCommon.h"
|
|
|
|
// Represent a compiled and linked vshader/fshader pair.
|
|
struct GLSLProgram {
|
|
// Locations of the uniforms and attributes the callers use, looked up once at link time.
|
|
// Add to these as needed - each one costs a lookup per link.
|
|
GLint sampler0;
|
|
GLint u_viewproj;
|
|
GLint a_position;
|
|
GLint a_texcoord0;
|
|
|
|
// Private to the implementation, do not touch
|
|
GLuint vsh_;
|
|
GLuint fsh_;
|
|
GLuint program_;
|
|
};
|
|
|
|
// Compiles and links a program. Returns nullptr on failure, having logged the reason and,
|
|
// if error_message is non-null, copied it there.
|
|
GLSLProgram *glsl_create_source(const char *vshader_src, const char *fshader_src, std::string *error_message = nullptr);
|
|
void glsl_destroy(GLSLProgram *program);
|
|
|
|
void glsl_bind(const GLSLProgram *program);
|
|
void glsl_unbind();
|