mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-04-24 08:38:47 +00:00
GLES now uses gles_system.h
This commit is contained in:
parent
903f305763
commit
4677b9c365
23 changed files with 125 additions and 59 deletions
|
@ -786,6 +786,7 @@ set (VULKAN_SOURCES
|
|||
)
|
||||
|
||||
set (GLES_SOURCES
|
||||
common/rendering/gles/gles_system.cpp
|
||||
common/rendering/gles/gles_renderer.cpp
|
||||
common/rendering/gles/gles_stereo3d.cpp
|
||||
common/rendering/gles/gles_framebuffer.cpp
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "win32glvideo.h"
|
||||
|
||||
#include "gl_framebuffer.h"
|
||||
#include "gles_framebuffer.h"
|
||||
|
||||
extern "C" {
|
||||
HGLRC zd_wglCreateContext(HDC Arg1);
|
||||
|
@ -106,7 +107,7 @@ DFrameBuffer *Win32GLVideo::CreateFrameBuffer()
|
|||
{
|
||||
SystemGLFrameBuffer *fb;
|
||||
|
||||
fb = new OpenGLRenderer::OpenGLFrameBuffer(m_hMonitor, vid_fullscreen);
|
||||
fb = new OpenGLESRenderer::OpenGLFrameBuffer(m_hMonitor, vid_fullscreen);
|
||||
|
||||
fb->mPipelineNbr = gl_pipeline_depth;
|
||||
return fb;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
**/
|
||||
|
||||
#include <algorithm>
|
||||
#include "gl_load.h"
|
||||
#include "gles_system.h"
|
||||
#include "gles_buffers.h"
|
||||
#include "gles_renderstate.h"
|
||||
#include "v_video.h"
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*/
|
||||
|
||||
#include "templates.h"
|
||||
#include "gl_system.h"
|
||||
#include "gles_system.h"
|
||||
#include "gles_debug.h"
|
||||
#include "stats.h"
|
||||
#include "printf.h"
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#define __GL_DEBUG_H
|
||||
|
||||
#include <string.h>
|
||||
#include "gl_interface.h"
|
||||
#include "c_cvars.h"
|
||||
#include "v_video.h"
|
||||
|
||||
|
@ -20,7 +19,7 @@ public:
|
|||
static void PushGroup(const FString &name);
|
||||
static void PopGroup();
|
||||
|
||||
static bool HasDebugApi() { return (gl.flags & RFL_DEBUG) != 0; }
|
||||
static bool HasDebugApi() { return 0; }
|
||||
|
||||
private:
|
||||
void SetupBreakpointMode();
|
||||
|
|
|
@ -33,13 +33,12 @@
|
|||
**
|
||||
*/
|
||||
|
||||
#include "gl_system.h"
|
||||
#include "gles_system.h"
|
||||
#include "v_video.h"
|
||||
#include "m_png.h"
|
||||
#include "templates.h"
|
||||
#include "i_time.h"
|
||||
|
||||
#include "gl_interface.h"
|
||||
#include "gles_framebuffer.h"
|
||||
#include "gles_renderer.h"
|
||||
#include "gles_renderbuffers.h"
|
||||
|
@ -123,6 +122,8 @@ void OpenGLFrameBuffer::InitializeState()
|
|||
{
|
||||
static bool first=true;
|
||||
|
||||
InitGLES();
|
||||
|
||||
if (first)
|
||||
{
|
||||
if (ogl_LoadFunctions() == ogl_LOAD_FAILED)
|
||||
|
@ -134,11 +135,11 @@ void OpenGLFrameBuffer::InitializeState()
|
|||
gl_LoadExtensions();
|
||||
|
||||
// Move some state to the framebuffer object for easier access.
|
||||
hwcaps = gl.flags;
|
||||
glslversion = gl.glslversion;
|
||||
uniformblockalignment = gl.uniformblockalignment;
|
||||
maxuniformblock = gl.maxuniformblock;
|
||||
vendorstring = gl.vendorstring;
|
||||
hwcaps = gles.flags;
|
||||
glslversion = gles.glslversion;
|
||||
uniformblockalignment = gles.uniformblockalignment;
|
||||
maxuniformblock = gles.maxuniformblock;
|
||||
vendorstring = gles.vendorstring;
|
||||
|
||||
if (first)
|
||||
{
|
||||
|
@ -240,7 +241,7 @@ void OpenGLFrameBuffer::RenderTextureView(FCanvasTexture* tex, std::function<voi
|
|||
|
||||
const char* OpenGLFrameBuffer::DeviceName() const
|
||||
{
|
||||
return gl.modelstring;
|
||||
return gles.modelstring;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef __GL_FRAMEBUFFER
|
||||
#define __GL_FRAMEBUFFER
|
||||
#ifndef __GLES_FRAMEBUFFER
|
||||
#define __GLES_FRAMEBUFFER
|
||||
|
||||
#include "gl_sysfb.h"
|
||||
#include "m_png.h"
|
||||
|
|
|
@ -33,12 +33,11 @@
|
|||
**
|
||||
*/
|
||||
|
||||
#include "gl_system.h"
|
||||
#include "gles_system.h"
|
||||
#include "templates.h"
|
||||
#include "c_cvars.h"
|
||||
#include "hw_material.h"
|
||||
|
||||
#include "gl_interface.h"
|
||||
#include "hw_cvars.h"
|
||||
#include "gles_debug.h"
|
||||
#include "gles_renderer.h"
|
||||
|
|
|
@ -14,7 +14,7 @@ class FTexture;
|
|||
#define DIRECT_PALETTE -2
|
||||
|
||||
#include "tarray.h"
|
||||
#include "gl_interface.h"
|
||||
#include "gles_system.h"
|
||||
#include "hw_ihwtexture.h"
|
||||
|
||||
class FCanvasTexture;
|
||||
|
@ -30,7 +30,7 @@ public:
|
|||
|
||||
static int GetTexDimension(int value)
|
||||
{
|
||||
if (value > gl.max_texturesize) return gl.max_texturesize;
|
||||
if (value > gles.max_texturesize) return gles.max_texturesize;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
** 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "gl_system.h"
|
||||
#include "gles_system.h"
|
||||
#include "m_png.h"
|
||||
#include "gles_buffers.h"
|
||||
#include "gles_framebuffer.h"
|
||||
|
|
|
@ -20,8 +20,7 @@
|
|||
*/
|
||||
|
||||
#include "templates.h"
|
||||
#include "gl_system.h"
|
||||
#include "gl_interface.h"
|
||||
#include "gles_system.h"
|
||||
#include "gles_postprocessstate.h"
|
||||
|
||||
namespace OpenGLESRenderer
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#define __GL_POSTPROCESSSTATE_H
|
||||
|
||||
#include <string.h>
|
||||
#include "gl_interface.h"
|
||||
#include "matrix.h"
|
||||
#include "c_cvars.h"
|
||||
|
||||
|
|
|
@ -19,9 +19,8 @@
|
|||
** 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "gl_system.h"
|
||||
#include "gles_system.h"
|
||||
#include "v_video.h"
|
||||
#include "gl_interface.h"
|
||||
#include "printf.h"
|
||||
#include "hw_cvars.h"
|
||||
#include "gles_debug.h"
|
||||
|
@ -513,11 +512,7 @@ void FGLRenderBuffers::BlitSceneToTexture()
|
|||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mPipelineFB[mCurrentPipelineTexture].handle);
|
||||
glBlitFramebuffer(0, 0, mWidth, mHeight, 0, 0, mWidth, mHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
if ((gl.flags & RFL_INVALIDATE_BUFFER) != 0)
|
||||
{
|
||||
GLenum attachments[2] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_STENCIL_ATTACHMENT };
|
||||
glInvalidateFramebuffer(GL_READ_FRAMEBUFFER, 2, attachments);
|
||||
}
|
||||
|
||||
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
|
@ -537,11 +532,7 @@ void FGLRenderBuffers::BlitToEyeTexture(int eye, bool allowInvalidate)
|
|||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mEyeFBs[eye].handle);
|
||||
glBlitFramebuffer(0, 0, mWidth, mHeight, 0, 0, mWidth, mHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
if ((gl.flags & RFL_INVALIDATE_BUFFER) != 0 && allowInvalidate)
|
||||
{
|
||||
GLenum attachments[2] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_STENCIL_ATTACHMENT };
|
||||
glInvalidateFramebuffer(GL_READ_FRAMEBUFFER, 2, attachments);
|
||||
}
|
||||
|
||||
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
|
@ -555,11 +546,7 @@ void FGLRenderBuffers::BlitFromEyeTexture(int eye)
|
|||
glBindFramebuffer(GL_READ_FRAMEBUFFER, mEyeFBs[eye].handle);
|
||||
glBlitFramebuffer(0, 0, mWidth, mHeight, 0, 0, mWidth, mHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
if ((gl.flags & RFL_INVALIDATE_BUFFER) != 0)
|
||||
{
|
||||
GLenum attachments[2] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_STENCIL_ATTACHMENT };
|
||||
glInvalidateFramebuffer(GL_READ_FRAMEBUFFER, 2, attachments);
|
||||
}
|
||||
|
||||
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
**
|
||||
*/
|
||||
|
||||
#include "gl_system.h"
|
||||
#include "gles_system.h"
|
||||
#include "files.h"
|
||||
#include "v_video.h"
|
||||
#include "m_png.h"
|
||||
|
@ -40,7 +40,6 @@
|
|||
#include "i_time.h"
|
||||
#include "cmdlib.h"
|
||||
#include "version.h"
|
||||
#include "gl_interface.h"
|
||||
#include "gles_framebuffer.h"
|
||||
#include "hw_cvars.h"
|
||||
#include "gles_debug.h"
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
*/
|
||||
|
||||
#include "templates.h"
|
||||
#include "gl_system.h"
|
||||
#include "gl_interface.h"
|
||||
#include "gles_system.h"
|
||||
#include "hw_cvars.h"
|
||||
#include "flatvertices.h"
|
||||
#include "gles_shader.h"
|
||||
|
@ -489,7 +488,7 @@ void FGLRenderState::SetCulling(int mode)
|
|||
void FGLRenderState::EnableClipDistance(int num, bool state)
|
||||
{
|
||||
// Update the viewpoint-related clip plane setting.
|
||||
if (!(gl.flags & RFL_NO_CLIP_PLANES))
|
||||
if (!(gles.flags & RFL_NO_CLIP_PLANES))
|
||||
{
|
||||
ToggleState(GL_CLIP_DISTANCE0 + num, state);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <string.h>
|
||||
#include "gl_interface.h"
|
||||
#include "matrix.h"
|
||||
#include "hw_renderstate.h"
|
||||
#include "hw_material.h"
|
||||
|
|
|
@ -32,10 +32,9 @@
|
|||
**---------------------------------------------------------------------------
|
||||
**
|
||||
*/
|
||||
#include "gl_system.h"
|
||||
#include "gles_system.h"
|
||||
#include "c_cvars.h"
|
||||
|
||||
#include "gl_interface.h"
|
||||
#include "hw_cvars.h"
|
||||
#include "gles_debug.h"
|
||||
#include "gles_renderer.h"
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
**
|
||||
*/
|
||||
|
||||
#include "gl_system.h"
|
||||
#include "gles_system.h"
|
||||
#include "c_cvars.h"
|
||||
#include "v_video.h"
|
||||
#include "filesystem.h"
|
||||
|
@ -42,7 +42,6 @@
|
|||
#include "printf.h"
|
||||
#include "version.h"
|
||||
|
||||
#include "gl_interface.h"
|
||||
#include "gles_debug.h"
|
||||
#include "matrix.h"
|
||||
#include "gles_renderer.h"
|
||||
|
@ -376,16 +375,17 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
|||
else
|
||||
{
|
||||
// This differentiation is for Intel which do not seem to expose the full extension, even if marked as required.
|
||||
if (gl.glslversion < 4.3f)
|
||||
if (gles.glslversion < 4.3f)
|
||||
vp_comb = "#version 400 core\n#extension GL_ARB_shader_storage_buffer_object : require\n#define SHADER_STORAGE_LIGHTS\n";
|
||||
else
|
||||
vp_comb = "#version 430 core\n#define SHADER_STORAGE_LIGHTS\n";
|
||||
}
|
||||
|
||||
/*
|
||||
if (gl.flags & RFL_SHADER_STORAGE_BUFFER)
|
||||
{
|
||||
vp_comb << "#define SUPPORTS_SHADOWMAPS\n";
|
||||
}
|
||||
*/
|
||||
|
||||
FString fp_comb = vp_comb;
|
||||
vp_comb << defines << i_data.GetChars();
|
||||
|
@ -477,7 +477,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
|||
fp_comb << pp_data.GetString().GetChars() << "\n";
|
||||
}
|
||||
|
||||
if (gl.flags & RFL_NO_CLIP_PLANES)
|
||||
if (gles.flags & RFL_NO_CLIP_PLANES)
|
||||
{
|
||||
// On ATI's GL3 drivers we have to disable gl_ClipDistance because it's hopelessly broken.
|
||||
// This will cause some glitches and regressions but is the only way to avoid total display garbage.
|
||||
|
|
|
@ -19,9 +19,8 @@
|
|||
** 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "gl_system.h"
|
||||
#include "gles_system.h"
|
||||
#include "v_video.h"
|
||||
#include "gl_interface.h"
|
||||
#include "hw_cvars.h"
|
||||
#include "gles_debug.h"
|
||||
#include "gles_shaderprogram.h"
|
||||
|
@ -262,8 +261,8 @@ FString FShaderProgram::PatchShader(ShaderType type, const FString &code, const
|
|||
FString patchedCode;
|
||||
|
||||
// If we have 4.2, always use it because it adds important new syntax.
|
||||
if (maxGlslVersion < 420 && gl.glslversion >= 4.2f) maxGlslVersion = 420;
|
||||
int shaderVersion = std::min((int)round(gl.glslversion * 10) * 10, maxGlslVersion);
|
||||
if (maxGlslVersion < 420 && gles.glslversion >= 4.2f) maxGlslVersion = 420;
|
||||
int shaderVersion = std::min((int)round(gles.glslversion * 10) * 10, maxGlslVersion);
|
||||
patchedCode.AppendFormat("#version %d\n", shaderVersion);
|
||||
|
||||
// TODO: Find some way to add extension requirements to the patching
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "gl_system.h"
|
||||
#include "gles_system.h"
|
||||
#include "gles_shader.h"
|
||||
#include "hwrenderer/postprocessing/hw_postprocess.h"
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
**
|
||||
*/
|
||||
|
||||
#include "gl_system.h"
|
||||
#include "gles_system.h"
|
||||
#include "gles_renderer.h"
|
||||
#include "gles_renderbuffers.h"
|
||||
#include "hw_vrmodes.h"
|
||||
|
|
24
src/common/rendering/gles/gles_system.cpp
Normal file
24
src/common/rendering/gles/gles_system.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
|
||||
|
||||
#include "gles_system.h"
|
||||
|
||||
|
||||
namespace OpenGLESRenderer
|
||||
{
|
||||
|
||||
RenderContextGLES gles;
|
||||
|
||||
|
||||
void InitGLES()
|
||||
{
|
||||
gles.flags = 0;
|
||||
gles.glslversion = 3.31;
|
||||
gles.maxuniforms = 1024 * 16;
|
||||
gles.maxuniformblock = 1024 * 16;
|
||||
gles.uniformblockalignment = 256;
|
||||
gles.max_texturesize = 1024 * 4;
|
||||
gles.modelstring = (char*)"MODEL";
|
||||
gles.vendorstring = (char*)"EMILES";
|
||||
}
|
||||
|
||||
}
|
61
src/common/rendering/gles/gles_system.h
Normal file
61
src/common/rendering/gles/gles_system.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
#ifndef __GLES_SYSTEM_H
|
||||
#define __GLES_SYSTEM_H
|
||||
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <signal.h>
|
||||
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
//GL headers
|
||||
#include "gl_load/gl_load.h"
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <OpenGL/OpenGL.h>
|
||||
#endif
|
||||
|
||||
namespace OpenGLESRenderer
|
||||
{
|
||||
struct RenderContextGLES
|
||||
{
|
||||
unsigned int flags;
|
||||
unsigned int maxuniforms;
|
||||
unsigned int maxuniformblock;
|
||||
unsigned int uniformblockalignment;
|
||||
float glslversion;
|
||||
int max_texturesize;
|
||||
char* vendorstring;
|
||||
char* modelstring;
|
||||
};
|
||||
|
||||
extern RenderContextGLES gles;
|
||||
|
||||
void InitGLES();
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4244) // MIPS
|
||||
#pragma warning(disable : 4136) // X86
|
||||
#pragma warning(disable : 4051) // ALPHA
|
||||
|
||||
#pragma warning(disable : 4018) // signed/unsigned mismatch
|
||||
#pragma warning(disable : 4305) // truncate from double to float
|
||||
#endif
|
||||
|
||||
#endif //__GL_PCH_H
|
Loading…
Reference in a new issue