From d137251c4bb7f5bda118a66815994d891db54222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Wed, 24 Jan 2024 15:45:36 +0100 Subject: [PATCH] Mark everything in shaders as highp, switch to ES context --- Data/Base.rte/Shaders/Blit8.frag | 13 ++++++++----- Data/Base.rte/Shaders/Blit8.vert | 16 +++++++++------- Data/Base.rte/Shaders/PostProcess.frag | 13 ++++++++----- Data/Base.rte/Shaders/PostProcess.vert | 14 ++++++++------ Data/Base.rte/Shaders/ScreenBlit.frag | 13 ++++++++----- Data/Base.rte/Shaders/ScreenBlit.vert | 14 ++++++++------ Source/Managers/WindowMan.cpp | 4 ++-- 7 files changed, 51 insertions(+), 36 deletions(-) diff --git a/Data/Base.rte/Shaders/Blit8.frag b/Data/Base.rte/Shaders/Blit8.frag index a1b5e05aff..bb6d4e00b6 100644 --- a/Data/Base.rte/Shaders/Blit8.frag +++ b/Data/Base.rte/Shaders/Blit8.frag @@ -1,12 +1,15 @@ // Blit8.frag -#version 330 core +#version 300 es -in vec2 textureUV; +precision highp float; +precision highp sampler2D; -out vec4 FragColor; +in highp vec2 textureUV; -uniform sampler2D rteTexture; -uniform sampler2D rtePalette; +out highp vec4 FragColor; + +uniform highp sampler2D rteTexture; +uniform highp sampler2D rtePalette; void main() { float colorIndex = texture(rteTexture, vec2(textureUV.x, -textureUV.y)).r; diff --git a/Data/Base.rte/Shaders/Blit8.vert b/Data/Base.rte/Shaders/Blit8.vert index 652a81e18d..68f668d631 100644 --- a/Data/Base.rte/Shaders/Blit8.vert +++ b/Data/Base.rte/Shaders/Blit8.vert @@ -1,13 +1,15 @@ -#version 330 core +#version 300 es -layout(location = 0) in vec2 rteVertexPosition; -layout(location = 1) in vec2 rteTexUV; +precision highp float; -out vec2 textureUV; +layout(location = 0) in highp vec2 rteVertexPosition; +layout(location = 1) in highp vec2 rteTexUV; -uniform mat4 rteTransform; -uniform mat4 rteProjection; -uniform mat4 rteUVTransform; +out highp vec2 textureUV; + +uniform highp mat4 rteTransform; +uniform highp mat4 rteProjection; +uniform highp mat4 rteUVTransform; void main() { gl_Position = rteProjection * rteTransform * vec4(rteVertexPosition, 0.0, 1.0); diff --git a/Data/Base.rte/Shaders/PostProcess.frag b/Data/Base.rte/Shaders/PostProcess.frag index 56227308ea..cdb544191c 100644 --- a/Data/Base.rte/Shaders/PostProcess.frag +++ b/Data/Base.rte/Shaders/PostProcess.frag @@ -1,11 +1,14 @@ -#version 330 core +#version 300 es -in vec2 textureUV; +precision highp float; +precision highp sampler2D; -out vec4 FragColor; +in highp vec2 textureUV; -uniform sampler2D rteTexture; -uniform vec4 rteColor; +out highp vec4 FragColor; + +uniform highp sampler2D rteTexture; +uniform highp vec4 rteColor; void main() { FragColor = texture(rteTexture, textureUV) * rteColor; diff --git a/Data/Base.rte/Shaders/PostProcess.vert b/Data/Base.rte/Shaders/PostProcess.vert index ac9f28d0ef..6cc3005266 100644 --- a/Data/Base.rte/Shaders/PostProcess.vert +++ b/Data/Base.rte/Shaders/PostProcess.vert @@ -1,12 +1,14 @@ -#version 330 core +#version 300 es -layout(location = 0) in vec2 rteVertexPosition; -layout(location = 1) in vec2 rteTexUV; +precision highp float; -out vec2 textureUV; +layout(location = 0) in highp vec2 rteVertexPosition; +layout(location = 1) in highp vec2 rteTexUV; -uniform mat4 rteTransform; -uniform mat4 rteProjection; +out highp vec2 textureUV; + +uniform highp mat4 rteTransform; +uniform highp mat4 rteProjection; void main() { gl_Position = rteProjection * rteTransform * vec4(rteVertexPosition, 0.0, 1.0); diff --git a/Data/Base.rte/Shaders/ScreenBlit.frag b/Data/Base.rte/Shaders/ScreenBlit.frag index ef0376a56d..f4ba7c3908 100644 --- a/Data/Base.rte/Shaders/ScreenBlit.frag +++ b/Data/Base.rte/Shaders/ScreenBlit.frag @@ -1,11 +1,14 @@ -#version 330 core +#version 300 es -in vec2 textureUV; +precision highp float; +precision highp sampler2D; -out vec4 FragColor; +in highp vec2 textureUV; -uniform sampler2D rteTexture; -uniform sampler2D rteGUITexture; +out highp vec4 FragColor; + +uniform highp sampler2D rteTexture; +uniform highp sampler2D rteGUITexture; vec4 texture2DAA(sampler2D tex, vec2 uv) { vec2 texsize = vec2(textureSize(tex, 0)); diff --git a/Data/Base.rte/Shaders/ScreenBlit.vert b/Data/Base.rte/Shaders/ScreenBlit.vert index 8cb4be28c2..0e356d8347 100644 --- a/Data/Base.rte/Shaders/ScreenBlit.vert +++ b/Data/Base.rte/Shaders/ScreenBlit.vert @@ -1,12 +1,14 @@ -#version 330 core +#version 300 es -layout(location = 0) in vec2 rteVertexPosition; -layout(location = 1) in vec2 rteTexUV; +precision highp float; -out vec2 textureUV; +layout(location = 0) in highp vec2 rteVertexPosition; +layout(location = 1) in highp vec2 rteTexUV; -uniform mat4 rteTransform; -uniform mat4 rteProjection; +out highp vec2 textureUV; + +uniform highp mat4 rteTransform; +uniform highp mat4 rteProjection; void main() { gl_Position = rteProjection * rteTransform * vec4(rteVertexPosition.xy, 0.0, 1.0); diff --git a/Source/Managers/WindowMan.cpp b/Source/Managers/WindowMan.cpp index 54ab154857..5e019788d9 100644 --- a/Source/Managers/WindowMan.cpp +++ b/Source/Managers/WindowMan.cpp @@ -99,8 +99,8 @@ void WindowMan::Initialize() { SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); CreatePrimaryWindow(); InitializeOpenGL(); CreateBackBufferTexture();