diff --git a/renderdoc/CMakeLists.txt b/renderdoc/CMakeLists.txt index 16b3f8708..135df23e9 100644 --- a/renderdoc/CMakeLists.txt +++ b/renderdoc/CMakeLists.txt @@ -96,6 +96,7 @@ set(sources data/glsl/debuguniforms.h data/glsl/vk_texsample.h data/glsl/gl_texsample.h + data/glsl/gles_texsample.h data/glsl_shaders.cpp data/glsl_shaders.h hooks/hooks.cpp @@ -227,6 +228,7 @@ set(data data/glsl/quadwrite.frag data/glsl/texdisplay.frag data/glsl/gl_texsample.h + data/glsl/gles_texsample.h data/glsl/vk_texsample.h data/glsl/text.frag data/glsl/text.vert diff --git a/renderdoc/data/embedded_files.h b/renderdoc/data/embedded_files.h index cfada9df4..fad672010 100644 --- a/renderdoc/data/embedded_files.h +++ b/renderdoc/data/embedded_files.h @@ -55,5 +55,6 @@ DECLARE_EMBED(glsl_array2ms_comp); DECLARE_EMBED(glsl_ms2array_comp); DECLARE_EMBED(glsl_deptharr2ms_frag); DECLARE_EMBED(glsl_depthms2arr_frag); +DECLARE_EMBED(glsl_gles_texsample_h); #undef DECLARE_EMBED diff --git a/renderdoc/data/glsl/array2ms.comp b/renderdoc/data/glsl/array2ms.comp index efd1bc9ab..b7ead8ffc 100644 --- a/renderdoc/data/glsl/array2ms.comp +++ b/renderdoc/data/glsl/array2ms.comp @@ -22,7 +22,7 @@ * THE SOFTWARE. ******************************************************************************/ -//#extension GL_ARB_compute_shader : require +//#extension_nongles GL_ARB_compute_shader : require layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in; @@ -66,4 +66,4 @@ void main() uvec4 data = texelFetch(srcArray, ivec3(int(id.x), int(id.y), int(id.z)), 0); imageStore(dstMS, ivec3(int(id.x), int(id.y), slice), sampleIdx, data); -} \ No newline at end of file +} diff --git a/renderdoc/data/glsl/blit.vert b/renderdoc/data/glsl/blit.vert index 099ad7785..08823c320 100644 --- a/renderdoc/data/glsl/blit.vert +++ b/renderdoc/data/glsl/blit.vert @@ -22,11 +22,13 @@ * THE SOFTWARE. ******************************************************************************/ +#ifndef OPENGL_ES out gl_PerVertex { vec4 gl_Position; float gl_PointSize; }; +#endif layout (location = 0) out vec2 uv; diff --git a/renderdoc/data/glsl/checkerboard.frag b/renderdoc/data/glsl/checkerboard.frag index 41e0808b6..a8cf84483 100644 --- a/renderdoc/data/glsl/checkerboard.frag +++ b/renderdoc/data/glsl/checkerboard.frag @@ -32,11 +32,11 @@ layout (binding = 0, std140) uniform checkeruniforms void main(void) { - vec2 ab = mod(gl_FragCoord.xy, 128.0f.xx); + vec2 ab = mod(gl_FragCoord.xy, vec2(128.0f)); if( - (ab.x < 64 && ab.y < 64) || - (ab.x > 64 && ab.y > 64) + (ab.x < 64.0f && ab.y < 64.0f) || + (ab.x > 64.0f && ab.y > 64.0f) ) { color_out = vec4(checker.darkCol.rgb*checker.darkCol.rgb, 1); diff --git a/renderdoc/data/glsl/debuguniforms.h b/renderdoc/data/glsl/debuguniforms.h index fb73c1684..7512f7058 100644 --- a/renderdoc/data/glsl/debuguniforms.h +++ b/renderdoc/data/glsl/debuguniforms.h @@ -26,9 +26,11 @@ // classes that represent a whole cbuffer #if defined(__cplusplus) -#include "common/common.h" -#include "maths/matrix.h" -#include "maths/vec.h" +// The Android GL ES shader compiler does not supports the " character. +// The includes should be before this file is included! +//#include "common/common.h" +//#include "maths/matrix.h" +//#include "maths/vec.h" #define uniform struct #define vec2 Vec2f @@ -48,23 +50,19 @@ struct Vec4u #define uvec4 Vec4u #if !defined(VULKAN) && !defined(OPENGL) -#error "Must define VULKAN or OPENGL before including debuguniforms.h" +#error Must define VULKAN or OPENGL before including debuguniforms.h #endif #if defined(VULKAN) && defined(OPENGL) -#error "Only one of VULKAN and OPENGL must be defined in debuguniforms.h" +#error Only one of VULKAN and OPENGL must be defined in debuguniforms.h #endif #else -// this has to happen above even any pre-processor definitions, -// so it's added in code -//#version 430 core - // we require these extensions to be able to set explicit layout bindings, etc -//#extension GL_ARB_shading_language_420pack : require -//#extension GL_ARB_separate_shader_objects : require -//#extension GL_ARB_explicit_attrib_location : require +//#extension_nongles GL_ARB_shading_language_420pack : require +//#extension_nongles GL_ARB_separate_shader_objects : require +//#extension_nongles GL_ARB_explicit_attrib_location : require #ifdef VULKAN @@ -76,6 +74,10 @@ struct Vec4u #define OPENGL 1 +#ifdef GL_ES +#define OPENGL_ES 1 +#endif + #define BINDING(b) layout(binding = b, std140) #define VERTEX_ID gl_VertexID #define INSTANCE_ID gl_InstanceID @@ -84,6 +86,13 @@ struct Vec4u #define INST_NAME(name) name +#ifndef OPENGL_ES +#define PRECISION +#else +#define PRECISION mediump +precision PRECISION float; +#endif + #endif BINDING(2) uniform HistogramUBOData @@ -269,9 +278,34 @@ INST_NAME(texdisplay); #define HGRAM_NUM_BUCKETS 256u -#define MESH_OTHER 0 // this covers points and lines, logic is the same -#define MESH_TRIANGLE_LIST 1 -#define MESH_TRIANGLE_STRIP 2 -#define MESH_TRIANGLE_FAN 3 -#define MESH_TRIANGLE_LIST_ADJ 4 -#define MESH_TRIANGLE_STRIP_ADJ 5 +#define MESH_OTHER 0u // this covers points and lines, logic is the same +#define MESH_TRIANGLE_LIST 1u +#define MESH_TRIANGLE_STRIP 2u +#define MESH_TRIANGLE_FAN 3u +#define MESH_TRIANGLE_LIST_ADJ 4u +#define MESH_TRIANGLE_STRIP_ADJ 5u + +#if !defined(__cplusplus) + +vec3 CalcCubeCoord(vec2 uv, int face) +{ + // From table 8.19 in GL4.5 spec + // Map UVs to [-0.5, 0.5] and rotate + uv -= vec2(0.5); + vec3 coord; + if(face == CUBEMAP_FACE_POS_X) + coord = vec3(0.5, -uv.y, -uv.x); + else if(face == CUBEMAP_FACE_NEG_X) + coord = vec3(-0.5, -uv.y, uv.x); + else if(face == CUBEMAP_FACE_POS_Y) + coord = vec3(uv.x, 0.5, uv.y); + else if(face == CUBEMAP_FACE_NEG_Y) + coord = vec3(uv.x, -0.5, -uv.y); + else if(face == CUBEMAP_FACE_POS_Z) + coord = vec3(uv.x, -uv.y, 0.5); + else // face == CUBEMAP_FACE_NEG_Z + coord = vec3(-uv.x, -uv.y, -0.5); + return coord; +} + +#endif diff --git a/renderdoc/data/glsl/gl_texsample.h b/renderdoc/data/glsl/gl_texsample.h index 92cdb5327..13c4788f7 100644 --- a/renderdoc/data/glsl/gl_texsample.h +++ b/renderdoc/data/glsl/gl_texsample.h @@ -22,27 +22,6 @@ * THE SOFTWARE. ******************************************************************************/ -vec3 CalcCubeCoord(vec2 uv, int face) -{ - // From table 8.19 in GL4.5 spec - // Map UVs to [-0.5, 0.5] and rotate - uv -= vec2(0.5); - vec3 coord; - if(face == CUBEMAP_FACE_POS_X) - coord = vec3(0.5, -uv.y, -uv.x); - else if(face == CUBEMAP_FACE_NEG_X) - coord = vec3(-0.5, -uv.y, uv.x); - else if(face == CUBEMAP_FACE_POS_Y) - coord = vec3(uv.x, 0.5, uv.y); - else if(face == CUBEMAP_FACE_NEG_Y) - coord = vec3(uv.x, -0.5, -uv.y); - else if(face == CUBEMAP_FACE_POS_Z) - coord = vec3(uv.x, -uv.y, 0.5); - else // face == CUBEMAP_FACE_NEG_Z - coord = vec3(-uv.x, -uv.y, -0.5); - return coord; -} - // enable these extensions if possible //#extension GL_ARB_texture_cube_map_array : enable //#extension GL_ARB_texture_multisample : enable diff --git a/renderdoc/data/glsl/gles_texsample.h b/renderdoc/data/glsl/gles_texsample.h new file mode 100644 index 000000000..40871c90e --- /dev/null +++ b/renderdoc/data/glsl/gles_texsample.h @@ -0,0 +1,294 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2014-2017 Baldur Karlsson + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + +// enable these extensions if possible +//#extension GL_OES_texture_cube_map_array : enable +//#extension GL_EXT_texture_cube_map_array : enable + +#if __VERSION__ >= 310 +#define GLES_texture_multisample 1 +#endif + +#if defined(GL_OES_texture_cube_map_array) || defined(GL_EXT_texture_cube_map_array) +#define GLES_texture_cube_map_array 1 +#endif + +#if UINT_TEX + +// these bindings are defined based on the RESTYPE_ defines in debuguniforms.h + +// 1d = 1 +layout(binding = 2) uniform PRECISION usampler2D texUInt2D; +layout(binding = 3) uniform PRECISION usampler3D texUInt3D; +// cube = 4 +// 1d array = 5 +layout(binding = 6) uniform PRECISION usampler2DArray texUInt2DArray; +// cube array = 7 +// 2d rect = 8 +layout(binding = 9) uniform PRECISION usamplerBuffer texUIntBuffer; +#ifdef GLES_texture_multisample +layout(binding = 10) uniform PRECISION usampler2DMS texUInt2DMS; +#endif + +vec4 SampleTextureFloat4(int type, vec2 pos, float slice, int mipLevel, int sampleIdx, vec3 texRes) +{ + return vec4(0.0f, 0.0f, 0.0f, 0.0f); +} + +uvec4 SampleTextureUInt4(int type, vec2 pos, float slice, int mipLevel, int sampleIdx, vec3 texRes) +{ + uvec4 col; + if(type == RESTYPE_TEX2D) + { + col = texelFetch(texUInt2D, ivec2(pos * texRes.xy), mipLevel); + } + else if(type == RESTYPE_TEXBUFFER) + { + col = texelFetch(texUIntBuffer, int(pos.x * texRes.x)); + } + else if(type == RESTYPE_TEX2DMS) + { +#ifdef GLES_texture_multisample + if(sampleIdx < 0) + sampleIdx = 0; + + col = texelFetch(texUInt2DMS, ivec2(pos * texRes.xy), sampleIdx); +#else + col = uvec4(0u, 0u, 0u, 0u); +#endif + } + else if(type == RESTYPE_TEX2DARRAY) + { + col = texelFetch(texUInt2DArray, ivec3(pos * texRes.xy, slice), mipLevel); + } + else // if (type == RESTYPE_TEX3D) + { + col = texelFetch(texUInt3D, ivec3(pos * texRes.xy, slice), mipLevel); + } + + return col; +} + +ivec4 SampleTextureSInt4(int type, vec2 pos, float slice, int mipLevel, int sampleIdx, vec3 texRes) +{ + return ivec4(0, 0, 0, 0); +} + +#elif SINT_TEX + +// these bindings are defined based on the RESTYPE_ defines in debuguniforms.h + +// 1d = 1 +layout(binding = 2) uniform PRECISION isampler2D texSInt2D; +layout(binding = 3) uniform PRECISION isampler3D texSInt3D; +// cube = 4 +// 1d array = 5 +layout(binding = 6) uniform PRECISION isampler2DArray texSInt2DArray; +// cube array = 7 +// 2d rect = 8 +layout(binding = 9) uniform PRECISION isamplerBuffer texSIntBuffer; +#ifdef GLES_texture_multisample +layout(binding = 10) uniform PRECISION isampler2DMS texSInt2DMS; +#endif + +vec4 SampleTextureFloat4(int type, vec2 pos, float slice, int mipLevel, int sampleIdx, vec3 texRes) +{ + return vec4(0.0f, 0.0f, 0.0f, 0.0f); +} + +uvec4 SampleTextureUInt4(int type, vec2 pos, float slice, int mipLevel, int sampleIdx, vec3 texRes) +{ + return uvec4(0u, 0u, 0u, 0u); +} + +ivec4 SampleTextureSInt4(int type, vec2 pos, float slice, int mipLevel, int sampleIdx, vec3 texRes) +{ + ivec4 col; + if(type == RESTYPE_TEX2D) + { + col = texelFetch(texSInt2D, ivec2(pos * texRes.xy), mipLevel); + } + else if(type == RESTYPE_TEXBUFFER) + { + col = texelFetch(texSIntBuffer, int(pos.x * texRes.x)); + } + else if(type == RESTYPE_TEX2DMS) + { +#ifdef GLES_texture_multisample + if(sampleIdx < 0) + sampleIdx = 0; + + col = texelFetch(texSInt2DMS, ivec2(pos * texRes.xy), sampleIdx); +#else + col = ivec4(0, 0, 0, 0); +#endif + } + else if(type == RESTYPE_TEX2DARRAY) + { + col = texelFetch(texSInt2DArray, ivec3(pos * texRes.xy, slice), mipLevel); + } + else // if (type == RESTYPE_TEX3D) + { + col = texelFetch(texSInt3D, ivec3(pos * texRes.xy, slice), mipLevel); + } + + return col; +} + +#else + +// these bindings are defined based on the RESTYPE_ defines in debuguniforms.h + +// 1d = 1 +layout(binding = 2) uniform PRECISION sampler2D tex2D; +layout(binding = 3) uniform PRECISION sampler3D tex3D; +layout(binding = 4) uniform PRECISION samplerCube texCube; +// 1d array = 5 +layout(binding = 6) uniform PRECISION sampler2DArray tex2DArray; +#ifdef GLES_texture_cube_map_array +layout(binding = 7) uniform PRECISION samplerCubeArray texCubeArray; +#endif +// 2d rect = 8 +layout(binding = 9) uniform PRECISION samplerBuffer texBuffer; +#ifdef GLES_texture_multisample +layout(binding = 10) uniform PRECISION sampler2DMS tex2DMS; +#endif + +vec4 SampleTextureFloat4(int type, vec2 pos, float slice, int mipLevel, int sampleIdx, vec3 texRes) +{ + vec4 col; + if(type == RESTYPE_TEX2D) + { + col = textureLod(tex2D, pos, float(mipLevel)); + } + else if(type == RESTYPE_TEXBUFFER) + { + col = texelFetch(texBuffer, int(pos.x * texRes.x)); +#ifdef OPENGL_ES + // This hack is needed for an Android device to let the compiler optimize out the texBuffer, + // because otherwise due to some compiler bug the RESTYPE_TEX2D case won't work normally. + col = vec4(1.0f, 1.0f, 1.0f, 1.0f); +#endif + } + else if(type == RESTYPE_TEX2DMS) + { +#ifdef GLES_texture_multisample + if(sampleIdx < 0) + { + int sampleCount = -sampleIdx; + + // worst resolve you've seen in your life + // it's manually unrolled because doing it as a dynamic loop on + // sampleCount seems to produce crazy artifacts on nvidia - probably a compiler bug + if(sampleCount == 2) + { + col += 0.5f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 0); + col += 0.5f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 1); + } + else if(sampleCount == 4) + { + col += 0.25f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 0); + col += 0.25f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 1); + col += 0.25f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 2); + col += 0.25f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 3); + } + else if(sampleCount == 8) + { + col += 0.125f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 0); + col += 0.125f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 1); + col += 0.125f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 2); + col += 0.125f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 3); + col += 0.125f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 4); + col += 0.125f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 5); + col += 0.125f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 6); + col += 0.125f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 7); + } + else if(sampleCount == 16) + { + col += 0.0625f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 0); + col += 0.0625f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 1); + col += 0.0625f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 2); + col += 0.0625f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 3); + col += 0.0625f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 4); + col += 0.0625f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 5); + col += 0.0625f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 6); + col += 0.0625f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 7); + col += 0.0625f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 8); + col += 0.0625f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 9); + col += 0.0625f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 10); + col += 0.0625f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 11); + col += 0.0625f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 12); + col += 0.0625f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 13); + col += 0.0625f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 14); + col += 0.0625f * texelFetch(tex2DMS, ivec2(pos * texRes.xy), 15); + } + } + else + { + col = texelFetch(tex2DMS, ivec2(pos * texRes.xy), sampleIdx); + } +#else + col = vec4(0.0f, 0.0f, 0.0f, 0.0f); +#endif + } + else if(type == RESTYPE_TEX2DARRAY) + { + col = textureLod(tex2DArray, vec3(pos, slice), float(mipLevel)); + } + else if(type == RESTYPE_TEX3D) + { + col = textureLod(tex3D, vec3(pos, slice / texRes.z), float(mipLevel)); + } + else if(type == RESTYPE_TEXCUBE) + { + vec3 cubeCoord = CalcCubeCoord(pos, int(slice)); + + col = textureLod(texCube, cubeCoord, float(mipLevel)); + } + else // type == RESTYPE_TEXCUBEARRAY + { +#ifdef GLES_texture_cube_map_array + vec3 cubeCoord = CalcCubeCoord(pos, int(slice) % 6); + vec4 arrayCoord = vec4(cubeCoord, int(slice) / 6); + + col = textureLod(texCubeArray, arrayCoord, float(mipLevel)); +#else + col = vec4(0.0f, 0.0f, 0.0f, 0.0f); +#endif + } + + return col; +} + +uvec4 SampleTextureUInt4(int type, vec2 pos, float slice, int mipLevel, int sampleIdx, vec3 texRes) +{ + return uvec4(0u, 0u, 0u, 0u); +} + +ivec4 SampleTextureSInt4(int type, vec2 pos, float slice, int mipLevel, int sampleIdx, vec3 texRes) +{ + return ivec4(0, 0, 0, 0); +} + +#endif diff --git a/renderdoc/data/glsl/mesh.geom b/renderdoc/data/glsl/mesh.geom index 5c56a63d4..6723ab276 100644 --- a/renderdoc/data/glsl/mesh.geom +++ b/renderdoc/data/glsl/mesh.geom @@ -22,6 +22,10 @@ * THE SOFTWARE. ******************************************************************************/ +//#extension_gles GL_EXT_geometry_shader : enable +//#extension_gles GL_OES_geometry_shader : enable +//#extension_gles GL_EXT_geometry_point_size : enable + layout(triangles) in; layout(triangle_strip, max_vertices = 3) out; @@ -31,6 +35,7 @@ layout (location = 1) in vec4 IN_norm[3]; layout (location = 0) out vec4 OUT_secondary; layout (location = 1) out vec4 OUT_norm; +#ifndef OPENGL_ES in gl_PerVertex { vec4 gl_Position; @@ -42,6 +47,7 @@ out gl_PerVertex vec4 gl_Position; float gl_PointSize; }; +#endif void main() { diff --git a/renderdoc/data/glsl/mesh.vert b/renderdoc/data/glsl/mesh.vert index 72829ba6d..191433e19 100644 --- a/renderdoc/data/glsl/mesh.vert +++ b/renderdoc/data/glsl/mesh.vert @@ -25,24 +25,26 @@ layout (location = 0) in vec4 position; layout (location = 1) in vec4 IN_secondary; +#ifndef OPENGL_ES out gl_PerVertex { vec4 gl_Position; float gl_PointSize; }; +#endif layout (location = 0) out vec4 OUT_secondary; layout (location = 1) out vec4 norm; void main(void) { - vec2 psprite[4] = - { + vec2 psprite[4] = vec2[] + ( vec2(-1.0f, -1.0f), vec2(-1.0f, 1.0f), vec2( 1.0f, -1.0f), vec2( 1.0f, 1.0f) - }; + ); vec4 pos = position; if(Mesh.homogenousInput == 0u) diff --git a/renderdoc/data/glsl/ms2array.comp b/renderdoc/data/glsl/ms2array.comp index 379d205fe..d260c9499 100644 --- a/renderdoc/data/glsl/ms2array.comp +++ b/renderdoc/data/glsl/ms2array.comp @@ -22,7 +22,7 @@ * THE SOFTWARE. ******************************************************************************/ -//#extension GL_ARB_compute_shader : require +//#extension_nongles GL_ARB_compute_shader : require layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/renderdoc/data/glsl/outline.frag b/renderdoc/data/glsl/outline.frag index d009db1ac..e5fd8f43c 100644 --- a/renderdoc/data/glsl/outline.frag +++ b/renderdoc/data/glsl/outline.frag @@ -31,11 +31,11 @@ void main(void) vec2 rectPos = gl_FragCoord.xy - outline.ViewRect.xy; vec2 rectSize = outline.ViewRect.zw; - vec2 ab = mod(rectPos.xy, 32.0f.xx); + vec2 ab = mod(rectPos.xy, vec2(32.0f)); bool checkerVariant = ( - (ab.x < 16 && ab.y < 16) || - (ab.x > 16 && ab.y > 16) + (ab.x < 16.0f && ab.y < 16.0f) || + (ab.x > 16.0f && ab.y > 16.0f) ); if(outline.Scissor == 0u) diff --git a/renderdoc/data/glsl/quadresolve.frag b/renderdoc/data/glsl/quadresolve.frag index 20e027e33..c9375b216 100644 --- a/renderdoc/data/glsl/quadresolve.frag +++ b/renderdoc/data/glsl/quadresolve.frag @@ -22,7 +22,7 @@ * THE SOFTWARE. ******************************************************************************/ -//#extension GL_ARB_shader_image_load_store : require +//#extension_nongles GL_ARB_shader_image_load_store : require //////////////////////////////////////////////////////////////////////////////////////////// // Below shaders courtesy of Stephen Hill (@self_shadow), converted to glsl trivially @@ -31,7 +31,7 @@ // https://github.com/selfshadow/demos/blob/master/QuadShading/QuadShading.fx //////////////////////////////////////////////////////////////////////////////////////////// -layout(binding = 0, r32ui) uniform coherent uimage2DArray overdrawImage; +layout(binding = 0, r32ui) uniform PRECISION coherent uimage2DArray overdrawImage; #define NUM_RAMP_COLOURS 128 diff --git a/renderdoc/data/glsl/quadwrite.frag b/renderdoc/data/glsl/quadwrite.frag index c5a56fdd6..3402e974e 100644 --- a/renderdoc/data/glsl/quadwrite.frag +++ b/renderdoc/data/glsl/quadwrite.frag @@ -23,10 +23,14 @@ ******************************************************************************/ // outer code will hoist this up to just after the #version -//#extension GL_ARB_derivative_control : enable -//#extension GL_ARB_shader_image_load_store : require -//#extension GL_ARB_gpu_shader5 : require - + +//#extension_gles GL_OES_shader_image_atomic : enable +//#extension_gles GL_OES_sample_variables : enable +//#extension_nongles GL_ARB_derivative_control : enable +//#extension_nongles GL_ARB_shader_image_load_store : require +//#extension_nongles GL_ARB_gpu_shader5 : require + + //////////////////////////////////////////////////////////////////////////////////////////// // Below shaders courtesy of Stephen Hill (@self_shadow), converted to glsl trivially // @@ -37,8 +41,8 @@ #ifdef VULKAN // descriptor set will be patched from 0 to whichever descriptor set we're using in code layout(set = 0, binding = 0, r32ui) uniform coherent uimage2DArray overdrawImage; -#else // OPENGL -layout(binding = 0, r32ui) uniform coherent uimage2DArray overdrawImage; +#else // OPENGL and OPENGL_ES +layout(binding = 0, r32ui) uniform PRECISION coherent uimage2DArray overdrawImage; #endif layout(early_fragment_tests) in; @@ -51,12 +55,12 @@ void main() // "Shader Amortization using Pixel Quad Message Passing", Eric Penner, GPU Pro 2.) uvec2 p = uvec2(uint(gl_FragCoord.x) & 1u, uint(gl_FragCoord.y) & 1u); ivec2 sign = ivec2(p.x > 0u ? -1 : 1, p.y > 0u ? -1 : 1); - uint c1 = c0 + sign.x*int(dFdxFine(c0)); - uint c2 = c0 + sign.y*int(dFdyFine(c0)); - uint c3 = c2 + sign.x*int(dFdxFine(c2)); + uint c1 = c0 + uint(sign.x*int(dFdxFine(c0))); + uint c2 = c0 + uint(sign.y*int(dFdyFine(c0))); + uint c3 = c2 + uint(sign.x*int(dFdxFine(c2))); // Count the live pixels, minus 1 (zero indexing) - uint pixelCount = c0 + c1 + c2 + c3 - 1; + uint pixelCount = c0 + c1 + c2 + c3 - 1u; ivec3 quad = ivec3(gl_FragCoord.xy*0.5, pixelCount); imageAtomicAdd(overdrawImage, quad, 1); diff --git a/renderdoc/data/glsl/texdisplay.frag b/renderdoc/data/glsl/texdisplay.frag index 96f88fd65..6057d7b30 100644 --- a/renderdoc/data/glsl/texdisplay.frag +++ b/renderdoc/data/glsl/texdisplay.frag @@ -23,8 +23,14 @@ ******************************************************************************/ layout (location = 0) out vec4 color_out; +#ifdef OPENGL_ES +// Required otherwise the shader compiler could remove the 'uv' from the vertex shader also. +layout (location = 0) in vec2 uv; +#endif -//#extension GL_ARB_gpu_shader5 : enable +//#extension_gles GL_EXT_texture_cube_map_array : enable +//#extension_gles GL_EXT_texture_buffer : enable +//#extension_nongles GL_ARB_gpu_shader5 : enable //#include "texsample.h" // while includes aren't supported in glslang, this will be added in code @@ -183,41 +189,41 @@ void main(void) return; } - if(pre_range_col.r < 0 || pre_range_col.g < 0 || pre_range_col.b < 0 || pre_range_col.a < 0) + if(pre_range_col.r < 0.0f || pre_range_col.g < 0.0f || pre_range_col.b < 0.0f || pre_range_col.a < 0.0f) { color_out = vec4(0, 0, 1, 1); return; } - col = vec4(dot(col.xyz, vec3(0.2126, 0.7152, 0.0722)).xxx, 1); + col = vec4(vec3(dot(col.xyz, vec3(0.2126, 0.7152, 0.0722))), 1); } else if((texdisplay.OutputDisplayFormat & TEXDISPLAY_CLIPPING) > 0) { - if(col.r < 0 || col.g < 0 || col.b < 0 || col.a < 0) + if(col.r < 0.0f || col.g < 0.0f || col.b < 0.0f || col.a < 0.0f) { color_out = vec4(1, 0, 0, 1); return; } - if(col.r > (1+FLT_EPSILON) || col.g > (1+FLT_EPSILON) || col.b > (1+FLT_EPSILON) || col.a > (1+FLT_EPSILON)) + if(col.r > (1.0f+FLT_EPSILON) || col.g > (1.0f+FLT_EPSILON) || col.b > (1.0f+FLT_EPSILON) || col.a > (1.0f+FLT_EPSILON)) { color_out = vec4(0, 1, 0, 1); return; } - col = vec4(dot(col.xyz, vec3(0.2126, 0.7152, 0.0722)).xxx, 1); + col = vec4(vec3(dot(col.xyz, vec3(0.2126, 0.7152, 0.0722))), 1); } else { // if only one channel is selected - if(dot(texdisplay.Channels, 1.0f.xxxx) == 1.0f) + if(dot(texdisplay.Channels, vec4(1.0f)) == 1.0f) { // if it's alpha, just move it into rgb // otherwise, select the channel that's on and replicate it across all channels - if(texdisplay.Channels.a == 1) + if(texdisplay.Channels.a == 1.0f) col = vec4(col.aaa, 1); else - col = vec4(dot(col.rgb, 1.0f.xxx).xxx, 1.0f); + col = vec4(vec3(dot(col.rgb, vec3(1.0f))), 1.0f); } } diff --git a/renderdoc/data/glsl/text.frag b/renderdoc/data/glsl/text.frag index 1daeb7957..9c70a8b70 100644 --- a/renderdoc/data/glsl/text.frag +++ b/renderdoc/data/glsl/text.frag @@ -34,7 +34,7 @@ layout (location = 1) in vec2 glyphuv; void main(void) { - float text = 0; + float text = 0.0f; if(glyphuv.x >= 0.0f && glyphuv.x <= 1.0f && glyphuv.y >= 0.0f && glyphuv.y <= 1.0f) @@ -45,5 +45,5 @@ void main(void) text = texture(tex0, uv.xy).x; } - color_out = vec4(text.xxx, clamp(text + 0.5f, 0.0f, 1.0f)); + color_out = vec4(vec3(text), clamp(text + 0.5f, 0.0f, 1.0f)); } diff --git a/renderdoc/data/glsl/text.vert b/renderdoc/data/glsl/text.vert index 8358cd44e..757ddaf48 100644 --- a/renderdoc/data/glsl/text.vert +++ b/renderdoc/data/glsl/text.vert @@ -22,11 +22,13 @@ * THE SOFTWARE. ******************************************************************************/ +#ifndef OPENGL_ES out gl_PerVertex { vec4 gl_Position; float gl_PointSize; }; +#endif layout (location = 0) out vec4 tex; layout (location = 1) out vec2 glyphuv; @@ -46,7 +48,7 @@ void main(void) vec3 pos = verts[vert]; uint strindex = uint(VERTEX_ID)/6u; - vec2 charPos = vec2(strindex + pos.x + general.TextPosition.x, pos.y + general.TextPosition.y); + vec2 charPos = vec2(float(strindex) + pos.x + general.TextPosition.x, pos.y + general.TextPosition.y); FontGlyphData G = glyphs.data[ str.chars[strindex].x ]; diff --git a/renderdoc/data/glsl/trisize.geom b/renderdoc/data/glsl/trisize.geom index b2f0b31a4..1775d5eb8 100644 --- a/renderdoc/data/glsl/trisize.geom +++ b/renderdoc/data/glsl/trisize.geom @@ -22,6 +22,9 @@ * THE SOFTWARE. ******************************************************************************/ +//#extension_gles GL_EXT_geometry_shader : enable +//#extension_gles GL_OES_geometry_shader : enable + layout(triangles) in; layout(triangle_strip, max_vertices = 3) out; @@ -30,6 +33,7 @@ layout (location = 1) in vec4 IN_norm[3]; layout (location = 0) out float OUT_pixarea; +#ifndef OPENGL_ES in gl_PerVertex { vec4 gl_Position; @@ -41,6 +45,7 @@ out gl_PerVertex vec4 gl_Position; float gl_PointSize; }; +#endif layout(binding = 2) uniform ViewportSizeUBO { diff --git a/renderdoc/data/glsl_shaders.cpp b/renderdoc/data/glsl_shaders.cpp index 2f7b8ed36..2e8704374 100644 --- a/renderdoc/data/glsl_shaders.cpp +++ b/renderdoc/data/glsl_shaders.cpp @@ -30,7 +30,8 @@ void GenerateGLSLShader(std::vector &sources, ShaderType type, bool uniforms) { sources.resize(4); - sources[0] = StringFormat::Fmt("#version %d core\n", version); + sources[0] = + StringFormat::Fmt("#version %d %s\n", version, type == eShaderGLSLES ? "es" : "core"); if(uniforms) sources[1] = GetEmbeddedResource(glsl_debuguniforms_h); @@ -43,6 +44,8 @@ void GenerateGLSLShader(std::vector &sources, ShaderType type, sources[2] = GetEmbeddedResource(glsl_vk_texsample_h); else if(type == eShaderGLSL) sources[2] = GetEmbeddedResource(glsl_gl_texsample_h); + else if(type == eShaderGLSLES) + sources[2] = GetEmbeddedResource(glsl_gles_texsample_h); else RDCERR("Unknown type! %d", type); } @@ -67,7 +70,24 @@ void GenerateGLSLShader(std::vector &sources, ShaderType type, size_t begin = extsearch; extsearch = sources[i].find('\n', extsearch); - sources[0] += sources[i].substr(begin, extsearch - begin + 1); + string ext = sources[i].substr(begin, extsearch - begin + 1); + + if(ext.find("#extension_gles") == 0) + { + if(type != eShaderGLSLES) + continue; + + ext.erase(ext.find("_gles"), 5); + } + else if(ext.find("#extension_nongles") == 0) + { + if(type == eShaderGLSLES) + continue; + + ext.erase(ext.find("_nongles"), 8); + } + + sources[0] += ext; } while(extsearch != string::npos); } diff --git a/renderdoc/data/glsl_shaders.h b/renderdoc/data/glsl_shaders.h index 97a98df3e..2e2c7a54f 100644 --- a/renderdoc/data/glsl_shaders.h +++ b/renderdoc/data/glsl_shaders.h @@ -25,6 +25,7 @@ enum ShaderType { eShaderGLSL, + eShaderGLSLES, eShaderVulkan }; diff --git a/renderdoc/data/renderdoc.rc b/renderdoc/data/renderdoc.rc index 7062830f0..52dce1208 100644 --- a/renderdoc/data/renderdoc.rc +++ b/renderdoc/data/renderdoc.rc @@ -137,6 +137,7 @@ RESOURCE_glsl_trisize_geom TYPE_EMBED "glsl/trisize.geom" RESOURCE_glsl_trisize_frag TYPE_EMBED "glsl/trisize.frag" RESOURCE_glsl_deptharr2ms_frag TYPE_EMBED "glsl/deptharr2ms.frag" RESOURCE_glsl_depthms2arr_frag TYPE_EMBED "glsl/depthms2arr.frag" +RESOURCE_glsl_gles_texsample_h TYPE_EMBED "glsl/gles_texsample.h" #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// diff --git a/renderdoc/data/resource.h b/renderdoc/data/resource.h index 13f95e7d2..52dd3ba0f 100644 --- a/renderdoc/data/resource.h +++ b/renderdoc/data/resource.h @@ -39,6 +39,7 @@ #define RESOURCE_glsl_trisize_frag 425 #define RESOURCE_glsl_deptharr2ms_frag 426 #define RESOURCE_glsl_depthms2arr_frag 427 +#define RESOURCE_glsl_gles_texsample_h 428 //#define RENDERDOC_OFFICIAL_BUILD // used to determine whether to submit auto crash reports diff --git a/renderdoc/driver/gl/gl_debug.cpp b/renderdoc/driver/gl/gl_debug.cpp index eb0501545..dfc312e81 100644 --- a/renderdoc/driver/gl/gl_debug.cpp +++ b/renderdoc/driver/gl/gl_debug.cpp @@ -262,7 +262,27 @@ void GLReplay::InitDebugData() vector gs; vector cs; - GenerateGLSLShader(vs, eShaderGLSL, "", GetEmbeddedResource(glsl_blit_vert), 150); + int glslVersion; + int glslBaseVer; + int glslCSVer; // compute shader + ShaderType shaderType; + + if(m_pDriver->isGLESMode()) + { + glslVersion = glslBaseVer = glslCSVer = 310; + shaderType = eShaderGLSLES; + } + else + { + glslVersion = glslBaseVer = 150; + glslCSVer = 420; + shaderType = eShaderGLSL; + } + + // TODO In case of GLES some currently unused shaders, which are guarded by HasExt[..] checks, + // still contain compile errors (e.g. array2ms.comp, ms2array.comp, quad*, etc.). + + GenerateGLSLShader(vs, shaderType, "", GetEmbeddedResource(glsl_blit_vert), glslBaseVer); DebugData.texDisplayVSProg = CreateShaderProgram(vs, empty); @@ -271,16 +291,15 @@ void GLReplay::InitDebugData() string defines = string("#define UINT_TEX ") + (i == 1 ? "1" : "0") + "\n"; defines += string("#define SINT_TEX ") + (i == 2 ? "1" : "0") + "\n"; - GenerateGLSLShader(fs, eShaderGLSL, defines, GetEmbeddedResource(glsl_texdisplay_frag), 150); + GenerateGLSLShader(fs, shaderType, defines, GetEmbeddedResource(glsl_texdisplay_frag), + glslBaseVer); DebugData.texDisplayProg[i] = CreateShaderProgram(empty, fs); } RenderDoc::Inst().SetProgress(DebugManagerInit, 0.2f); - int glslVersion = 150; - - if(GLCoreVersion >= 43) + if(GLCoreVersion >= 43 && !m_pDriver->isGLESMode()) // TODO gles { GLint numsl = 0; gl.glGetIntegerv(eGL_NUM_SHADING_LANGUAGE_VERSIONS, &numsl); @@ -303,7 +322,7 @@ void GLReplay::InitDebugData() RDCLOG("GLSL version %d", glslVersion); - GenerateGLSLShader(vs, eShaderGLSL, "", GetEmbeddedResource(glsl_blit_vert), 150); + GenerateGLSLShader(vs, shaderType, "", GetEmbeddedResource(glsl_blit_vert), glslBaseVer); if(HasExt[ARB_shader_image_load_store] && HasExt[ARB_gpu_shader5]) { @@ -322,12 +341,12 @@ void GLReplay::InitDebugData() "Quad overdraw requires GLSL 4.50 for dFd(xy)fine, using possibly coarse dFd(xy)."); } - GenerateGLSLShader(fs, eShaderGLSL, defines, GetEmbeddedResource(glsl_quadwrite_frag), + GenerateGLSLShader(fs, shaderType, defines, GetEmbeddedResource(glsl_quadwrite_frag), RDCMIN(450, glslVersion)); DebugData.quadoverdrawFSProg = CreateShaderProgram(empty, fs); - GenerateGLSLShader(fs, eShaderGLSL, "", GetEmbeddedResource(glsl_quadresolve_frag), 150); + GenerateGLSLShader(fs, shaderType, "", GetEmbeddedResource(glsl_quadresolve_frag), glslBaseVer); DebugData.quadoverdrawResolveProg = CreateShaderProgram(vs, fs); } @@ -344,22 +363,22 @@ void GLReplay::InitDebugData() DebugData.quadoverdrawResolveProg = 0; } - GenerateGLSLShader(fs, eShaderGLSL, "", GetEmbeddedResource(glsl_checkerboard_frag), 150); + GenerateGLSLShader(fs, shaderType, "", GetEmbeddedResource(glsl_checkerboard_frag), glslBaseVer); DebugData.checkerProg = CreateShaderProgram(vs, fs); - GenerateGLSLShader(fs, eShaderGLSL, "", GetEmbeddedResource(glsl_fixedcol_frag), 150); + GenerateGLSLShader(fs, shaderType, "", GetEmbeddedResource(glsl_fixedcol_frag), glslBaseVer); DebugData.fixedcolFSProg = CreateShaderProgram(empty, fs); - GenerateGLSLShader(vs, eShaderGLSL, "", GetEmbeddedResource(glsl_mesh_vert), 150); - GenerateGLSLShader(fs, eShaderGLSL, "", GetEmbeddedResource(glsl_mesh_frag), 150); - GenerateGLSLShader(gs, eShaderGLSL, "", GetEmbeddedResource(glsl_mesh_geom), 150); + GenerateGLSLShader(vs, shaderType, "", GetEmbeddedResource(glsl_mesh_vert), glslBaseVer); + GenerateGLSLShader(fs, shaderType, "", GetEmbeddedResource(glsl_mesh_frag), glslBaseVer); + GenerateGLSLShader(gs, shaderType, "", GetEmbeddedResource(glsl_mesh_geom), glslBaseVer); DebugData.meshProg = CreateShaderProgram(vs, fs); DebugData.meshgsProg = CreateShaderProgram(vs, fs, gs); - GenerateGLSLShader(fs, eShaderGLSL, "", GetEmbeddedResource(glsl_trisize_frag), 150); - GenerateGLSLShader(gs, eShaderGLSL, "", GetEmbeddedResource(glsl_trisize_geom), 150); + GenerateGLSLShader(fs, shaderType, "", GetEmbeddedResource(glsl_trisize_frag), glslBaseVer); + GenerateGLSLShader(gs, shaderType, "", GetEmbeddedResource(glsl_trisize_geom), glslBaseVer); DebugData.trisizeProg = CreateShaderProgram(vs, fs, gs); @@ -454,8 +473,8 @@ void GLReplay::InitDebugData() defines += string("#define UINT_TEX ") + (i == 1 ? "1" : "0") + "\n"; defines += string("#define SINT_TEX ") + (i == 2 ? "1" : "0") + "\n"; - GenerateGLSLShader(cs, eShaderGLSL, defines, GetEmbeddedResource(glsl_minmaxtile_comp), - 420); + GenerateGLSLShader(cs, shaderType, defines, GetEmbeddedResource(glsl_minmaxtile_comp), + glslCSVer); DebugData.minmaxTileProgram[idx] = CreateCShaderProgram(cs); } @@ -466,7 +485,8 @@ void GLReplay::InitDebugData() defines += string("#define UINT_TEX ") + (i == 1 ? "1" : "0") + "\n"; defines += string("#define SINT_TEX ") + (i == 2 ? "1" : "0") + "\n"; - GenerateGLSLShader(cs, eShaderGLSL, defines, GetEmbeddedResource(glsl_histogram_comp), 420); + GenerateGLSLShader(cs, shaderType, defines, GetEmbeddedResource(glsl_histogram_comp), + glslCSVer); DebugData.histogramProgram[idx] = CreateCShaderProgram(cs); } @@ -478,8 +498,8 @@ void GLReplay::InitDebugData() defines += string("#define UINT_TEX ") + (i == 1 ? "1" : "0") + "\n"; defines += string("#define SINT_TEX ") + (i == 2 ? "1" : "0") + "\n"; - GenerateGLSLShader(cs, eShaderGLSL, defines, GetEmbeddedResource(glsl_minmaxresult_comp), - 420); + GenerateGLSLShader(cs, shaderType, defines, GetEmbeddedResource(glsl_minmaxresult_comp), + glslCSVer); DebugData.minmaxResultProgram[i] = CreateCShaderProgram(cs); } @@ -513,10 +533,10 @@ void GLReplay::InitDebugData() if(HasExt[ARB_compute_shader]) { - GenerateGLSLShader(cs, eShaderGLSL, "", GetEmbeddedResource(glsl_ms2array_comp), 420); + GenerateGLSLShader(cs, shaderType, "", GetEmbeddedResource(glsl_ms2array_comp), glslCSVer); DebugData.MS2Array = CreateCShaderProgram(cs); - GenerateGLSLShader(cs, eShaderGLSL, "", GetEmbeddedResource(glsl_array2ms_comp), 420); + GenerateGLSLShader(cs, shaderType, "", GetEmbeddedResource(glsl_array2ms_comp), glslCSVer); DebugData.Array2MS = CreateCShaderProgram(cs); } else @@ -534,7 +554,7 @@ void GLReplay::InitDebugData() string defines = "#extension GL_ARB_compute_shader : require\n" "#extension GL_ARB_shader_storage_buffer_object : require"; - GenerateGLSLShader(cs, eShaderGLSL, defines, GetEmbeddedResource(glsl_mesh_comp), 420); + GenerateGLSLShader(cs, shaderType, defines, GetEmbeddedResource(glsl_mesh_comp), glslCSVer); DebugData.meshPickProgram = CreateCShaderProgram(cs); } else @@ -617,8 +637,8 @@ void GLReplay::InitDebugData() gl.glVertexAttribPointer(0, 4, eGL_FLOAT, GL_FALSE, sizeof(Vec4f), NULL); gl.glEnableVertexAttribArray(0); - GenerateGLSLShader(vs, eShaderGLSL, "", GetEmbeddedResource(glsl_blit_vert), 150); - GenerateGLSLShader(fs, eShaderGLSL, "", GetEmbeddedResource(glsl_outline_frag), 150); + GenerateGLSLShader(vs, shaderType, "", GetEmbeddedResource(glsl_blit_vert), glslBaseVer); + GenerateGLSLShader(fs, shaderType, "", GetEmbeddedResource(glsl_outline_frag), glslBaseVer); DebugData.outlineQuadProg = CreateShaderProgram(vs, fs); diff --git a/renderdoc/driver/gl/gl_driver.cpp b/renderdoc/driver/gl/gl_driver.cpp index 14d53e5a1..6348cfb30 100644 --- a/renderdoc/driver/gl/gl_driver.cpp +++ b/renderdoc/driver/gl/gl_driver.cpp @@ -29,6 +29,7 @@ #include "data/glsl_shaders.h" #include "driver/shaders/spirv/spirv_common.h" #include "jpeg-compressor/jpge.h" +#include "maths/matrix.h" #include "maths/vec.h" #include "replay/type_helpers.h" #include "serialise/string_utils.h" @@ -1103,7 +1104,7 @@ void WrappedOpenGL::ContextData::AssociateWindow(WrappedOpenGL *gl, void *wndHan windows[wndHandle] = Timing::GetUnixTimestamp(); } -void WrappedOpenGL::ContextData::CreateDebugData(const GLHookSet &gl) +void WrappedOpenGL::ContextData::CreateDebugData(const GLHookSet &gl, const bool isGLESMode) { // to let us display the overlay on old GL contexts, use as simple a subset of functionality as // possible @@ -1206,13 +1207,29 @@ void WrappedOpenGL::ContextData::CreateDebugData(const GLHookSet &gl) vector vs; vector fs; - GenerateGLSLShader(vs, eShaderGLSL, "", GetEmbeddedResource(glsl_text_vert), 150); + ShaderType shaderType; + int glslVersion; + string fragDefines; - GenerateGLSLShader(fs, eShaderGLSL, - "#extension GL_ARB_shading_language_420pack : require\n" - "#extension GL_ARB_separate_shader_objects : require\n" - "#extension GL_ARB_explicit_attrib_location : require\n", - GetEmbeddedResource(glsl_text_frag), 150); + if(isGLESMode) + { + shaderType = eShaderGLSLES; + glslVersion = 310; + fragDefines = ""; + } + else + { + shaderType = eShaderGLSL; + glslVersion = 150; + fragDefines = + "#extension GL_ARB_shading_language_420pack : require\n" + "#extension GL_ARB_separate_shader_objects : require\n" + "#extension GL_ARB_explicit_attrib_location : require\n"; + } + + GenerateGLSLShader(vs, shaderType, "", GetEmbeddedResource(glsl_text_vert), glslVersion); + GenerateGLSLShader(fs, shaderType, fragDefines, GetEmbeddedResource(glsl_text_frag), + glslVersion); vector vsc; vsc.reserve(vs.size()); @@ -2270,7 +2287,7 @@ void WrappedOpenGL::SwapBuffers(void *windowHandle) // that might be shared later (wglShareLists requires contexts to be // pristine, so can't create this from wglMakeCurrent) if(!ctxdata.ready) - ctxdata.CreateDebugData(m_Real); + ctxdata.CreateDebugData(m_Real, isGLESMode()); bool activeWindow = RenderDoc::Inst().IsActiveWindow(ctxdata.ctx, windowHandle); diff --git a/renderdoc/driver/gl/gl_driver.h b/renderdoc/driver/gl/gl_driver.h index 1214f28e4..d15443678 100644 --- a/renderdoc/driver/gl/gl_driver.h +++ b/renderdoc/driver/gl/gl_driver.h @@ -413,7 +413,7 @@ private: void UnassociateWindow(void *wndHandle); void AssociateWindow(WrappedOpenGL *gl, void *wndHandle); - void CreateDebugData(const GLHookSet &gl); + void CreateDebugData(const GLHookSet &gl, const bool isGLESMode); bool Legacy() { return !attribsCreate || version < 32; } bool Modern() { return !Legacy(); } diff --git a/renderdoc/driver/gl/gl_replay.cpp b/renderdoc/driver/gl/gl_replay.cpp index 0406c0227..68e3c1ea9 100644 --- a/renderdoc/driver/gl/gl_replay.cpp +++ b/renderdoc/driver/gl/gl_replay.cpp @@ -24,6 +24,7 @@ ******************************************************************************/ #include "gl_replay.h" +#include "maths/matrix.h" #include "serialise/string_utils.h" #include "gl_driver.h" #include "gl_resources.h" diff --git a/renderdoc/renderdoc.vcxproj b/renderdoc/renderdoc.vcxproj index 2bc2d3d0c..25047971c 100644 --- a/renderdoc/renderdoc.vcxproj +++ b/renderdoc/renderdoc.vcxproj @@ -260,6 +260,7 @@ + diff --git a/renderdoc/renderdoc.vcxproj.filters b/renderdoc/renderdoc.vcxproj.filters index 296092169..600ffd034 100644 --- a/renderdoc/renderdoc.vcxproj.filters +++ b/renderdoc/renderdoc.vcxproj.filters @@ -249,6 +249,9 @@ Resources\glsl + + Resources\glsl + Resources\glsl