| 1 | /** |
| 2 | * MojoShader; generate shader programs from bytecode of compiled |
| 3 | * Direct3D shaders. |
| 4 | * |
| 5 | * Please see the file LICENSE.txt in the source's root directory. |
| 6 | * |
| 7 | * This file written by Ryan C. Gordon. |
| 8 | */ |
| 9 | |
| 10 | #ifdef _WIN32 |
| 11 | #define WIN32_LEAN_AND_MEAN 1 |
| 12 | #include <windows.h> // GL headers need this for WINGDIAPI definition. |
| 13 | #endif |
| 14 | |
| 15 | #if (defined(__APPLE__) && defined(__MACH__)) |
| 16 | #include "TargetConditionals.h" |
| 17 | #if !TARGET_OS_IPHONE && !TARGET_OS_TV |
| 18 | #define PLATFORM_MACOSX 1 |
| 19 | #endif /* !TARGET_OS_IPHONE && !TARGET_OS_TV */ |
| 20 | #endif /* (defined(__APPLE__) && defined(__MACH__)) */ |
| 21 | |
| 22 | #if PLATFORM_MACOSX |
| 23 | #include <Carbon/Carbon.h> |
| 24 | #endif |
| 25 | |
| 26 | #define __MOJOSHADER_INTERNAL__cxx . . $ `mojoshader_opengl.c:26:9`! 1 |
| 27 | #include "mojoshader_internal.h"cxx . . $ `<file>/mojoshader_internal.h`/ |
| 28 | |
| 29 | #define GL_GLEXT_LEGACYcxx . . $ `mojoshader_opengl.c:29:9`! 1 |
| 30 | #include "GL/gl.h" |
| 31 | #include "GL/glext.h"cxx . . $ `<file>/GL/glext.h`/ |
| 32 | |
| 33 | #if SUPPORT_PROFILE_GLSPIRVcxx . . $ `mojoshader_internal.h:214:9`! |
| 34 | #include "spirv/spirv.h"cxx . . $ `<file>/spirv/spirv.h`/ |
| 35 | #endif |
| 36 | |
| 37 | #ifndef GL_HALF_FLOAT_NVcxx . . $ `GL/glext.h:4328:9`! |
| 38 | #define GL_HALF_FLOAT_NV 0x140B |
| 39 | #endif |
| 40 | |
| 41 | #ifndef GL_HALF_FLOAT_ARBcxx . . $ `GL/glext.h:1628:9`! |
| 42 | #define GL_HALF_FLOAT_ARB 0x140B |
| 43 | #endif |
| 44 | |
| 45 | #ifndef GL_HALF_FLOAT_OES |
| 46 | #define GL_HALF_FLOAT_OEScxx . . $ `mojoshader_opengl.c:46:9`! 0x8D61 |
| 47 | #endif |
| 48 | |
| 49 | // this happens to be the same value for ARB1 and GLSL. |
| 50 | #ifndef GL_PROGRAM_POINT_SIZEcxx . . $ `GL/glext.h:816:9`! |
| 51 | #define GL_PROGRAM_POINT_SIZE 0x8642 |
| 52 | #endif |
| 53 | |
| 54 | // FIXME: ARB_gl_spirv in glext.h? -flibit |
| 55 | #ifndef GL_ARB_gl_spirv |
| 56 | #define GL_ARB_gl_spirvcxx . . $ `mojoshader_opengl.c:56:9`! 1 |
| 57 | #define GL_SHADER_BINARY_FORMAT_SPIR_V_ARBcxx . . $ `mojoshader_opengl.c:57:9`! 0x9551 |
| 58 | typedef void (APIENTRYPcxx . . $ `<external>/11565930711847777359/gl.h:88:9`! PFNGLSPECIALIZESHADERARBPROCcxx . . $ PFNGLSPECIALIZESHADERARBPROC#) ( |
| 59 | GLuintcxx . . $ GLuint# shader, |
| 60 | const GLcharcxx . . $ GLchar#* pEntryPoint, |
| 61 | GLuintcxx . . $ GLuint# numSpecializationConstants, |
| 62 | const GLuintcxx . . $ GLuint#* pConstantIndex, |
| 63 | const GLuintcxx . . $ GLuint#* pConstantValue |
| 64 | ); |
| 65 | #endif |
| 66 | |
| 67 | struct MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# |
| 68 | { |
| 69 | const MOJOSHADER_parseDatacxx . . $ MOJOSHADER_parseData# *parseDatacxx . . $ MOJOSHADER_glShader#parseData.; |
| 70 | GLuintcxx . . $ GLuint# handlecxx . . $ MOJOSHADER_glShader#handle.; |
| 71 | uint32cxx . . $ uint32# refcountcxx . . $ MOJOSHADER_glShader#refcount.; |
| 72 | }; |
| 73 | |
| 74 | typedef structcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_0# |
| 75 | { |
| 76 | MOJOSHADER_shaderTypecxx . . $ MOJOSHADER_shaderType# shader_typecxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_0#shader_type.; |
| 77 | const MOJOSHADER_uniformcxx . . $ MOJOSHADER_uniform# *uniformcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_0#uniform.; |
| 78 | GLintcxx . . $ GLint# locationcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_0#location.; |
| 79 | } UniformMapcxx . . $ UniformMap#; |
| 80 | |
| 81 | typedef structcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_1# |
| 82 | { |
| 83 | const MOJOSHADER_attributecxx . . $ MOJOSHADER_attribute# *attributecxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_1#attribute.; |
| 84 | GLintcxx . . $ GLint# locationcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_1#location.; |
| 85 | } AttributeMapcxx . . $ AttributeMap#; |
| 86 | |
| 87 | struct MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# |
| 88 | { |
| 89 | MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *vertexcxx . . $ MOJOSHADER_glProgram#vertex.; |
| 90 | MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *fragmentcxx . . $ MOJOSHADER_glProgram#fragment.; |
| 91 | GLuintcxx . . $ GLuint# handlecxx . . $ MOJOSHADER_glProgram#handle.; |
| 92 | uint32cxx . . $ uint32# generationcxx . . $ MOJOSHADER_glProgram#generation.; |
| 93 | uint32cxx . . $ uint32# uniform_countcxx . . $ MOJOSHADER_glProgram#uniform_count.; |
| 94 | uint32cxx . . $ uint32# texbem_countcxx . . $ MOJOSHADER_glProgram#texbem_count.; |
| 95 | UniformMapcxx . . $ UniformMap# *uniformscxx . . $ MOJOSHADER_glProgram#uniforms.; |
| 96 | uint32cxx . . $ uint32# attribute_countcxx . . $ MOJOSHADER_glProgram#attribute_count.; |
| 97 | AttributeMapcxx . . $ AttributeMap# *attributescxx . . $ MOJOSHADER_glProgram#attributes.; |
| 98 | size_t vs_uniforms_float4_countcxx . . $ MOJOSHADER_glProgram#vs_uniforms_float4_count.; |
| 99 | GLfloatcxx . . $ GLfloat# *vs_uniforms_float4cxx . . $ MOJOSHADER_glProgram#vs_uniforms_float4.; |
| 100 | size_t vs_uniforms_int4_countcxx . . $ MOJOSHADER_glProgram#vs_uniforms_int4_count.; |
| 101 | GLintcxx . . $ GLint# *vs_uniforms_int4cxx . . $ MOJOSHADER_glProgram#vs_uniforms_int4.; |
| 102 | size_t vs_uniforms_bool_countcxx . . $ MOJOSHADER_glProgram#vs_uniforms_bool_count.; |
| 103 | GLintcxx . . $ GLint# *vs_uniforms_boolcxx . . $ MOJOSHADER_glProgram#vs_uniforms_bool.; |
| 104 | size_t ps_uniforms_float4_countcxx . . $ MOJOSHADER_glProgram#ps_uniforms_float4_count.; |
| 105 | GLfloatcxx . . $ GLfloat# *ps_uniforms_float4cxx . . $ MOJOSHADER_glProgram#ps_uniforms_float4.; |
| 106 | size_t ps_uniforms_int4_countcxx . . $ MOJOSHADER_glProgram#ps_uniforms_int4_count.; |
| 107 | GLintcxx . . $ GLint# *ps_uniforms_int4cxx . . $ MOJOSHADER_glProgram#ps_uniforms_int4.; |
| 108 | size_t ps_uniforms_bool_countcxx . . $ MOJOSHADER_glProgram#ps_uniforms_bool_count.; |
| 109 | GLintcxx . . $ GLint# *ps_uniforms_boolcxx . . $ MOJOSHADER_glProgram#ps_uniforms_bool.; |
| 110 | |
| 111 | uint32cxx . . $ uint32# refcountcxx . . $ MOJOSHADER_glProgram#refcount.; |
| 112 | |
| 113 | int uses_pointsizecxx . . $ MOJOSHADER_glProgram#uses_pointsize.; |
| 114 | |
| 115 | // According to MSDN... |
| 116 | // |
| 117 | // n is an optional integer between 0 and the number of resources supported. |
| 118 | // For example, POSITION0, TEXCOOR1, etc. |
| 119 | // |
| 120 | // The input registers consist of 16 four-component floating-point vectors, |
| 121 | // designated as v0 through v15. |
| 122 | GLintcxx . . $ GLint# vertex_attrib_loccxx . . $ MOJOSHADER_glProgram#vertex_attrib_loc.[MOJOSHADER_USAGE_TOTALcxx . . $ MOJOSHADER_USAGE_TOTAL.][16]; |
| 123 | |
| 124 | // GLSL uses these...location of uniform arrays. |
| 125 | GLintcxx . . $ GLint# vs_float4_loccxx . . $ MOJOSHADER_glProgram#vs_float4_loc.; |
| 126 | GLintcxx . . $ GLint# vs_int4_loccxx . . $ MOJOSHADER_glProgram#vs_int4_loc.; |
| 127 | GLintcxx . . $ GLint# vs_bool_loccxx . . $ MOJOSHADER_glProgram#vs_bool_loc.; |
| 128 | GLintcxx . . $ GLint# ps_float4_loccxx . . $ MOJOSHADER_glProgram#ps_float4_loc.; |
| 129 | GLintcxx . . $ GLint# ps_int4_loccxx . . $ MOJOSHADER_glProgram#ps_int4_loc.; |
| 130 | GLintcxx . . $ GLint# ps_bool_loccxx . . $ MOJOSHADER_glProgram#ps_bool_loc.; |
| 131 | |
| 132 | // Numerous fixes for coordinate system mismatches |
| 133 | GLintcxx . . $ GLint# ps_vpos_flip_loccxx . . $ MOJOSHADER_glProgram#ps_vpos_flip_loc.; |
| 134 | int current_vpos_flipcxx . . $ MOJOSHADER_glProgram#current_vpos_flip.[2]; |
| 135 | #ifdef MOJOSHADER_FLIP_RENDERTARGET |
| 136 | GLint vs_flip_loc; |
| 137 | int current_flip; |
| 138 | #endif |
| 139 | }; |
| 140 | |
| 141 | #ifndef WINGDIAPI |
| 142 | #define WINGDIAPIcxx . . $ `mojoshader_opengl.c:142:9`! |
| 143 | #endif |
| 144 | |
| 145 | // Entry points in base OpenGL that lack function pointer prototypes... |
| 146 | typedef WINGDIAPIcxx . . $ `mojoshader_opengl.c:142:9`! void (APIENTRYPcxx . . $ `<external>/11565930711847777359/gl.h:88:9`! PFNGLGETINTEGERVPROCcxx . . $ PFNGLGETINTEGERVPROC#) (GLenumcxx . . $ GLenum# pname, GLintcxx . . $ GLint# *params); |
| 147 | typedef WINGDIAPIcxx . . $ `mojoshader_opengl.c:142:9`! const GLubytecxx . . $ GLubyte# * (APIENTRYPcxx . . $ `<external>/11565930711847777359/gl.h:88:9`! PFNGLGETSTRINGPROCcxx . . $ PFNGLGETSTRINGPROC#) (GLenumcxx . . $ GLenum# name); |
| 148 | typedef WINGDIAPIcxx . . $ `mojoshader_opengl.c:142:9`! GLenumcxx . . $ GLenum# (APIENTRYPcxx . . $ `<external>/11565930711847777359/gl.h:88:9`! PFNGLGETERRORPROCcxx . . $ PFNGLGETERRORPROC#) (void); |
| 149 | typedef WINGDIAPIcxx . . $ `mojoshader_opengl.c:142:9`! void (APIENTRYPcxx . . $ `<external>/11565930711847777359/gl.h:88:9`! PFNGLENABLEPROCcxx . . $ PFNGLENABLEPROC#) (GLenumcxx . . $ GLenum# cap); |
| 150 | typedef WINGDIAPIcxx . . $ `mojoshader_opengl.c:142:9`! void (APIENTRYPcxx . . $ `<external>/11565930711847777359/gl.h:88:9`! PFNGLDISABLEPROCcxx . . $ PFNGLDISABLEPROC#) (GLenumcxx . . $ GLenum# cap); |
| 151 | |
| 152 | // Max entries for each register file type... |
| 153 | #define MAX_REG_FILE_Fcxx . . $ `mojoshader_opengl.c:153:9`! 8192 |
| 154 | #define MAX_REG_FILE_Icxx . . $ `mojoshader_opengl.c:154:9`! 2047 |
| 155 | #define MAX_REG_FILE_Bcxx . . $ `mojoshader_opengl.c:155:9`! 2047 |
| 156 | #define MAX_TEXBEMScxx . . $ `mojoshader_opengl.c:156:9`! 3 // ps_1_1 allows 4 texture stages, texbem can't use t0. |
| 157 | |
| 158 | struct MOJOSHADER_glContextcxx . . $ MOJOSHADER_glContext# |
| 159 | { |
| 160 | // Allocators... |
| 161 | MOJOSHADER_malloccxx . . $ MOJOSHADER_malloc# malloc_fncxx . . $ MOJOSHADER_glContext#malloc_fn.; |
| 162 | MOJOSHADER_freecxx . . $ MOJOSHADER_free# free_fncxx . . $ MOJOSHADER_glContext#free_fn.; |
| 163 | void *malloc_datacxx . . $ MOJOSHADER_glContext#malloc_data.; |
| 164 | |
| 165 | // The constant register files... |
| 166 | // !!! FIXME: Man, it kills me how much memory this takes... |
| 167 | // !!! FIXME: ... make this dynamically allocated on demand. |
| 168 | GLfloatcxx . . $ GLfloat# vs_reg_file_fcxx . . $ MOJOSHADER_glContext#vs_reg_file_f.[MAX_REG_FILE_Fcxx . . $ `mojoshader_opengl.c:153:9`! * 4]; |
| 169 | GLintcxx . . $ GLint# vs_reg_file_icxx . . $ MOJOSHADER_glContext#vs_reg_file_i.[MAX_REG_FILE_Icxx . . $ `mojoshader_opengl.c:154:9`! * 4]; |
| 170 | uint8cxx . . $ uint8# vs_reg_file_bcxx . . $ MOJOSHADER_glContext#vs_reg_file_b.[MAX_REG_FILE_Bcxx . . $ `mojoshader_opengl.c:155:9`!]; |
| 171 | GLfloatcxx . . $ GLfloat# ps_reg_file_fcxx . . $ MOJOSHADER_glContext#ps_reg_file_f.[MAX_REG_FILE_Fcxx . . $ `mojoshader_opengl.c:153:9`! * 4]; |
| 172 | GLintcxx . . $ GLint# ps_reg_file_icxx . . $ MOJOSHADER_glContext#ps_reg_file_i.[MAX_REG_FILE_Icxx . . $ `mojoshader_opengl.c:154:9`! * 4]; |
| 173 | uint8cxx . . $ uint8# ps_reg_file_bcxx . . $ MOJOSHADER_glContext#ps_reg_file_b.[MAX_REG_FILE_Bcxx . . $ `mojoshader_opengl.c:155:9`!]; |
| 174 | GLuintcxx . . $ GLuint# sampler_reg_filecxx . . $ MOJOSHADER_glContext#sampler_reg_file.[16]; |
| 175 | GLfloatcxx . . $ GLfloat# texbem_statecxx . . $ MOJOSHADER_glContext#texbem_state.[MAX_TEXBEMScxx . . $ `mojoshader_opengl.c:156:9`! * 6]; |
| 176 | |
| 177 | // This increments every time we change the register files. |
| 178 | uint32cxx . . $ uint32# generationcxx . . $ MOJOSHADER_glContext#generation.; |
| 179 | |
| 180 | // This keeps track of implicitly linked programs. |
| 181 | HashTablecxx . . $ HashTable# *linker_cachecxx . . $ MOJOSHADER_glContext#linker_cache.; |
| 182 | |
| 183 | // This tells us which vertex attribute arrays we have enabled. |
| 184 | GLintcxx . . $ GLint# max_attrscxx . . $ MOJOSHADER_glContext#max_attrs.; |
| 185 | uint8cxx . . $ uint8# want_attrcxx . . $ MOJOSHADER_glContext#want_attr.[32]; |
| 186 | uint8cxx . . $ uint8# have_attrcxx . . $ MOJOSHADER_glContext#have_attr.[32]; |
| 187 | |
| 188 | // This shadows vertex attribute and divisor states. |
| 189 | GLuintcxx . . $ GLuint# attr_divisorcxx . . $ MOJOSHADER_glContext#attr_divisor.[32]; |
| 190 | |
| 191 | // rarely used, so we don't touch when we don't have to. |
| 192 | int pointsize_enabledcxx . . $ MOJOSHADER_glContext#pointsize_enabled.; |
| 193 | |
| 194 | // GL stuff... |
| 195 | int opengl_majorcxx . . $ MOJOSHADER_glContext#opengl_major.; |
| 196 | int opengl_minorcxx . . $ MOJOSHADER_glContext#opengl_minor.; |
| 197 | int glsl_majorcxx . . $ MOJOSHADER_glContext#glsl_major.; |
| 198 | int glsl_minorcxx . . $ MOJOSHADER_glContext#glsl_minor.; |
| 199 | MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *bound_programcxx . . $ MOJOSHADER_glContext#bound_program.; |
| 200 | char profilecxx . . $ MOJOSHADER_glContext#profile.[16]; |
| 201 | |
| 202 | #ifdef MOJOSHADER_XNA4_VERTEX_TEXTURES |
| 203 | // Vertex texture sampler offset... |
| 204 | int vertex_sampler_offset; |
| 205 | #endif |
| 206 | |
| 207 | // Extensions... |
| 208 | int have_core_openglcxx . . $ MOJOSHADER_glContext#have_core_opengl.; |
| 209 | int have_opengl_2cxx . . $ MOJOSHADER_glContext#have_opengl_2.; // different entry points than ARB extensions. |
| 210 | int have_opengl_3cxx . . $ MOJOSHADER_glContext#have_opengl_3.; // different extension query. |
| 211 | int have_opengl_escxx . . $ MOJOSHADER_glContext#have_opengl_es.; // different extension requirements |
| 212 | int have_opengl_es3cxx . . $ MOJOSHADER_glContext#have_opengl_es3.; // different shader synxtax and attributes |
| 213 | int have_GL_ARB_vertex_programcxx . . $ MOJOSHADER_glContext#have_GL_ARB_vertex_program.; |
| 214 | int have_GL_ARB_fragment_programcxx . . $ MOJOSHADER_glContext#have_GL_ARB_fragment_program.; |
| 215 | int have_GL_NV_vertex_program2_optioncxx . . $ MOJOSHADER_glContext#have_GL_NV_vertex_program2_option.; |
| 216 | int have_GL_NV_fragment_program2cxx . . $ MOJOSHADER_glContext#have_GL_NV_fragment_program2.; |
| 217 | int have_GL_NV_vertex_program3cxx . . $ MOJOSHADER_glContext#have_GL_NV_vertex_program3.; |
| 218 | int have_GL_NV_gpu_program4cxx . . $ MOJOSHADER_glContext#have_GL_NV_gpu_program4.; |
| 219 | int have_GL_ARB_shader_objectscxx . . $ MOJOSHADER_glContext#have_GL_ARB_shader_objects.; |
| 220 | int have_GL_ARB_vertex_shadercxx . . $ MOJOSHADER_glContext#have_GL_ARB_vertex_shader.; |
| 221 | int have_GL_ARB_fragment_shadercxx . . $ MOJOSHADER_glContext#have_GL_ARB_fragment_shader.; |
| 222 | int have_GL_ARB_shading_language_100cxx . . $ MOJOSHADER_glContext#have_GL_ARB_shading_language_100.; |
| 223 | int have_GL_NV_half_floatcxx . . $ MOJOSHADER_glContext#have_GL_NV_half_float.; |
| 224 | int have_GL_ARB_half_float_vertexcxx . . $ MOJOSHADER_glContext#have_GL_ARB_half_float_vertex.; |
| 225 | int have_GL_OES_vertex_half_floatcxx . . $ MOJOSHADER_glContext#have_GL_OES_vertex_half_float.; |
| 226 | int have_GL_ARB_instanced_arrayscxx . . $ MOJOSHADER_glContext#have_GL_ARB_instanced_arrays.; |
| 227 | int have_GL_ARB_ES2_compatibilitycxx . . $ MOJOSHADER_glContext#have_GL_ARB_ES2_compatibility.; |
| 228 | int have_GL_ARB_gl_spirvcxx . . $ MOJOSHADER_glContext#have_GL_ARB_gl_spirv.; |
| 229 | |
| 230 | // Entry points... |
| 231 | PFNGLGETSTRINGPROCcxx . . $ PFNGLGETSTRINGPROC# glGetStringcxx . . $ MOJOSHADER_glContext#glGetString.; |
| 232 | PFNGLGETSTRINGIPROCcxx . . $ PFNGLGETSTRINGIPROC# glGetStringicxx . . $ MOJOSHADER_glContext#glGetStringi.; |
| 233 | PFNGLGETERRORPROCcxx . . $ PFNGLGETERRORPROC# glGetErrorcxx . . $ MOJOSHADER_glContext#glGetError.; |
| 234 | PFNGLGETINTEGERVPROCcxx . . $ PFNGLGETINTEGERVPROC# glGetIntegervcxx . . $ MOJOSHADER_glContext#glGetIntegerv.; |
| 235 | PFNGLENABLEPROCcxx . . $ PFNGLENABLEPROC# glEnablecxx . . $ MOJOSHADER_glContext#glEnable.; |
| 236 | PFNGLDISABLEPROCcxx . . $ PFNGLDISABLEPROC# glDisablecxx . . $ MOJOSHADER_glContext#glDisable.; |
| 237 | PFNGLDELETESHADERPROCcxx . . $ PFNGLDELETESHADERPROC# glDeleteShadercxx . . $ MOJOSHADER_glContext#glDeleteShader.; |
| 238 | PFNGLDELETEPROGRAMPROCcxx . . $ PFNGLDELETEPROGRAMPROC# glDeleteProgramcxx . . $ MOJOSHADER_glContext#glDeleteProgram.; |
| 239 | PFNGLATTACHSHADERPROCcxx . . $ PFNGLATTACHSHADERPROC# glAttachShadercxx . . $ MOJOSHADER_glContext#glAttachShader.; |
| 240 | PFNGLCOMPILESHADERPROCcxx . . $ PFNGLCOMPILESHADERPROC# glCompileShadercxx . . $ MOJOSHADER_glContext#glCompileShader.; |
| 241 | PFNGLCREATESHADERPROCcxx . . $ PFNGLCREATESHADERPROC# glCreateShadercxx . . $ MOJOSHADER_glContext#glCreateShader.; |
| 242 | PFNGLCREATEPROGRAMPROCcxx . . $ PFNGLCREATEPROGRAMPROC# glCreateProgramcxx . . $ MOJOSHADER_glContext#glCreateProgram.; |
| 243 | PFNGLDISABLEVERTEXATTRIBARRAYPROCcxx . . $ PFNGLDISABLEVERTEXATTRIBARRAYPROC# glDisableVertexAttribArraycxx . . $ MOJOSHADER_glContext#glDisableVertexAttribArray.; |
| 244 | PFNGLENABLEVERTEXATTRIBARRAYPROCcxx . . $ PFNGLENABLEVERTEXATTRIBARRAYPROC# glEnableVertexAttribArraycxx . . $ MOJOSHADER_glContext#glEnableVertexAttribArray.; |
| 245 | PFNGLGETATTRIBLOCATIONPROCcxx . . $ PFNGLGETATTRIBLOCATIONPROC# glGetAttribLocationcxx . . $ MOJOSHADER_glContext#glGetAttribLocation.; |
| 246 | PFNGLGETPROGRAMINFOLOGPROCcxx . . $ PFNGLGETPROGRAMINFOLOGPROC# glGetProgramInfoLogcxx . . $ MOJOSHADER_glContext#glGetProgramInfoLog.; |
| 247 | PFNGLGETSHADERINFOLOGPROCcxx . . $ PFNGLGETSHADERINFOLOGPROC# glGetShaderInfoLogcxx . . $ MOJOSHADER_glContext#glGetShaderInfoLog.; |
| 248 | PFNGLGETSHADERIVPROCcxx . . $ PFNGLGETSHADERIVPROC# glGetShaderivcxx . . $ MOJOSHADER_glContext#glGetShaderiv.; |
| 249 | PFNGLGETPROGRAMIVPROCcxx . . $ PFNGLGETPROGRAMIVPROC# glGetProgramivcxx . . $ MOJOSHADER_glContext#glGetProgramiv.; |
| 250 | PFNGLGETUNIFORMLOCATIONPROCcxx . . $ PFNGLGETUNIFORMLOCATIONPROC# glGetUniformLocationcxx . . $ MOJOSHADER_glContext#glGetUniformLocation.; |
| 251 | PFNGLLINKPROGRAMPROCcxx . . $ PFNGLLINKPROGRAMPROC# glLinkProgramcxx . . $ MOJOSHADER_glContext#glLinkProgram.; |
| 252 | PFNGLSHADERSOURCEPROCcxx . . $ PFNGLSHADERSOURCEPROC# glShaderSourcecxx . . $ MOJOSHADER_glContext#glShaderSource.; |
| 253 | PFNGLUNIFORM1IPROCcxx . . $ PFNGLUNIFORM1IPROC# glUniform1icxx . . $ MOJOSHADER_glContext#glUniform1i.; |
| 254 | PFNGLUNIFORM1IVPROCcxx . . $ PFNGLUNIFORM1IVPROC# glUniform1ivcxx . . $ MOJOSHADER_glContext#glUniform1iv.; |
| 255 | PFNGLUNIFORM2FPROCcxx . . $ PFNGLUNIFORM2FPROC# glUniform2fcxx . . $ MOJOSHADER_glContext#glUniform2f.; |
| 256 | #ifdef MOJOSHADER_FLIP_RENDERTARGET |
| 257 | PFNGLUNIFORM1FPROC glUniform1f; |
| 258 | #endif |
| 259 | PFNGLUNIFORM4FVPROCcxx . . $ PFNGLUNIFORM4FVPROC# glUniform4fvcxx . . $ MOJOSHADER_glContext#glUniform4fv.; |
| 260 | PFNGLUNIFORM4IVPROCcxx . . $ PFNGLUNIFORM4IVPROC# glUniform4ivcxx . . $ MOJOSHADER_glContext#glUniform4iv.; |
| 261 | PFNGLUSEPROGRAMPROCcxx . . $ PFNGLUSEPROGRAMPROC# glUseProgramcxx . . $ MOJOSHADER_glContext#glUseProgram.; |
| 262 | PFNGLVERTEXATTRIBPOINTERPROCcxx . . $ PFNGLVERTEXATTRIBPOINTERPROC# glVertexAttribPointercxx . . $ MOJOSHADER_glContext#glVertexAttribPointer.; |
| 263 | PFNGLDELETEOBJECTARBPROCcxx . . $ PFNGLDELETEOBJECTARBPROC# glDeleteObjectARBcxx . . $ MOJOSHADER_glContext#glDeleteObjectARB.; |
| 264 | PFNGLATTACHOBJECTARBPROCcxx . . $ PFNGLATTACHOBJECTARBPROC# glAttachObjectARBcxx . . $ MOJOSHADER_glContext#glAttachObjectARB.; |
| 265 | PFNGLCOMPILESHADERARBPROCcxx . . $ PFNGLCOMPILESHADERARBPROC# glCompileShaderARBcxx . . $ MOJOSHADER_glContext#glCompileShaderARB.; |
| 266 | PFNGLCREATEPROGRAMOBJECTARBPROCcxx . . $ PFNGLCREATEPROGRAMOBJECTARBPROC# glCreateProgramObjectARBcxx . . $ MOJOSHADER_glContext#glCreateProgramObjectARB.; |
| 267 | PFNGLCREATESHADEROBJECTARBPROCcxx . . $ PFNGLCREATESHADEROBJECTARBPROC# glCreateShaderObjectARBcxx . . $ MOJOSHADER_glContext#glCreateShaderObjectARB.; |
| 268 | PFNGLDISABLEVERTEXATTRIBARRAYARBPROCcxx . . $ PFNGLDISABLEVERTEXATTRIBARRAYARBPROC# glDisableVertexAttribArrayARBcxx . . $ MOJOSHADER_glContext#glDisableVertexAttribArrayARB.; |
| 269 | PFNGLENABLEVERTEXATTRIBARRAYARBPROCcxx . . $ PFNGLENABLEVERTEXATTRIBARRAYARBPROC# glEnableVertexAttribArrayARBcxx . . $ MOJOSHADER_glContext#glEnableVertexAttribArrayARB.; |
| 270 | PFNGLGETATTRIBLOCATIONARBPROCcxx . . $ PFNGLGETATTRIBLOCATIONARBPROC# glGetAttribLocationARBcxx . . $ MOJOSHADER_glContext#glGetAttribLocationARB.; |
| 271 | PFNGLGETINFOLOGARBPROCcxx . . $ PFNGLGETINFOLOGARBPROC# glGetInfoLogARBcxx . . $ MOJOSHADER_glContext#glGetInfoLogARB.; |
| 272 | PFNGLGETOBJECTPARAMETERIVARBPROCcxx . . $ PFNGLGETOBJECTPARAMETERIVARBPROC# glGetObjectParameterivARBcxx . . $ MOJOSHADER_glContext#glGetObjectParameterivARB.; |
| 273 | PFNGLGETUNIFORMLOCATIONARBPROCcxx . . $ PFNGLGETUNIFORMLOCATIONARBPROC# glGetUniformLocationARBcxx . . $ MOJOSHADER_glContext#glGetUniformLocationARB.; |
| 274 | PFNGLLINKPROGRAMARBPROCcxx . . $ PFNGLLINKPROGRAMARBPROC# glLinkProgramARBcxx . . $ MOJOSHADER_glContext#glLinkProgramARB.; |
| 275 | PFNGLSHADERSOURCEARBPROCcxx . . $ PFNGLSHADERSOURCEARBPROC# glShaderSourceARBcxx . . $ MOJOSHADER_glContext#glShaderSourceARB.; |
| 276 | PFNGLUNIFORM1IARBPROCcxx . . $ PFNGLUNIFORM1IARBPROC# glUniform1iARBcxx . . $ MOJOSHADER_glContext#glUniform1iARB.; |
| 277 | PFNGLUNIFORM1IVARBPROCcxx . . $ PFNGLUNIFORM1IVARBPROC# glUniform1ivARBcxx . . $ MOJOSHADER_glContext#glUniform1ivARB.; |
| 278 | PFNGLUNIFORM4FVARBPROCcxx . . $ PFNGLUNIFORM4FVARBPROC# glUniform4fvARBcxx . . $ MOJOSHADER_glContext#glUniform4fvARB.; |
| 279 | PFNGLUNIFORM4IVARBPROCcxx . . $ PFNGLUNIFORM4IVARBPROC# glUniform4ivARBcxx . . $ MOJOSHADER_glContext#glUniform4ivARB.; |
| 280 | PFNGLUSEPROGRAMOBJECTARBPROCcxx . . $ PFNGLUSEPROGRAMOBJECTARBPROC# glUseProgramObjectARBcxx . . $ MOJOSHADER_glContext#glUseProgramObjectARB.; |
| 281 | PFNGLVERTEXATTRIBPOINTERARBPROCcxx . . $ PFNGLVERTEXATTRIBPOINTERARBPROC# glVertexAttribPointerARBcxx . . $ MOJOSHADER_glContext#glVertexAttribPointerARB.; |
| 282 | PFNGLGETPROGRAMIVARBPROCcxx . . $ PFNGLGETPROGRAMIVARBPROC# glGetProgramivARBcxx . . $ MOJOSHADER_glContext#glGetProgramivARB.; |
| 283 | PFNGLPROGRAMLOCALPARAMETER4FVARBPROCcxx . . $ PFNGLPROGRAMLOCALPARAMETER4FVARBPROC# glProgramLocalParameter4fvARBcxx . . $ MOJOSHADER_glContext#glProgramLocalParameter4fvARB.; |
| 284 | PFNGLPROGRAMLOCALPARAMETERI4IVNVPROCcxx . . $ PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC# glProgramLocalParameterI4ivNVcxx . . $ MOJOSHADER_glContext#glProgramLocalParameterI4ivNV.; |
| 285 | PFNGLDELETEPROGRAMSARBPROCcxx . . $ PFNGLDELETEPROGRAMSARBPROC# glDeleteProgramsARBcxx . . $ MOJOSHADER_glContext#glDeleteProgramsARB.; |
| 286 | PFNGLGENPROGRAMSARBPROCcxx . . $ PFNGLGENPROGRAMSARBPROC# glGenProgramsARBcxx . . $ MOJOSHADER_glContext#glGenProgramsARB.; |
| 287 | PFNGLBINDPROGRAMARBPROCcxx . . $ PFNGLBINDPROGRAMARBPROC# glBindProgramARBcxx . . $ MOJOSHADER_glContext#glBindProgramARB.; |
| 288 | PFNGLPROGRAMSTRINGARBPROCcxx . . $ PFNGLPROGRAMSTRINGARBPROC# glProgramStringARBcxx . . $ MOJOSHADER_glContext#glProgramStringARB.; |
| 289 | PFNGLVERTEXATTRIBDIVISORARBPROCcxx . . $ PFNGLVERTEXATTRIBDIVISORARBPROC# glVertexAttribDivisorARBcxx . . $ MOJOSHADER_glContext#glVertexAttribDivisorARB.; |
| 290 | PFNGLSHADERBINARYPROCcxx . . $ PFNGLSHADERBINARYPROC# glShaderBinarycxx . . $ MOJOSHADER_glContext#glShaderBinary.; |
| 291 | PFNGLSPECIALIZESHADERARBPROCcxx . . $ PFNGLSPECIALIZESHADERARBPROC# glSpecializeShaderARBcxx . . $ MOJOSHADER_glContext#glSpecializeShaderARB.; |
| 292 | |
| 293 | // interface for profile-specific things. |
| 294 | int (*profileMaxUniformscxx . . $ MOJOSHADER_glContext#profileMaxUniforms.)(MOJOSHADER_shaderTypecxx . . $ MOJOSHADER_shaderType# shader_type); |
| 295 | int (*profileCompileShadercxx . . $ MOJOSHADER_glContext#profileCompileShader.)(const MOJOSHADER_parseDatacxx . . $ MOJOSHADER_parseData# *pd, GLuintcxx . . $ GLuint# *s); |
| 296 | void (*profileDeleteShadercxx . . $ MOJOSHADER_glContext#profileDeleteShader.)(const GLuintcxx . . $ GLuint# shader); |
| 297 | void (*profileDeleteProgramcxx . . $ MOJOSHADER_glContext#profileDeleteProgram.)(const GLuintcxx . . $ GLuint# program); |
| 298 | GLintcxx . . $ GLint# (*profileGetAttribLocationcxx . . $ MOJOSHADER_glContext#profileGetAttribLocation.)(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program, int idx); |
| 299 | GLintcxx . . $ GLint# (*profileGetUniformLocationcxx . . $ MOJOSHADER_glContext#profileGetUniformLocation.)(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program, MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *shader, int idx); |
| 300 | GLintcxx . . $ GLint# (*profileGetSamplerLocationcxx . . $ MOJOSHADER_glContext#profileGetSamplerLocation.)(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *, MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *, int); |
| 301 | GLuintcxx . . $ GLuint# (*profileLinkProgramcxx . . $ MOJOSHADER_glContext#profileLinkProgram.)(MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *, MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *); |
| 302 | void (*profileFinalInitProgramcxx . . $ MOJOSHADER_glContext#profileFinalInitProgram.)(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program); |
| 303 | void (*profileUseProgramcxx . . $ MOJOSHADER_glContext#profileUseProgram.)(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program); |
| 304 | void (*profilePushConstantArraycxx . . $ MOJOSHADER_glContext#profilePushConstantArray.)(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *, const MOJOSHADER_uniformcxx . . $ MOJOSHADER_uniform# *, const GLfloatcxx . . $ GLfloat# *); |
| 305 | void (*profilePushUniformscxx . . $ MOJOSHADER_glContext#profilePushUniforms.)(void); |
| 306 | void (*profilePushSamplercxx . . $ MOJOSHADER_glContext#profilePushSampler.)(GLintcxx . . $ GLint# loc, GLuintcxx . . $ GLuint# sampler); |
| 307 | int (*profileMustPushConstantArrayscxx . . $ MOJOSHADER_glContext#profileMustPushConstantArrays.)(void); |
| 308 | int (*profileMustPushSamplerscxx . . $ MOJOSHADER_glContext#profileMustPushSamplers.)(void); |
| 309 | void (*profileToggleProgramPointSizecxx . . $ MOJOSHADER_glContext#profileToggleProgramPointSize.)(int enable); |
| 310 | }; |
| 311 | |
| 312 | #ifdef MOJOSHADER_NO_THREAD_LOCAL |
| 313 | #define MOJOSHADER_THREADLOCAL |
| 314 | #elif defined(_WIN32) |
| 315 | #define MOJOSHADER_THREADLOCAL __declspec(thread) |
| 316 | #elif defined(__GNUC__cxx . . $ `<built-in>:8:9`!) || defined(__clang__cxx . . $ `<built-in>:3:9`!) |
| 317 | #define MOJOSHADER_THREADLOCALcxx . . $ `mojoshader_opengl.c:317:9`! __thread |
| 318 | #else |
| 319 | #error Please define your platform. |
| 320 | #endif |
| 321 | |
| 322 | static MOJOSHADER_THREADLOCALcxx . . $ `mojoshader_opengl.c:317:9`! MOJOSHADER_glContextcxx . . $ MOJOSHADER_glContext# *ctxcxx . . $ ctx. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 323 | |
| 324 | // Error state... |
| 325 | static char error_buffercxx . . $ error_buffer.[1024] = { '\0' }; |
| 326 | |
| 327 | static void set_errorcxx . . $ set_error(85c52e162fed56f9).(const char *str) |
| 328 | { |
| 329 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(error_buffercxx . . $ error_buffer., sizeof (error_buffercxx . . $ error_buffer.), "%s", str); |
| 330 | } // set_error |
| 331 | |
| 332 | #if PLATFORM_MACOSX |
| 333 | static inline int macosx_version_atleast(int x, int y, int z) |
| 334 | { |
| 335 | #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 |
| 336 | return 1; |
| 337 | #else |
| 338 | static int checked = 0; |
| 339 | static int combined = 0; |
| 340 | |
| 341 | if (!checked) |
| 342 | { |
| 343 | SInt32 ver = 0; |
| 344 | SInt32 major = 0; |
| 345 | SInt32 minor = 0; |
| 346 | SInt32 patch = 0; |
| 347 | int convert = 0; |
| 348 | |
| 349 | if (Gestalt(gestaltSystemVersion, &ver) != noErr) |
| 350 | { |
| 351 | ver = 0x1000; // oh well. |
| 352 | convert = 1; // split (ver) into (major),(minor),(patch). |
| 353 | } |
| 354 | else if (ver < 0x1030) |
| 355 | { |
| 356 | convert = 1; // split (ver) into (major),(minor),(patch). |
| 357 | } |
| 358 | else |
| 359 | { |
| 360 | // presumably this won't fail. But if it does, we'll just use the |
| 361 | // original version value. This might cut the value--10.12.11 will |
| 362 | // come out to 10.9.9, for example--but it's better than nothing. |
| 363 | if (Gestalt(gestaltSystemVersionMajor, &major) != noErr) |
| 364 | convert = 1; |
| 365 | else if (Gestalt(gestaltSystemVersionMinor, &minor) != noErr) |
| 366 | convert = 1; |
| 367 | else if (Gestalt(gestaltSystemVersionBugFix, &patch) != noErr) |
| 368 | convert = 1; |
| 369 | } // else |
| 370 | |
| 371 | if (convert) |
| 372 | { |
| 373 | major = ((ver & 0xFF00) >> 8); |
| 374 | major = (((major / 16) * 10) + (major % 16)); |
| 375 | minor = ((ver & 0xF0) >> 4); |
| 376 | patch = (ver & 0xF); |
| 377 | } // if |
| 378 | |
| 379 | combined = (major << 16) | (minor << 8) | patch; |
| 380 | checked = 1; |
| 381 | } // if |
| 382 | |
| 383 | return (combined >= ((x << 16) | (y << 8) | z)); |
| 384 | #endif |
| 385 | } // macosx_version_atleast |
| 386 | #endif |
| 387 | |
| 388 | static inline void out_of_memorycxx . . $ out_of_memory(49f6e7a06ebc5aa8).(void) |
| 389 | { |
| 390 | set_errorcxx . . $ set_error(85c52e162fed56f9).("out of memory"); |
| 391 | } // out_of_memory |
| 392 | |
| 393 | static inline void *Malloccxx . . $ Malloc(bfcfa4d6b7f7ef64).(const size_t len) |
| 394 | { |
| 395 | void *retval = ctxcxx . . $ ctx.->malloc_fncxx . . $ MOJOSHADER_glContext#malloc_fn.((int) len, ctxcxx . . $ ctx.->malloc_datacxx . . $ MOJOSHADER_glContext#malloc_data.); |
| 396 | if (retval == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 397 | out_of_memorycxx . . $ out_of_memory(49f6e7a06ebc5aa8).(); |
| 398 | return retval; |
| 399 | } // Malloc |
| 400 | |
| 401 | static inline void Freecxx . . $ Free(5d22bdacc48458e8).(void *ptr) |
| 402 | { |
| 403 | if (ptr != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 404 | ctxcxx . . $ ctx.->free_fncxx . . $ MOJOSHADER_glContext#free_fn.(ptr, ctxcxx . . $ ctx.->malloc_datacxx . . $ MOJOSHADER_glContext#malloc_data.); |
| 405 | } // Free |
| 406 | |
| 407 | |
| 408 | static inline void toggle_gl_statecxx . . $ toggle_gl_state(3d89109e85ced1be).(GLenumcxx . . $ GLenum# state, int val) |
| 409 | { |
| 410 | if (val) |
| 411 | ctxcxx . . $ ctx.->glEnablecxx . . $ MOJOSHADER_glContext#glEnable.(state); |
| 412 | else |
| 413 | ctxcxx . . $ ctx.->glDisablecxx . . $ MOJOSHADER_glContext#glDisable.(state); |
| 414 | } // toggle_gl_state |
| 415 | |
| 416 | |
| 417 | // profile-specific implementations... |
| 418 | |
| 419 | #if SUPPORT_PROFILE_GLSLcxx . . $ `mojoshader_internal.h:182:9`! || SUPPORT_PROFILE_GLSPIRVcxx . . $ `mojoshader_internal.h:214:9`! |
| 420 | static inline GLenumcxx . . $ GLenum# glsl_shader_typecxx . . $ glsl_shader_type(6ba2cb23bc7c8a0c).(const MOJOSHADER_shaderTypecxx . . $ MOJOSHADER_shaderType# t) |
| 421 | { |
| 422 | // these enums match between core 2.0 and the ARB extensions. |
| 423 | if (t == MOJOSHADER_TYPE_VERTEXcxx . . $ MOJOSHADER_TYPE_VERTEX.) |
| 424 | return GL_VERTEX_SHADERcxx . . $ `GL/glext.h:420:9`!; |
| 425 | else if (t == MOJOSHADER_TYPE_PIXELcxx . . $ MOJOSHADER_TYPE_PIXEL.) |
| 426 | return GL_FRAGMENT_SHADERcxx . . $ `GL/glext.h:419:9`!; |
| 427 | |
| 428 | // !!! FIXME: geometry shaders? |
| 429 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(0 && "Unknown GLSL shader type!"); |
| 430 | return GL_NONEcxx . . $ `<external>/11565930711847777359/gl.h:431:9`!; |
| 431 | } // glsl_shader_type |
| 432 | |
| 433 | |
| 434 | static int impl_GLSL_MustPushConstantArrayscxx . . $ impl_GLSL_MustPushConstantArrays(b126dc7c1de90089).(void) { return 1; } |
| 435 | static int impl_GLSL_MustPushSamplerscxx . . $ impl_GLSL_MustPushSamplers(b126dc7c1de90089).(void) { return 1; } |
| 436 | |
| 437 | static int impl_GLSL_MaxUniformscxx . . $ impl_GLSL_MaxUniforms(31af91354e387fe).(MOJOSHADER_shaderTypecxx . . $ MOJOSHADER_shaderType# shader_type) |
| 438 | { |
| 439 | // these enums match between core 2.0 and the ARB extensions. |
| 440 | GLenumcxx . . $ GLenum# pname = GL_NONEcxx . . $ `<external>/11565930711847777359/gl.h:431:9`!; |
| 441 | GLintcxx . . $ GLint# val = 0; |
| 442 | if (shader_type == MOJOSHADER_TYPE_VERTEXcxx . . $ MOJOSHADER_TYPE_VERTEX.) |
| 443 | pname = GL_MAX_VERTEX_UNIFORM_COMPONENTScxx . . $ `GL/glext.h:422:9`!; |
| 444 | else if (shader_type == MOJOSHADER_TYPE_PIXELcxx . . $ MOJOSHADER_TYPE_PIXEL.) |
| 445 | pname = GL_MAX_FRAGMENT_UNIFORM_COMPONENTScxx . . $ `GL/glext.h:421:9`!; |
| 446 | else |
| 447 | return -1; |
| 448 | |
| 449 | ctxcxx . . $ ctx.->glGetIntegervcxx . . $ MOJOSHADER_glContext#glGetIntegerv.(pname, &val); |
| 450 | return (int) val; |
| 451 | } // impl_GLSL_MaxUniforms |
| 452 | |
| 453 | #if SUPPORT_PROFILE_GLSPIRVcxx . . $ `mojoshader_internal.h:214:9`! |
| 454 | static const SpirvPatchTablecxx . . $ SpirvPatchTable#* spv_getPatchTablecxx . . $ spv_getPatchTable(18150a3aca5512d4).(MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *shader) |
| 455 | { |
| 456 | const MOJOSHADER_parseDatacxx . . $ MOJOSHADER_parseData# *pd = shader->parseDatacxx . . $ MOJOSHADER_glShader#parseData.; |
| 457 | size_t table_offset = pd->output_lencxx . . $ MOJOSHADER_parseData#output_len. - sizeof(SpirvPatchTablecxx . . $ SpirvPatchTable#); |
| 458 | return (const SpirvPatchTablecxx . . $ SpirvPatchTable# *) (pd->outputcxx . . $ MOJOSHADER_parseData#output. + table_offset); |
| 459 | } // spv_getPatchTable |
| 460 | |
| 461 | static int spv_CompileShadercxx . . $ spv_CompileShader(33b0fc9fc74254ae).(const MOJOSHADER_parseDatacxx . . $ MOJOSHADER_parseData# *pd, int32cxx . . $ int32# base_location, GLuintcxx . . $ GLuint# *s) |
| 462 | { |
| 463 | GLintcxx . . $ GLint# ok = 0; |
| 464 | |
| 465 | GLsizeicxx . . $ GLsizei# data_len = pd->output_lencxx . . $ MOJOSHADER_parseData#output_len. - sizeof(SpirvPatchTablecxx . . $ SpirvPatchTable#); |
| 466 | const GLvoidcxx . . $ GLvoid#* data = pd->outputcxx . . $ MOJOSHADER_parseData#output.; |
| 467 | uint32cxx . . $ uint32# *patched_data = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 468 | if (base_location) |
| 469 | { |
| 470 | size_t i, max; |
| 471 | |
| 472 | patched_data = (uint32cxx . . $ uint32# *) Malloccxx . . $ Malloc(bfcfa4d6b7f7ef64).(data_len); |
| 473 | memcpycxx . . $ memcpy(cc817cb175f282d).(patched_data, data, data_len); |
| 474 | const SpirvPatchTablecxx . . $ SpirvPatchTable# *table = (const SpirvPatchTablecxx . . $ SpirvPatchTable# *) &pd->outputcxx . . $ MOJOSHADER_parseData#output.[data_len]; |
| 475 | if (table->vpflipcxx . . $ SpirvPatchTable#vpflip..offsetcxx . . $ SpirvPatchEntry#offset.) patched_data[table->vpflipcxx . . $ SpirvPatchTable#vpflip..offsetcxx . . $ SpirvPatchEntry#offset.] += base_location; |
| 476 | if (table->array_vec4cxx . . $ SpirvPatchTable#array_vec4..offsetcxx . . $ SpirvPatchEntry#offset.) patched_data[table->array_vec4cxx . . $ SpirvPatchTable#array_vec4..offsetcxx . . $ SpirvPatchEntry#offset.] += base_location; |
| 477 | if (table->array_ivec4cxx . . $ SpirvPatchTable#array_ivec4..offsetcxx . . $ SpirvPatchEntry#offset.) patched_data[table->array_ivec4cxx . . $ SpirvPatchTable#array_ivec4..offsetcxx . . $ SpirvPatchEntry#offset.] += base_location; |
| 478 | if (table->array_boolcxx . . $ SpirvPatchTable#array_bool..offsetcxx . . $ SpirvPatchEntry#offset.) patched_data[table->array_boolcxx . . $ SpirvPatchTable#array_bool..offsetcxx . . $ SpirvPatchEntry#offset.] += base_location; |
| 479 | |
| 480 | for (i = 0, max = STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(table->samplers); i < max; i++) |
| 481 | { |
| 482 | SpirvPatchEntrycxx . . $ SpirvPatchEntry# entry = table->samplerscxx . . $ SpirvPatchTable#samplers.[i]; |
| 483 | if (entry.offsetcxx . . $ SpirvPatchEntry#offset.) |
| 484 | patched_data[entry.offsetcxx . . $ SpirvPatchEntry#offset.] += base_location; |
| 485 | } // for |
| 486 | |
| 487 | data = patched_data; |
| 488 | } // if |
| 489 | |
| 490 | const GLuintcxx . . $ GLuint# shader = ctxcxx . . $ ctx.->glCreateShadercxx . . $ MOJOSHADER_glContext#glCreateShader.(glsl_shader_typecxx . . $ glsl_shader_type(6ba2cb23bc7c8a0c).(pd->shader_typecxx . . $ MOJOSHADER_parseData#shader_type.)); |
| 491 | ctxcxx . . $ ctx.->glShaderBinarycxx . . $ MOJOSHADER_glContext#glShaderBinary.(1, &shader, GL_SHADER_BINARY_FORMAT_SPIR_V_ARBcxx . . $ `mojoshader_opengl.c:57:9`!, data, data_len); |
| 492 | ctxcxx . . $ ctx.->glSpecializeShaderARBcxx . . $ MOJOSHADER_glContext#glSpecializeShaderARB.(shader, pd->mainfncxx . . $ MOJOSHADER_parseData#mainfn., 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); // FIXME: Spec Constants? -flibit |
| 493 | ctxcxx . . $ ctx.->glGetShaderivcxx . . $ MOJOSHADER_glContext#glGetShaderiv.(shader, GL_COMPILE_STATUScxx . . $ `GL/glext.h:447:9`!, &ok); |
| 494 | |
| 495 | if (patched_data) |
| 496 | Freecxx . . $ Free(5d22bdacc48458e8).(patched_data); |
| 497 | |
| 498 | if (!ok) |
| 499 | { |
| 500 | GLsizeicxx . . $ GLsizei# len = 0; |
| 501 | ctxcxx . . $ ctx.->glGetShaderInfoLogcxx . . $ MOJOSHADER_glContext#glGetShaderInfoLog.(shader, sizeof(error_buffercxx . . $ error_buffer.), &len, |
| 502 | (GLcharcxx . . $ GLchar# *) error_buffercxx . . $ error_buffer.); |
| 503 | ctxcxx . . $ ctx.->glDeleteShadercxx . . $ MOJOSHADER_glContext#glDeleteShader.(shader); |
| 504 | *s = 0; |
| 505 | return 0; |
| 506 | } // if |
| 507 | |
| 508 | *s = shader; |
| 509 | |
| 510 | return 1; |
| 511 | } // spv_CompileShader |
| 512 | |
| 513 | static int impl_SPIRV_CompileShadercxx . . $ impl_SPIRV_CompileShader(ec98bc26451bb3a1).(const MOJOSHADER_parseDatacxx . . $ MOJOSHADER_parseData# *pd, GLuintcxx . . $ GLuint# *s) |
| 514 | { |
| 515 | // Compilation postponed until linking, but generate dummy shader id so hash table lookups work. |
| 516 | *s = ctxcxx . . $ ctx.->glCreateShadercxx . . $ MOJOSHADER_glContext#glCreateShader.(glsl_shader_typecxx . . $ glsl_shader_type(6ba2cb23bc7c8a0c).(pd->shader_typecxx . . $ MOJOSHADER_parseData#shader_type.)); |
| 517 | return 1; |
| 518 | } // impl_SPIRV_CompileShader |
| 519 | |
| 520 | static GLuintcxx . . $ GLuint# impl_SPIRV_LinkProgramcxx . . $ impl_SPIRV_LinkProgram(3128a097761c2828).(MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *vshader, |
| 521 | MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *pshader) |
| 522 | { |
| 523 | GLintcxx . . $ GLint# ok = 0; |
| 524 | GLuintcxx . . $ GLuint# vs_handle = 0; |
| 525 | int32cxx . . $ int32# base_location = 0; |
| 526 | |
| 527 | // Shader compilation postponed until linking due to locations being global |
| 528 | // in program. To avoid overlap between VS and PS, we need to know about |
| 529 | // other shader stages to assign final uniform/attrib locations before |
| 530 | // compilation. |
| 531 | |
| 532 | MOJOSHADER_spirv_link_attributescxx . . $ MOJOSHADER_spirv_link_attributes(8985aed79211bd0).(vshader->parseDatacxx . . $ MOJOSHADER_glShader#parseData., pshader->parseDatacxx . . $ MOJOSHADER_glShader#parseData., 1); |
| 533 | |
| 534 | if (vshader) |
| 535 | { |
| 536 | if (!spv_CompileShadercxx . . $ spv_CompileShader(33b0fc9fc74254ae).(vshader->parseDatacxx . . $ MOJOSHADER_glShader#parseData., base_location, &vs_handle)) |
| 537 | return 0; |
| 538 | |
| 539 | const SpirvPatchTablecxx . . $ SpirvPatchTable#* patch_table = spv_getPatchTablecxx . . $ spv_getPatchTable(18150a3aca5512d4).(vshader); |
| 540 | base_location += patch_table->location_countcxx . . $ SpirvPatchTable#location_count.; |
| 541 | } // if |
| 542 | |
| 543 | GLuintcxx . . $ GLuint# ps_handle = 0; |
| 544 | if (pshader) |
| 545 | { |
| 546 | if (!spv_CompileShadercxx . . $ spv_CompileShader(33b0fc9fc74254ae).(pshader->parseDatacxx . . $ MOJOSHADER_glShader#parseData., base_location, &ps_handle)) |
| 547 | return 0; |
| 548 | } // if |
| 549 | |
| 550 | if (ctxcxx . . $ ctx.->have_opengl_2cxx . . $ MOJOSHADER_glContext#have_opengl_2.) |
| 551 | { |
| 552 | const GLuintcxx . . $ GLuint# program = ctxcxx . . $ ctx.->glCreateProgramcxx . . $ MOJOSHADER_glContext#glCreateProgram.(); |
| 553 | if (vs_handle) |
| 554 | { |
| 555 | ctxcxx . . $ ctx.->glAttachShadercxx . . $ MOJOSHADER_glContext#glAttachShader.(program, vs_handle); |
| 556 | ctxcxx . . $ ctx.->glDeleteShadercxx . . $ MOJOSHADER_glContext#glDeleteShader.(vs_handle); |
| 557 | } // if |
| 558 | if (ps_handle) |
| 559 | { |
| 560 | ctxcxx . . $ ctx.->glAttachShadercxx . . $ MOJOSHADER_glContext#glAttachShader.(program, ps_handle); |
| 561 | ctxcxx . . $ ctx.->glDeleteShadercxx . . $ MOJOSHADER_glContext#glDeleteShader.(ps_handle); |
| 562 | } // if |
| 563 | ctxcxx . . $ ctx.->glLinkProgramcxx . . $ MOJOSHADER_glContext#glLinkProgram.(program); |
| 564 | ctxcxx . . $ ctx.->glGetProgramivcxx . . $ MOJOSHADER_glContext#glGetProgramiv.(program, GL_LINK_STATUScxx . . $ `GL/glext.h:448:9`!, &ok); |
| 565 | if (!ok) |
| 566 | { |
| 567 | GLsizeicxx . . $ GLsizei# len = 0; |
| 568 | ctxcxx . . $ ctx.->glGetProgramInfoLogcxx . . $ MOJOSHADER_glContext#glGetProgramInfoLog.(program, sizeof (error_buffercxx . . $ error_buffer.), |
| 569 | &len, (GLcharcxx . . $ GLchar# *) error_buffercxx . . $ error_buffer.); |
| 570 | ctxcxx . . $ ctx.->glDeleteProgramcxx . . $ MOJOSHADER_glContext#glDeleteProgram.(program); |
| 571 | return 0; |
| 572 | } // if |
| 573 | |
| 574 | return program; |
| 575 | } // if |
| 576 | else |
| 577 | { |
| 578 | const GLhandleARBcxx . . $ GLhandleARB# program = ctxcxx . . $ ctx.->glCreateProgramObjectARBcxx . . $ MOJOSHADER_glContext#glCreateProgramObjectARB.(); |
| 579 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(sizeof(program) == sizeof(GLuint)); // not always true on OS X! |
| 580 | if (vs_handle) |
| 581 | { |
| 582 | ctxcxx . . $ ctx.->glAttachObjectARBcxx . . $ MOJOSHADER_glContext#glAttachObjectARB.(program, (GLhandleARBcxx . . $ GLhandleARB#) vs_handle); |
| 583 | ctxcxx . . $ ctx.->glDeleteObjectARBcxx . . $ MOJOSHADER_glContext#glDeleteObjectARB.((GLhandleARBcxx . . $ GLhandleARB#) vs_handle); |
| 584 | } // if |
| 585 | if (ps_handle) |
| 586 | { |
| 587 | ctxcxx . . $ ctx.->glAttachObjectARBcxx . . $ MOJOSHADER_glContext#glAttachObjectARB.(program, (GLhandleARBcxx . . $ GLhandleARB#) ps_handle); |
| 588 | ctxcxx . . $ ctx.->glDeleteObjectARBcxx . . $ MOJOSHADER_glContext#glDeleteObjectARB.((GLhandleARBcxx . . $ GLhandleARB#) ps_handle); |
| 589 | } // if |
| 590 | ctxcxx . . $ ctx.->glLinkProgramARBcxx . . $ MOJOSHADER_glContext#glLinkProgramARB.(program); |
| 591 | ctxcxx . . $ ctx.->glGetObjectParameterivARBcxx . . $ MOJOSHADER_glContext#glGetObjectParameterivARB.(program, GL_OBJECT_LINK_STATUS_ARBcxx . . $ `GL/glext.h:1552:9`!, &ok); |
| 592 | if (!ok) |
| 593 | { |
| 594 | GLsizeicxx . . $ GLsizei# len = 0; |
| 595 | ctxcxx . . $ ctx.->glGetInfoLogARBcxx . . $ MOJOSHADER_glContext#glGetInfoLogARB.(program, sizeof (error_buffercxx . . $ error_buffer.), |
| 596 | &len, (GLcharARBcxx . . $ GLcharARB# *) error_buffercxx . . $ error_buffer.); |
| 597 | ctxcxx . . $ ctx.->glDeleteObjectARBcxx . . $ MOJOSHADER_glContext#glDeleteObjectARB.(program); |
| 598 | return 0; |
| 599 | } // if |
| 600 | |
| 601 | return (GLuintcxx . . $ GLuint#) program; |
| 602 | } // else |
| 603 | } // impl_SPIRV_LinkProgram |
| 604 | |
| 605 | static void impl_SPIRV_DeleteShadercxx . . $ impl_SPIRV_DeleteShader(cb2f890c2fdad230).(const GLuintcxx . . $ GLuint# shader) |
| 606 | { |
| 607 | ctxcxx . . $ ctx.->glDeleteShadercxx . . $ MOJOSHADER_glContext#glDeleteShader.(shader); |
| 608 | } // impl_SPIRV_DeleteShader |
| 609 | |
| 610 | static void impl_SPIRV_DeleteProgramcxx . . $ impl_SPIRV_DeleteProgram(cb2f890c2fdad230).(const GLuintcxx . . $ GLuint# program) |
| 611 | { |
| 612 | if (ctxcxx . . $ ctx.->have_opengl_2cxx . . $ MOJOSHADER_glContext#have_opengl_2.) |
| 613 | ctxcxx . . $ ctx.->glDeleteProgramcxx . . $ MOJOSHADER_glContext#glDeleteProgram.(program); |
| 614 | else |
| 615 | ctxcxx . . $ ctx.->glDeleteObjectARBcxx . . $ MOJOSHADER_glContext#glDeleteObjectARB.((GLhandleARBcxx . . $ GLhandleARB#) program); |
| 616 | } // impl_SPIRV_DeleteProgram |
| 617 | |
| 618 | static GLintcxx . . $ GLint# impl_SPIRV_GetAttribLocationcxx . . $ impl_SPIRV_GetAttribLocation(68cbdf50a567c948).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program, int idx) |
| 619 | { |
| 620 | return idx; |
| 621 | } // impl_SPIRV_GetAttribLocation |
| 622 | |
| 623 | static GLintcxx . . $ GLint# impl_SPIRV_GetUniformLocationcxx . . $ impl_SPIRV_GetUniformLocation(68ce97c0384b6dea).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program, MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *shader, int idx) |
| 624 | { |
| 625 | return 0; // no-op, we push this as one big-ass array now. |
| 626 | } // impl_SPIRV_GetUniformLocation |
| 627 | |
| 628 | static GLintcxx . . $ GLint# impl_SPIRV_GetSamplerLocationcxx . . $ impl_SPIRV_GetSamplerLocation(68ce97c0384b6dea).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program, MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *shader, int idx) |
| 629 | { |
| 630 | const SpirvPatchTablecxx . . $ SpirvPatchTable# *table = spv_getPatchTablecxx . . $ spv_getPatchTable(18150a3aca5512d4).(shader); |
| 631 | GLintcxx . . $ GLint# location = table->samplerscxx . . $ SpirvPatchTable#samplers.[idx].locationcxx . . $ SpirvPatchEntry#location.; |
| 632 | if (location == -1) |
| 633 | return location; |
| 634 | |
| 635 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(location >= 0); |
| 636 | if (shader->parseDatacxx . . $ MOJOSHADER_glShader#parseData.->shader_typecxx . . $ MOJOSHADER_parseData#shader_type. == MOJOSHADER_TYPE_PIXELcxx . . $ MOJOSHADER_TYPE_PIXEL.) |
| 637 | location += spv_getPatchTablecxx . . $ spv_getPatchTable(18150a3aca5512d4).(program->vertexcxx . . $ MOJOSHADER_glProgram#vertex.)->location_countcxx . . $ SpirvPatchTable#location_count.; |
| 638 | |
| 639 | return location; |
| 640 | } // impl_SPIRV_GetSamplerLocation |
| 641 | |
| 642 | static void impl_SPIRV_FinalInitProgramcxx . . $ impl_SPIRV_FinalInitProgram(b6cc5ff6e33eca9d).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program) |
| 643 | { |
| 644 | const SpirvPatchTablecxx . . $ SpirvPatchTable# *vs_table = spv_getPatchTablecxx . . $ spv_getPatchTable(18150a3aca5512d4).(program->vertexcxx . . $ MOJOSHADER_glProgram#vertex.); |
| 645 | const SpirvPatchTablecxx . . $ SpirvPatchTable# *ps_table = spv_getPatchTablecxx . . $ spv_getPatchTable(18150a3aca5512d4).(program->fragmentcxx . . $ MOJOSHADER_glProgram#fragment.); |
| 646 | program->vs_float4_loccxx . . $ MOJOSHADER_glProgram#vs_float4_loc. = vs_table->array_vec4cxx . . $ SpirvPatchTable#array_vec4..locationcxx . . $ SpirvPatchEntry#location.; |
| 647 | program->vs_int4_loccxx . . $ MOJOSHADER_glProgram#vs_int4_loc. = vs_table->array_ivec4cxx . . $ SpirvPatchTable#array_ivec4..locationcxx . . $ SpirvPatchEntry#location.; |
| 648 | program->vs_bool_loccxx . . $ MOJOSHADER_glProgram#vs_bool_loc. = vs_table->array_boolcxx . . $ SpirvPatchTable#array_bool..locationcxx . . $ SpirvPatchEntry#location.; |
| 649 | program->ps_float4_loccxx . . $ MOJOSHADER_glProgram#ps_float4_loc. = ps_table->array_vec4cxx . . $ SpirvPatchTable#array_vec4..locationcxx . . $ SpirvPatchEntry#location.; |
| 650 | program->ps_int4_loccxx . . $ MOJOSHADER_glProgram#ps_int4_loc. = ps_table->array_ivec4cxx . . $ SpirvPatchTable#array_ivec4..locationcxx . . $ SpirvPatchEntry#location.; |
| 651 | program->ps_bool_loccxx . . $ MOJOSHADER_glProgram#ps_bool_loc. = ps_table->array_boolcxx . . $ SpirvPatchTable#array_bool..locationcxx . . $ SpirvPatchEntry#location.; |
| 652 | program->ps_vpos_flip_loccxx . . $ MOJOSHADER_glProgram#ps_vpos_flip_loc. = ps_table->vpflipcxx . . $ SpirvPatchTable#vpflip..locationcxx . . $ SpirvPatchEntry#location.; |
| 653 | #ifdef MOJOSHADER_FLIP_RENDERTARGET |
| 654 | program->vs_flip_loc = vs_table->vpflip.location; |
| 655 | #endif |
| 656 | |
| 657 | int32cxx . . $ int32# ps_base_location = vs_table->location_countcxx . . $ SpirvPatchTable#location_count.; |
| 658 | if (ps_base_location) |
| 659 | { |
| 660 | if (program->ps_float4_loccxx . . $ MOJOSHADER_glProgram#ps_float4_loc. != -1) program->ps_float4_loccxx . . $ MOJOSHADER_glProgram#ps_float4_loc. += ps_base_location; |
| 661 | if (program->ps_int4_loccxx . . $ MOJOSHADER_glProgram#ps_int4_loc. != -1) program->ps_int4_loccxx . . $ MOJOSHADER_glProgram#ps_int4_loc. += ps_base_location; |
| 662 | if (program->ps_bool_loccxx . . $ MOJOSHADER_glProgram#ps_bool_loc. != -1) program->ps_bool_loccxx . . $ MOJOSHADER_glProgram#ps_bool_loc. += ps_base_location; |
| 663 | if (program->ps_vpos_flip_loccxx . . $ MOJOSHADER_glProgram#ps_vpos_flip_loc. != -1) program->ps_vpos_flip_loccxx . . $ MOJOSHADER_glProgram#ps_vpos_flip_loc. += ps_base_location; |
| 664 | } // if |
| 665 | } // impl_SPIRV_FinalInitProgram |
| 666 | #endif // SUPPORT_PROFILE_GLSPIRV |
| 667 | |
| 668 | #if SUPPORT_PROFILE_GLSLcxx . . $ `mojoshader_internal.h:182:9`! |
| 669 | static int impl_GLSL_CompileShadercxx . . $ impl_GLSL_CompileShader(ec98bc26451bb3a1).(const MOJOSHADER_parseDatacxx . . $ MOJOSHADER_parseData# *pd, GLuintcxx . . $ GLuint# *s) |
| 670 | { |
| 671 | GLintcxx . . $ GLint# ok = 0; |
| 672 | const GLintcxx . . $ GLint# codelen = (GLintcxx . . $ GLint#) pd->output_lencxx . . $ MOJOSHADER_parseData#output_len.; |
| 673 | const GLenumcxx . . $ GLenum# shader_type = glsl_shader_typecxx . . $ glsl_shader_type(6ba2cb23bc7c8a0c).(pd->shader_typecxx . . $ MOJOSHADER_parseData#shader_type.); |
| 674 | |
| 675 | if (ctxcxx . . $ ctx.->have_opengl_2cxx . . $ MOJOSHADER_glContext#have_opengl_2.) |
| 676 | { |
| 677 | const GLuintcxx . . $ GLuint# shader = ctxcxx . . $ ctx.->glCreateShadercxx . . $ MOJOSHADER_glContext#glCreateShader.(shader_type); |
| 678 | ctxcxx . . $ ctx.->glShaderSourcecxx . . $ MOJOSHADER_glContext#glShaderSource.(shader, 1, (const GLcharcxx . . $ GLchar#**) &pd->outputcxx . . $ MOJOSHADER_parseData#output., &codelen); |
| 679 | ctxcxx . . $ ctx.->glCompileShadercxx . . $ MOJOSHADER_glContext#glCompileShader.(shader); |
| 680 | ctxcxx . . $ ctx.->glGetShaderivcxx . . $ MOJOSHADER_glContext#glGetShaderiv.(shader, GL_COMPILE_STATUScxx . . $ `GL/glext.h:447:9`!, &ok); |
| 681 | if (!ok) |
| 682 | { |
| 683 | GLsizeicxx . . $ GLsizei# len = 0; |
| 684 | ctxcxx . . $ ctx.->glGetShaderInfoLogcxx . . $ MOJOSHADER_glContext#glGetShaderInfoLog.(shader, sizeof (error_buffercxx . . $ error_buffer.), &len, |
| 685 | (GLcharcxx . . $ GLchar# *) error_buffercxx . . $ error_buffer.); |
| 686 | ctxcxx . . $ ctx.->glDeleteShadercxx . . $ MOJOSHADER_glContext#glDeleteShader.(shader); |
| 687 | *s = 0; |
| 688 | return 0; |
| 689 | } // if |
| 690 | |
| 691 | *s = shader; |
| 692 | } // if |
| 693 | else |
| 694 | { |
| 695 | const GLhandleARBcxx . . $ GLhandleARB# shader = ctxcxx . . $ ctx.->glCreateShaderObjectARBcxx . . $ MOJOSHADER_glContext#glCreateShaderObjectARB.(shader_type); |
| 696 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(sizeof (shader) == sizeof (*s)); // not always true on OS X! |
| 697 | ctxcxx . . $ ctx.->glShaderSourceARBcxx . . $ MOJOSHADER_glContext#glShaderSourceARB.(shader, 1, |
| 698 | (const GLcharARBcxx . . $ GLcharARB# **) &pd->outputcxx . . $ MOJOSHADER_parseData#output., &codelen); |
| 699 | ctxcxx . . $ ctx.->glCompileShaderARBcxx . . $ MOJOSHADER_glContext#glCompileShaderARB.(shader); |
| 700 | ctxcxx . . $ ctx.->glGetObjectParameterivARBcxx . . $ MOJOSHADER_glContext#glGetObjectParameterivARB.(shader,GL_OBJECT_COMPILE_STATUS_ARBcxx . . $ `GL/glext.h:1551:9`!,&ok); |
| 701 | if (!ok) |
| 702 | { |
| 703 | GLsizeicxx . . $ GLsizei# len = 0; |
| 704 | ctxcxx . . $ ctx.->glGetInfoLogARBcxx . . $ MOJOSHADER_glContext#glGetInfoLogARB.(shader, sizeof (error_buffercxx . . $ error_buffer.), &len, |
| 705 | (GLcharARBcxx . . $ GLcharARB# *) error_buffercxx . . $ error_buffer.); |
| 706 | ctxcxx . . $ ctx.->glDeleteObjectARBcxx . . $ MOJOSHADER_glContext#glDeleteObjectARB.(shader); |
| 707 | *s = 0; |
| 708 | return 0; |
| 709 | } // if |
| 710 | |
| 711 | *s = (GLuintcxx . . $ GLuint#) shader; |
| 712 | } // else |
| 713 | |
| 714 | return 1; |
| 715 | } // impl_GLSL_CompileShader |
| 716 | #endif // SUPPORT_PROFILE_GLSL |
| 717 | |
| 718 | |
| 719 | static void impl_GLSL_DeleteShadercxx . . $ impl_GLSL_DeleteShader(cb2f890c2fdad230).(const GLuintcxx . . $ GLuint# shader) |
| 720 | { |
| 721 | if (ctxcxx . . $ ctx.->have_opengl_2cxx . . $ MOJOSHADER_glContext#have_opengl_2.) |
| 722 | ctxcxx . . $ ctx.->glDeleteShadercxx . . $ MOJOSHADER_glContext#glDeleteShader.(shader); |
| 723 | else |
| 724 | ctxcxx . . $ ctx.->glDeleteObjectARBcxx . . $ MOJOSHADER_glContext#glDeleteObjectARB.((GLhandleARBcxx . . $ GLhandleARB#) shader); |
| 725 | } // impl_GLSL_DeleteShader |
| 726 | |
| 727 | |
| 728 | static void impl_GLSL_DeleteProgramcxx . . $ impl_GLSL_DeleteProgram(cb2f890c2fdad230).(const GLuintcxx . . $ GLuint# program) |
| 729 | { |
| 730 | if (ctxcxx . . $ ctx.->have_opengl_2cxx . . $ MOJOSHADER_glContext#have_opengl_2.) |
| 731 | ctxcxx . . $ ctx.->glDeleteProgramcxx . . $ MOJOSHADER_glContext#glDeleteProgram.(program); |
| 732 | else |
| 733 | ctxcxx . . $ ctx.->glDeleteObjectARBcxx . . $ MOJOSHADER_glContext#glDeleteObjectARB.((GLhandleARBcxx . . $ GLhandleARB#) program); |
| 734 | } // impl_GLSL_DeleteProgram |
| 735 | |
| 736 | |
| 737 | static GLintcxx . . $ GLint# impl_GLSL_GetUniformLocationcxx . . $ impl_GLSL_GetUniformLocation(68ce97c0384b6dea).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program, |
| 738 | MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *shader, int idx) |
| 739 | { |
| 740 | return 0; // no-op, we push this as one big-ass array now. |
| 741 | } // impl_GLSL_GetUniformLocation |
| 742 | |
| 743 | |
| 744 | static inline GLintcxx . . $ GLint# glsl_uniform_loccxx . . $ glsl_uniform_loc(737fa11bb7f5ab57).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program, |
| 745 | const char *name) |
| 746 | { |
| 747 | return ctxcxx . . $ ctx.->have_opengl_2cxx . . $ MOJOSHADER_glContext#have_opengl_2. ? |
| 748 | ctxcxx . . $ ctx.->glGetUniformLocationcxx . . $ MOJOSHADER_glContext#glGetUniformLocation.(program->handlecxx . . $ MOJOSHADER_glProgram#handle., name) : |
| 749 | ctxcxx . . $ ctx.->glGetUniformLocationARBcxx . . $ MOJOSHADER_glContext#glGetUniformLocationARB.((GLhandleARBcxx . . $ GLhandleARB#) program->handlecxx . . $ MOJOSHADER_glProgram#handle., name); |
| 750 | } // glsl_uniform_loc |
| 751 | |
| 752 | |
| 753 | static GLintcxx . . $ GLint# impl_GLSL_GetSamplerLocationcxx . . $ impl_GLSL_GetSamplerLocation(68ce97c0384b6dea).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program, |
| 754 | MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *shader, int idx) |
| 755 | { |
| 756 | return glsl_uniform_loccxx . . $ glsl_uniform_loc(737fa11bb7f5ab57).(program, shader->parseDatacxx . . $ MOJOSHADER_glShader#parseData.->samplerscxx . . $ MOJOSHADER_parseData#samplers.[idx].namecxx . . $ MOJOSHADER_sampler#name.); |
| 757 | } // impl_GLSL_GetSamplerLocation |
| 758 | |
| 759 | |
| 760 | static GLintcxx . . $ GLint# impl_GLSL_GetAttribLocationcxx . . $ impl_GLSL_GetAttribLocation(68cbdf50a567c948).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program, int idx) |
| 761 | { |
| 762 | const MOJOSHADER_parseDatacxx . . $ MOJOSHADER_parseData# *pd = program->vertexcxx . . $ MOJOSHADER_glProgram#vertex.->parseDatacxx . . $ MOJOSHADER_glShader#parseData.; |
| 763 | const MOJOSHADER_attributecxx . . $ MOJOSHADER_attribute# *a = pd->attributescxx . . $ MOJOSHADER_parseData#attributes.; |
| 764 | |
| 765 | if (ctxcxx . . $ ctx.->have_opengl_2cxx . . $ MOJOSHADER_glContext#have_opengl_2.) |
| 766 | { |
| 767 | return ctxcxx . . $ ctx.->glGetAttribLocationcxx . . $ MOJOSHADER_glContext#glGetAttribLocation.(program->handlecxx . . $ MOJOSHADER_glProgram#handle., |
| 768 | (const GLcharcxx . . $ GLchar# *) a[idx].namecxx . . $ MOJOSHADER_attribute#name.); |
| 769 | } // if |
| 770 | |
| 771 | return ctxcxx . . $ ctx.->glGetAttribLocationARBcxx . . $ MOJOSHADER_glContext#glGetAttribLocationARB.((GLhandleARBcxx . . $ GLhandleARB#) program->handlecxx . . $ MOJOSHADER_glProgram#handle., |
| 772 | (const GLcharARBcxx . . $ GLcharARB# *) a[idx].namecxx . . $ MOJOSHADER_attribute#name.); |
| 773 | } // impl_GLSL_GetAttribLocation |
| 774 | |
| 775 | |
| 776 | static GLuintcxx . . $ GLuint# impl_GLSL_LinkProgramcxx . . $ impl_GLSL_LinkProgram(3128a097761c2828).(MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *vshader, |
| 777 | MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *pshader) |
| 778 | { |
| 779 | GLintcxx . . $ GLint# ok = 0; |
| 780 | |
| 781 | if (ctxcxx . . $ ctx.->have_opengl_2cxx . . $ MOJOSHADER_glContext#have_opengl_2.) |
| 782 | { |
| 783 | const GLuintcxx . . $ GLuint# program = ctxcxx . . $ ctx.->glCreateProgramcxx . . $ MOJOSHADER_glContext#glCreateProgram.(); |
| 784 | |
| 785 | if (vshader != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ctxcxx . . $ ctx.->glAttachShadercxx . . $ MOJOSHADER_glContext#glAttachShader.(program, vshader->handlecxx . . $ MOJOSHADER_glShader#handle.); |
| 786 | if (pshader != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ctxcxx . . $ ctx.->glAttachShadercxx . . $ MOJOSHADER_glContext#glAttachShader.(program, pshader->handlecxx . . $ MOJOSHADER_glShader#handle.); |
| 787 | |
| 788 | ctxcxx . . $ ctx.->glLinkProgramcxx . . $ MOJOSHADER_glContext#glLinkProgram.(program); |
| 789 | |
| 790 | ctxcxx . . $ ctx.->glGetProgramivcxx . . $ MOJOSHADER_glContext#glGetProgramiv.(program, GL_LINK_STATUScxx . . $ `GL/glext.h:448:9`!, &ok); |
| 791 | if (!ok) |
| 792 | { |
| 793 | GLsizeicxx . . $ GLsizei# len = 0; |
| 794 | ctxcxx . . $ ctx.->glGetProgramInfoLogcxx . . $ MOJOSHADER_glContext#glGetProgramInfoLog.(program, sizeof (error_buffercxx . . $ error_buffer.), |
| 795 | &len, (GLcharcxx . . $ GLchar# *) error_buffercxx . . $ error_buffer.); |
| 796 | ctxcxx . . $ ctx.->glDeleteProgramcxx . . $ MOJOSHADER_glContext#glDeleteProgram.(program); |
| 797 | return 0; |
| 798 | } // if |
| 799 | |
| 800 | return program; |
| 801 | } // if |
| 802 | else |
| 803 | { |
| 804 | const GLhandleARBcxx . . $ GLhandleARB# program = ctxcxx . . $ ctx.->glCreateProgramObjectARBcxx . . $ MOJOSHADER_glContext#glCreateProgramObjectARB.(); |
| 805 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(sizeof(program) == sizeof(GLuint)); // not always true on OS X! |
| 806 | |
| 807 | if (vshader != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 808 | ctxcxx . . $ ctx.->glAttachObjectARBcxx . . $ MOJOSHADER_glContext#glAttachObjectARB.(program, (GLhandleARBcxx . . $ GLhandleARB#) vshader->handlecxx . . $ MOJOSHADER_glShader#handle.); |
| 809 | |
| 810 | if (pshader != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 811 | ctxcxx . . $ ctx.->glAttachObjectARBcxx . . $ MOJOSHADER_glContext#glAttachObjectARB.(program, (GLhandleARBcxx . . $ GLhandleARB#) pshader->handlecxx . . $ MOJOSHADER_glShader#handle.); |
| 812 | |
| 813 | ctxcxx . . $ ctx.->glLinkProgramARBcxx . . $ MOJOSHADER_glContext#glLinkProgramARB.(program); |
| 814 | |
| 815 | ctxcxx . . $ ctx.->glGetObjectParameterivARBcxx . . $ MOJOSHADER_glContext#glGetObjectParameterivARB.(program, GL_OBJECT_LINK_STATUS_ARBcxx . . $ `GL/glext.h:1552:9`!, &ok); |
| 816 | if (!ok) |
| 817 | { |
| 818 | GLsizeicxx . . $ GLsizei# len = 0; |
| 819 | ctxcxx . . $ ctx.->glGetInfoLogARBcxx . . $ MOJOSHADER_glContext#glGetInfoLogARB.(program, sizeof (error_buffercxx . . $ error_buffer.), |
| 820 | &len, (GLcharARBcxx . . $ GLcharARB# *) error_buffercxx . . $ error_buffer.); |
| 821 | ctxcxx . . $ ctx.->glDeleteObjectARBcxx . . $ MOJOSHADER_glContext#glDeleteObjectARB.(program); |
| 822 | return 0; |
| 823 | } // if |
| 824 | |
| 825 | return (GLuintcxx . . $ GLuint#) program; |
| 826 | } // else |
| 827 | } // impl_GLSL_LinkProgram |
| 828 | |
| 829 | static void impl_GLSL_FinalInitProgramcxx . . $ impl_GLSL_FinalInitProgram(b6cc5ff6e33eca9d).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program) |
| 830 | { |
| 831 | program->vs_float4_loccxx . . $ MOJOSHADER_glProgram#vs_float4_loc. = glsl_uniform_loccxx . . $ glsl_uniform_loc(737fa11bb7f5ab57).(program, "vs_uniforms_vec4"); |
| 832 | program->vs_int4_loccxx . . $ MOJOSHADER_glProgram#vs_int4_loc. = glsl_uniform_loccxx . . $ glsl_uniform_loc(737fa11bb7f5ab57).(program, "vs_uniforms_ivec4"); |
| 833 | program->vs_bool_loccxx . . $ MOJOSHADER_glProgram#vs_bool_loc. = glsl_uniform_loccxx . . $ glsl_uniform_loc(737fa11bb7f5ab57).(program, "vs_uniforms_bool"); |
| 834 | program->ps_float4_loccxx . . $ MOJOSHADER_glProgram#ps_float4_loc. = glsl_uniform_loccxx . . $ glsl_uniform_loc(737fa11bb7f5ab57).(program, "ps_uniforms_vec4"); |
| 835 | program->ps_int4_loccxx . . $ MOJOSHADER_glProgram#ps_int4_loc. = glsl_uniform_loccxx . . $ glsl_uniform_loc(737fa11bb7f5ab57).(program, "ps_uniforms_ivec4"); |
| 836 | program->ps_bool_loccxx . . $ MOJOSHADER_glProgram#ps_bool_loc. = glsl_uniform_loccxx . . $ glsl_uniform_loc(737fa11bb7f5ab57).(program, "ps_uniforms_bool"); |
| 837 | program->ps_vpos_flip_loccxx . . $ MOJOSHADER_glProgram#ps_vpos_flip_loc. = glsl_uniform_loccxx . . $ glsl_uniform_loc(737fa11bb7f5ab57).(program, "vposFlip"); |
| 838 | #ifdef MOJOSHADER_FLIP_RENDERTARGET |
| 839 | program->vs_flip_loc = glsl_uniform_loc(program, "vpFlip"); |
| 840 | #endif |
| 841 | } // impl_GLSL_FinalInitProgram |
| 842 | |
| 843 | |
| 844 | static void impl_GLSL_UseProgramcxx . . $ impl_GLSL_UseProgram(b6cc5ff6e33eca9d).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program) |
| 845 | { |
| 846 | if (ctxcxx . . $ ctx.->have_opengl_2cxx . . $ MOJOSHADER_glContext#have_opengl_2.) |
| 847 | ctxcxx . . $ ctx.->glUseProgramcxx . . $ MOJOSHADER_glContext#glUseProgram.(program ? program->handlecxx . . $ MOJOSHADER_glProgram#handle. : 0); |
| 848 | else |
| 849 | ctxcxx . . $ ctx.->glUseProgramObjectARBcxx . . $ MOJOSHADER_glContext#glUseProgramObjectARB.((GLhandleARBcxx . . $ GLhandleARB#) (program ? program->handlecxx . . $ MOJOSHADER_glProgram#handle. : 0)); |
| 850 | } // impl_GLSL_UseProgram |
| 851 | |
| 852 | |
| 853 | static void impl_GLSL_PushConstantArraycxx . . $ impl_GLSL_PushConstantArray(d04408542d836fa4).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program, |
| 854 | const MOJOSHADER_uniformcxx . . $ MOJOSHADER_uniform# *u, |
| 855 | const GLfloatcxx . . $ GLfloat# *f) |
| 856 | { |
| 857 | const GLintcxx . . $ GLint# loc = glsl_uniform_loccxx . . $ glsl_uniform_loc(737fa11bb7f5ab57).(program, u->namecxx . . $ MOJOSHADER_uniform#name.); |
| 858 | if (loc >= 0) // not optimized out? |
| 859 | ctxcxx . . $ ctx.->glUniform4fvcxx . . $ MOJOSHADER_glContext#glUniform4fv.(loc, u->array_countcxx . . $ MOJOSHADER_uniform#array_count., f); |
| 860 | } // impl_GLSL_PushConstantArray |
| 861 | |
| 862 | |
| 863 | static void impl_GLSL_PushUniformscxx . . $ impl_GLSL_PushUniforms(49f6e7a06ebc5aa8).(void) |
| 864 | { |
| 865 | const MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program = ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program.; |
| 866 | |
| 867 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(program->uniform_count > 0); // don't call with nothing to do! |
| 868 | |
| 869 | if (program->vs_float4_loccxx . . $ MOJOSHADER_glProgram#vs_float4_loc. != -1) |
| 870 | { |
| 871 | ctxcxx . . $ ctx.->glUniform4fvcxx . . $ MOJOSHADER_glContext#glUniform4fv.(program->vs_float4_loccxx . . $ MOJOSHADER_glProgram#vs_float4_loc., |
| 872 | program->vs_uniforms_float4_countcxx . . $ MOJOSHADER_glProgram#vs_uniforms_float4_count., |
| 873 | program->vs_uniforms_float4cxx . . $ MOJOSHADER_glProgram#vs_uniforms_float4.); |
| 874 | } // if |
| 875 | |
| 876 | if (program->vs_int4_loccxx . . $ MOJOSHADER_glProgram#vs_int4_loc. != -1) |
| 877 | { |
| 878 | ctxcxx . . $ ctx.->glUniform4ivcxx . . $ MOJOSHADER_glContext#glUniform4iv.(program->vs_int4_loccxx . . $ MOJOSHADER_glProgram#vs_int4_loc., |
| 879 | program->vs_uniforms_int4_countcxx . . $ MOJOSHADER_glProgram#vs_uniforms_int4_count., |
| 880 | program->vs_uniforms_int4cxx . . $ MOJOSHADER_glProgram#vs_uniforms_int4.); |
| 881 | } // if |
| 882 | |
| 883 | if (program->vs_bool_loccxx . . $ MOJOSHADER_glProgram#vs_bool_loc. != -1) |
| 884 | { |
| 885 | ctxcxx . . $ ctx.->glUniform1ivcxx . . $ MOJOSHADER_glContext#glUniform1iv.(program->vs_bool_loccxx . . $ MOJOSHADER_glProgram#vs_bool_loc., |
| 886 | program->vs_uniforms_bool_countcxx . . $ MOJOSHADER_glProgram#vs_uniforms_bool_count., |
| 887 | program->vs_uniforms_boolcxx . . $ MOJOSHADER_glProgram#vs_uniforms_bool.); |
| 888 | } // if |
| 889 | |
| 890 | if (program->ps_float4_loccxx . . $ MOJOSHADER_glProgram#ps_float4_loc. != -1) |
| 891 | { |
| 892 | ctxcxx . . $ ctx.->glUniform4fvcxx . . $ MOJOSHADER_glContext#glUniform4fv.(program->ps_float4_loccxx . . $ MOJOSHADER_glProgram#ps_float4_loc., |
| 893 | program->ps_uniforms_float4_countcxx . . $ MOJOSHADER_glProgram#ps_uniforms_float4_count., |
| 894 | program->ps_uniforms_float4cxx . . $ MOJOSHADER_glProgram#ps_uniforms_float4.); |
| 895 | } // if |
| 896 | |
| 897 | if (program->ps_int4_loccxx . . $ MOJOSHADER_glProgram#ps_int4_loc. != -1) |
| 898 | { |
| 899 | ctxcxx . . $ ctx.->glUniform4ivcxx . . $ MOJOSHADER_glContext#glUniform4iv.(program->ps_int4_loccxx . . $ MOJOSHADER_glProgram#ps_int4_loc., |
| 900 | program->ps_uniforms_int4_countcxx . . $ MOJOSHADER_glProgram#ps_uniforms_int4_count., |
| 901 | program->ps_uniforms_int4cxx . . $ MOJOSHADER_glProgram#ps_uniforms_int4.); |
| 902 | } // if |
| 903 | |
| 904 | if (program->ps_bool_loccxx . . $ MOJOSHADER_glProgram#ps_bool_loc. != -1) |
| 905 | { |
| 906 | ctxcxx . . $ ctx.->glUniform1ivcxx . . $ MOJOSHADER_glContext#glUniform1iv.(program->ps_bool_loccxx . . $ MOJOSHADER_glProgram#ps_bool_loc., |
| 907 | program->ps_uniforms_bool_countcxx . . $ MOJOSHADER_glProgram#ps_uniforms_bool_count., |
| 908 | program->ps_uniforms_boolcxx . . $ MOJOSHADER_glProgram#ps_uniforms_bool.); |
| 909 | } // if |
| 910 | } // impl_GLSL_PushUniforms |
| 911 | |
| 912 | |
| 913 | static void impl_GLSL_PushSamplercxx . . $ impl_GLSL_PushSampler(c8dafc4a64bf4a1c).(GLintcxx . . $ GLint# loc, GLuintcxx . . $ GLuint# sampler) |
| 914 | { |
| 915 | ctxcxx . . $ ctx.->glUniform1icxx . . $ MOJOSHADER_glContext#glUniform1i.(loc, sampler); |
| 916 | } // impl_GLSL_PushSampler |
| 917 | |
| 918 | #endif // SUPPORT_PROFILE_GLSL || SUPPORT_PROFILE_GLSPIRV |
| 919 | |
| 920 | |
| 921 | #if SUPPORT_PROFILE_ARB1cxx . . $ `mojoshader_internal.h:198:9`! |
| 922 | static inline GLenumcxx . . $ GLenum# arb1_shader_typecxx . . $ arb1_shader_type(6ba2cb23bc7c8a0c).(const MOJOSHADER_shaderTypecxx . . $ MOJOSHADER_shaderType# t) |
| 923 | { |
| 924 | if (t == MOJOSHADER_TYPE_VERTEXcxx . . $ MOJOSHADER_TYPE_VERTEX.) |
| 925 | return GL_VERTEX_PROGRAM_ARBcxx . . $ `GL/glext.h:1384:9`!; |
| 926 | else if (t == MOJOSHADER_TYPE_PIXELcxx . . $ MOJOSHADER_TYPE_PIXEL.) |
| 927 | return GL_FRAGMENT_PROGRAM_ARBcxx . . $ `GL/glext.h:1465:9`!; |
| 928 | |
| 929 | // !!! FIXME: geometry shaders? |
| 930 | return GL_NONEcxx . . $ `<external>/11565930711847777359/gl.h:431:9`!; |
| 931 | } // arb1_shader_type |
| 932 | |
| 933 | static int impl_ARB1_MustPushConstantArrayscxx . . $ impl_ARB1_MustPushConstantArrays(b126dc7c1de90089).(void) { return 0; } |
| 934 | static int impl_ARB1_MustPushSamplerscxx . . $ impl_ARB1_MustPushSamplers(b126dc7c1de90089).(void) { return 0; } |
| 935 | |
| 936 | static int impl_ARB1_MaxUniformscxx . . $ impl_ARB1_MaxUniforms(31af91354e387fe).(MOJOSHADER_shaderTypecxx . . $ MOJOSHADER_shaderType# shader_type) |
| 937 | { |
| 938 | GLintcxx . . $ GLint# retval = 0; |
| 939 | const GLenumcxx . . $ GLenum# program_type = arb1_shader_typecxx . . $ arb1_shader_type(6ba2cb23bc7c8a0c).(shader_type); |
| 940 | if (program_type == GL_NONEcxx . . $ `<external>/11565930711847777359/gl.h:431:9`!) |
| 941 | return -1; |
| 942 | |
| 943 | ctxcxx . . $ ctx.->glGetProgramivARBcxx . . $ MOJOSHADER_glContext#glGetProgramivARB.(program_type, GL_MAX_PROGRAM_PARAMETERS_ARBcxx . . $ `GL/glext.h:1415:9`!, &retval); |
| 944 | return (int) retval; // !!! FIXME: times four? |
| 945 | } // impl_ARB1_MaxUniforms |
| 946 | |
| 947 | |
| 948 | static int impl_ARB1_CompileShadercxx . . $ impl_ARB1_CompileShader(ec98bc26451bb3a1).(const MOJOSHADER_parseDatacxx . . $ MOJOSHADER_parseData# *pd, GLuintcxx . . $ GLuint# *s) |
| 949 | { |
| 950 | GLintcxx . . $ GLint# shaderlen = (GLintcxx . . $ GLint#) pd->output_lencxx . . $ MOJOSHADER_parseData#output_len.; |
| 951 | const GLenumcxx . . $ GLenum# shader_type = arb1_shader_typecxx . . $ arb1_shader_type(6ba2cb23bc7c8a0c).(pd->shader_typecxx . . $ MOJOSHADER_parseData#shader_type.); |
| 952 | GLuintcxx . . $ GLuint# shader = 0; |
| 953 | ctxcxx . . $ ctx.->glGenProgramsARBcxx . . $ MOJOSHADER_glContext#glGenProgramsARB.(1, &shader); |
| 954 | |
| 955 | ctxcxx . . $ ctx.->glGetErrorcxx . . $ MOJOSHADER_glContext#glGetError.(); // flush any existing error state. |
| 956 | ctxcxx . . $ ctx.->glBindProgramARBcxx . . $ MOJOSHADER_glContext#glBindProgramARB.(shader_type, shader); |
| 957 | ctxcxx . . $ ctx.->glProgramStringARBcxx . . $ MOJOSHADER_glContext#glProgramStringARB.(shader_type, GL_PROGRAM_FORMAT_ASCII_ARBcxx . . $ `GL/glext.h:1404:9`!, |
| 958 | shaderlen, pd->outputcxx . . $ MOJOSHADER_parseData#output.); |
| 959 | |
| 960 | if (ctxcxx . . $ ctx.->glGetErrorcxx . . $ MOJOSHADER_glContext#glGetError.() == GL_INVALID_OPERATIONcxx . . $ `<external>/11565930711847777359/gl.h:662:9`!) |
| 961 | { |
| 962 | GLintcxx . . $ GLint# pos = 0; |
| 963 | ctxcxx . . $ ctx.->glGetIntegervcxx . . $ MOJOSHADER_glContext#glGetIntegerv.(GL_PROGRAM_ERROR_POSITION_ARBcxx . . $ `GL/glext.h:1399:9`!, &pos); |
| 964 | const GLubytecxx . . $ GLubyte# *errstr = ctxcxx . . $ ctx.->glGetStringcxx . . $ MOJOSHADER_glContext#glGetString.(GL_PROGRAM_ERROR_STRING_ARBcxx . . $ `GL/glext.h:1403:9`!); |
| 965 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(error_buffercxx . . $ error_buffer., sizeof (error_buffercxx . . $ error_buffer.), |
| 966 | "ARB1 compile error at position %d: %s", |
| 967 | (int) pos, (const char *) errstr); |
| 968 | ctxcxx . . $ ctx.->glBindProgramARBcxx . . $ MOJOSHADER_glContext#glBindProgramARB.(shader_type, 0); |
| 969 | ctxcxx . . $ ctx.->glDeleteProgramsARBcxx . . $ MOJOSHADER_glContext#glDeleteProgramsARB.(1, &shader); |
| 970 | *s = 0; |
| 971 | return 0; |
| 972 | } // if |
| 973 | |
| 974 | *s = shader; |
| 975 | return 1; |
| 976 | } // impl_ARB1_CompileShader |
| 977 | |
| 978 | |
| 979 | static void impl_ARB1_DeleteShadercxx . . $ impl_ARB1_DeleteShader(cb2f890c2fdad230).(const GLuintcxx . . $ GLuint# _shader) |
| 980 | { |
| 981 | GLuintcxx . . $ GLuint# shader = _shader; // const removal. |
| 982 | ctxcxx . . $ ctx.->glDeleteProgramsARBcxx . . $ MOJOSHADER_glContext#glDeleteProgramsARB.(1, &shader); |
| 983 | } // impl_ARB1_DeleteShader |
| 984 | |
| 985 | |
| 986 | static void impl_ARB1_DeleteProgramcxx . . $ impl_ARB1_DeleteProgram(cb2f890c2fdad230).(const GLuintcxx . . $ GLuint# program) |
| 987 | { |
| 988 | // no-op. ARB1 doesn't have real linked programs. |
| 989 | } // impl_ARB1_DeleteProgram |
| 990 | |
| 991 | static GLintcxx . . $ GLint# impl_ARB1_GetUniformLocationcxx . . $ impl_ARB1_GetUniformLocation(68ce97c0384b6dea).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program, |
| 992 | MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *shader, int idx) |
| 993 | { |
| 994 | return 0; // no-op, we push this as one big-ass array now. |
| 995 | } // impl_ARB1_GetUniformLocation |
| 996 | |
| 997 | static GLintcxx . . $ GLint# impl_ARB1_GetSamplerLocationcxx . . $ impl_ARB1_GetSamplerLocation(68ce97c0384b6dea).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program, |
| 998 | MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *shader, int idx) |
| 999 | { |
| 1000 | return shader->parseDatacxx . . $ MOJOSHADER_glShader#parseData.->samplerscxx . . $ MOJOSHADER_parseData#samplers.[idx].indexcxx . . $ MOJOSHADER_sampler#index.; |
| 1001 | } // impl_ARB1_GetSamplerLocation |
| 1002 | |
| 1003 | |
| 1004 | static GLintcxx . . $ GLint# impl_ARB1_GetAttribLocationcxx . . $ impl_ARB1_GetAttribLocation(68cbdf50a567c948).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program, int idx) |
| 1005 | { |
| 1006 | return idx; // map to vertex arrays in the same order as the parseData. |
| 1007 | } // impl_ARB1_GetAttribLocation |
| 1008 | |
| 1009 | |
| 1010 | static GLuintcxx . . $ GLuint# impl_ARB1_LinkProgramcxx . . $ impl_ARB1_LinkProgram(3128a097761c2828).(MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *vshader, |
| 1011 | MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *pshader) |
| 1012 | { |
| 1013 | // there is no formal linking in ARB1...just return a unique value. |
| 1014 | static GLuintcxx . . $ GLuint# retval = 1; |
| 1015 | return retval++; |
| 1016 | } // impl_ARB1_LinkProgram |
| 1017 | |
| 1018 | |
| 1019 | static void impl_ARB1_FinalInitProgramcxx . . $ impl_ARB1_FinalInitProgram(b6cc5ff6e33eca9d).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program) |
| 1020 | { |
| 1021 | // no-op. |
| 1022 | } // impl_ARB1_FinalInitProgram |
| 1023 | |
| 1024 | |
| 1025 | static void impl_ARB1_UseProgramcxx . . $ impl_ARB1_UseProgram(b6cc5ff6e33eca9d).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program) |
| 1026 | { |
| 1027 | GLuintcxx . . $ GLuint# vhandle = 0; |
| 1028 | GLuintcxx . . $ GLuint# phandle = 0; |
| 1029 | if (program != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1030 | { |
| 1031 | if (program->vertexcxx . . $ MOJOSHADER_glProgram#vertex. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1032 | vhandle = program->vertexcxx . . $ MOJOSHADER_glProgram#vertex.->handlecxx . . $ MOJOSHADER_glShader#handle.; |
| 1033 | if (program->fragmentcxx . . $ MOJOSHADER_glProgram#fragment. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1034 | phandle = program->fragmentcxx . . $ MOJOSHADER_glProgram#fragment.->handlecxx . . $ MOJOSHADER_glShader#handle.; |
| 1035 | } // if |
| 1036 | |
| 1037 | toggle_gl_statecxx . . $ toggle_gl_state(3d89109e85ced1be).(GL_VERTEX_PROGRAM_ARBcxx . . $ `GL/glext.h:1384:9`!, vhandle != 0); |
| 1038 | toggle_gl_statecxx . . $ toggle_gl_state(3d89109e85ced1be).(GL_FRAGMENT_PROGRAM_ARBcxx . . $ `GL/glext.h:1465:9`!, phandle != 0); |
| 1039 | |
| 1040 | ctxcxx . . $ ctx.->glBindProgramARBcxx . . $ MOJOSHADER_glContext#glBindProgramARB.(GL_VERTEX_PROGRAM_ARBcxx . . $ `GL/glext.h:1384:9`!, vhandle); |
| 1041 | ctxcxx . . $ ctx.->glBindProgramARBcxx . . $ MOJOSHADER_glContext#glBindProgramARB.(GL_FRAGMENT_PROGRAM_ARBcxx . . $ `GL/glext.h:1465:9`!, phandle); |
| 1042 | } // impl_ARB1_UseProgram |
| 1043 | |
| 1044 | |
| 1045 | static void impl_ARB1_PushConstantArraycxx . . $ impl_ARB1_PushConstantArray(d04408542d836fa4).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program, |
| 1046 | const MOJOSHADER_uniformcxx . . $ MOJOSHADER_uniform# *u, |
| 1047 | const GLfloatcxx . . $ GLfloat# *f) |
| 1048 | { |
| 1049 | // no-op. Constant arrays are defined in source code for arb1. |
| 1050 | } // impl_ARB1_PushConstantArray |
| 1051 | |
| 1052 | |
| 1053 | static void impl_ARB1_PushUniformscxx . . $ impl_ARB1_PushUniforms(49f6e7a06ebc5aa8).(void) |
| 1054 | { |
| 1055 | // vertex shader uniforms come first in program->uniforms array. |
| 1056 | MOJOSHADER_shaderTypecxx . . $ MOJOSHADER_shaderType# shader_type = MOJOSHADER_TYPE_VERTEXcxx . . $ MOJOSHADER_TYPE_VERTEX.; |
| 1057 | GLenumcxx . . $ GLenum# arb_shader_type = arb1_shader_typecxx . . $ arb1_shader_type(6ba2cb23bc7c8a0c).(shader_type); |
| 1058 | const MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program = ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program.; |
| 1059 | const uint32cxx . . $ uint32# count = program->uniform_countcxx . . $ MOJOSHADER_glProgram#uniform_count.; |
| 1060 | const GLfloatcxx . . $ GLfloat# *srcf = program->vs_uniforms_float4cxx . . $ MOJOSHADER_glProgram#vs_uniforms_float4.; |
| 1061 | const GLintcxx . . $ GLint# *srci = program->vs_uniforms_int4cxx . . $ MOJOSHADER_glProgram#vs_uniforms_int4.; |
| 1062 | const GLintcxx . . $ GLint# *srcb = program->vs_uniforms_boolcxx . . $ MOJOSHADER_glProgram#vs_uniforms_bool.; |
| 1063 | GLintcxx . . $ GLint# loc = 0; |
| 1064 | GLintcxx . . $ GLint# texbem_loc = 0; |
| 1065 | uint32cxx . . $ uint32# i; |
| 1066 | |
| 1067 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(count > 0); // shouldn't call this with nothing to do! |
| 1068 | |
| 1069 | for (i = 0; i < count; i++) |
| 1070 | { |
| 1071 | UniformMapcxx . . $ UniformMap# *map = &program->uniformscxx . . $ MOJOSHADER_glProgram#uniforms.[i]; |
| 1072 | const MOJOSHADER_shaderTypecxx . . $ MOJOSHADER_shaderType# uniform_shader_type = map->shader_typecxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_0#shader_type.; |
| 1073 | const MOJOSHADER_uniformcxx . . $ MOJOSHADER_uniform# *u = map->uniformcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_0#uniform.; |
| 1074 | const MOJOSHADER_uniformTypecxx . . $ MOJOSHADER_uniformType# type = u->typecxx . . $ MOJOSHADER_uniform#type.; |
| 1075 | const int size = u->array_countcxx . . $ MOJOSHADER_uniform#array_count. ? u->array_countcxx . . $ MOJOSHADER_uniform#array_count. : 1; |
| 1076 | |
| 1077 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(!u->constant); |
| 1078 | |
| 1079 | // Did we switch from vertex to pixel (to geometry, etc)? |
| 1080 | if (shader_type != uniform_shader_type) |
| 1081 | { |
| 1082 | if (shader_type == MOJOSHADER_TYPE_PIXELcxx . . $ MOJOSHADER_TYPE_PIXEL.) |
| 1083 | texbem_loc = loc; |
| 1084 | |
| 1085 | // we start with vertex, move to pixel, then to geometry, etc. |
| 1086 | // The array should always be sorted as such. |
| 1087 | if (uniform_shader_type == MOJOSHADER_TYPE_PIXELcxx . . $ MOJOSHADER_TYPE_PIXEL.) |
| 1088 | { |
| 1089 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(shader_type == MOJOSHADER_TYPE_VERTEX); |
| 1090 | srcf = program->ps_uniforms_float4cxx . . $ MOJOSHADER_glProgram#ps_uniforms_float4.; |
| 1091 | srci = program->ps_uniforms_int4cxx . . $ MOJOSHADER_glProgram#ps_uniforms_int4.; |
| 1092 | srcb = program->ps_uniforms_boolcxx . . $ MOJOSHADER_glProgram#ps_uniforms_bool.; |
| 1093 | loc = 0; |
| 1094 | } // if |
| 1095 | else |
| 1096 | { |
| 1097 | // These should be ordered vertex, then pixel, then geometry. |
| 1098 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(0 && "Unexpected shader type"); |
| 1099 | } // else |
| 1100 | |
| 1101 | shader_type = uniform_shader_type; |
| 1102 | arb_shader_type = arb1_shader_typecxx . . $ arb1_shader_type(6ba2cb23bc7c8a0c).(uniform_shader_type); |
| 1103 | } // if |
| 1104 | |
| 1105 | if (type == MOJOSHADER_UNIFORM_FLOATcxx . . $ MOJOSHADER_UNIFORM_FLOAT.) |
| 1106 | { |
| 1107 | int i; |
| 1108 | for (i = 0; i < size; i++, srcf += 4, loc++) |
| 1109 | ctxcxx . . $ ctx.->glProgramLocalParameter4fvARBcxx . . $ MOJOSHADER_glContext#glProgramLocalParameter4fvARB.(arb_shader_type, loc, srcf); |
| 1110 | } // if |
| 1111 | else if (type == MOJOSHADER_UNIFORM_INTcxx . . $ MOJOSHADER_UNIFORM_INT.) |
| 1112 | { |
| 1113 | int i; |
| 1114 | if (ctxcxx . . $ ctx.->have_GL_NV_gpu_program4cxx . . $ MOJOSHADER_glContext#have_GL_NV_gpu_program4.) |
| 1115 | { |
| 1116 | // GL_NV_gpu_program4 has integer uniform loading support. |
| 1117 | for (i = 0; i < size; i++, srci += 4, loc++) |
| 1118 | ctxcxx . . $ ctx.->glProgramLocalParameterI4ivNVcxx . . $ MOJOSHADER_glContext#glProgramLocalParameterI4ivNV.(arb_shader_type, loc, srci); |
| 1119 | } // if |
| 1120 | else |
| 1121 | { |
| 1122 | for (i = 0; i < size; i++, srci += 4, loc++) |
| 1123 | { |
| 1124 | const GLfloatcxx . . $ GLfloat# fv[4] = { |
| 1125 | (GLfloatcxx . . $ GLfloat#) srci[0], (GLfloatcxx . . $ GLfloat#) srci[1], |
| 1126 | (GLfloatcxx . . $ GLfloat#) srci[2], (GLfloatcxx . . $ GLfloat#) srci[3] |
| 1127 | }; |
| 1128 | ctxcxx . . $ ctx.->glProgramLocalParameter4fvARBcxx . . $ MOJOSHADER_glContext#glProgramLocalParameter4fvARB.(arb_shader_type, loc, fv); |
| 1129 | } // for |
| 1130 | } // else |
| 1131 | } // else if |
| 1132 | else if (type == MOJOSHADER_UNIFORM_BOOLcxx . . $ MOJOSHADER_UNIFORM_BOOL.) |
| 1133 | { |
| 1134 | int i; |
| 1135 | if (ctxcxx . . $ ctx.->have_GL_NV_gpu_program4cxx . . $ MOJOSHADER_glContext#have_GL_NV_gpu_program4.) |
| 1136 | { |
| 1137 | // GL_NV_gpu_program4 has integer uniform loading support. |
| 1138 | for (i = 0; i < size; i++, srcb++, loc++) |
| 1139 | { |
| 1140 | const GLintcxx . . $ GLint# ib = (GLintcxx . . $ GLint#) ((*srcb) ? 1 : 0); |
| 1141 | const GLintcxx . . $ GLint# iv[4] = { ib, ib, ib, ib }; |
| 1142 | ctxcxx . . $ ctx.->glProgramLocalParameterI4ivNVcxx . . $ MOJOSHADER_glContext#glProgramLocalParameterI4ivNV.(arb_shader_type, loc, iv); |
| 1143 | } // for |
| 1144 | } // if |
| 1145 | else |
| 1146 | { |
| 1147 | for (i = 0; i < size; i++, srcb++, loc++) |
| 1148 | { |
| 1149 | const GLfloatcxx . . $ GLfloat# fb = (GLfloatcxx . . $ GLfloat#) ((*srcb) ? 1.0f : 0.0f); |
| 1150 | const GLfloatcxx . . $ GLfloat# fv[4] = { fb, fb, fb, fb }; |
| 1151 | ctxcxx . . $ ctx.->glProgramLocalParameter4fvARBcxx . . $ MOJOSHADER_glContext#glProgramLocalParameter4fvARB.(arb_shader_type, loc, fv); |
| 1152 | } // for |
| 1153 | } // else |
| 1154 | } // else if |
| 1155 | } // for |
| 1156 | |
| 1157 | if (program->texbem_countcxx . . $ MOJOSHADER_glProgram#texbem_count.) |
| 1158 | { |
| 1159 | const GLenumcxx . . $ GLenum# target = GL_FRAGMENT_PROGRAM_ARBcxx . . $ `GL/glext.h:1465:9`!; |
| 1160 | GLfloatcxx . . $ GLfloat# *srcf = program->ps_uniforms_float4cxx . . $ MOJOSHADER_glProgram#ps_uniforms_float4.; |
| 1161 | srcf += (program->ps_uniforms_float4_countcxx . . $ MOJOSHADER_glProgram#ps_uniforms_float4_count. * 4) - |
| 1162 | (program->texbem_countcxx . . $ MOJOSHADER_glProgram#texbem_count. * 8); |
| 1163 | loc = texbem_loc; |
| 1164 | for (i = 0; i < program->texbem_countcxx . . $ MOJOSHADER_glProgram#texbem_count.; i++, srcf += 8) |
| 1165 | { |
| 1166 | ctxcxx . . $ ctx.->glProgramLocalParameter4fvARBcxx . . $ MOJOSHADER_glContext#glProgramLocalParameter4fvARB.(target, loc++, srcf); |
| 1167 | ctxcxx . . $ ctx.->glProgramLocalParameter4fvARBcxx . . $ MOJOSHADER_glContext#glProgramLocalParameter4fvARB.(target, loc++, srcf + 4); |
| 1168 | } // for |
| 1169 | } // if |
| 1170 | } // impl_ARB1_PushUniforms |
| 1171 | |
| 1172 | static void impl_ARB1_PushSamplercxx . . $ impl_ARB1_PushSampler(c8dafc4a64bf4a1c).(GLintcxx . . $ GLint# loc, GLuintcxx . . $ GLuint# sampler) |
| 1173 | { |
| 1174 | // no-op in this profile...arb1 uses the texture units as-is. |
| 1175 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(loc == (GLint) sampler); |
| 1176 | } // impl_ARB1_PushSampler |
| 1177 | |
| 1178 | #endif // SUPPORT_PROFILE_ARB1 |
| 1179 | |
| 1180 | #if SUPPORT_PROFILE_GLSLcxx . . $ `mojoshader_internal.h:182:9`! || SUPPORT_PROFILE_ARB1cxx . . $ `mojoshader_internal.h:198:9`! |
| 1181 | |
| 1182 | static void impl_REAL_ToggleProgramPointSizecxx . . $ impl_REAL_ToggleProgramPointSize(d4f767463ce0a6b3).(int enable) |
| 1183 | { |
| 1184 | toggle_gl_statecxx . . $ toggle_gl_state(3d89109e85ced1be).(GL_PROGRAM_POINT_SIZEcxx . . $ `GL/glext.h:816:9`!, enable); |
| 1185 | } // impl_REAL_ToggleProgramPointSize |
| 1186 | |
| 1187 | static void impl_NOOP_ToggleProgramPointSizecxx . . $ impl_NOOP_ToggleProgramPointSize(d4f767463ce0a6b3).(int enable) |
| 1188 | { |
| 1189 | // No-op, this profile's GL context forces this to always be on |
| 1190 | } // impl_NOOP_ToggleProgramPointSize |
| 1191 | |
| 1192 | #endif // SUPPORT_PROFILE_GLSL || SUPPORT_PROFILE_ARB1 |
| 1193 | |
| 1194 | |
| 1195 | const char *MOJOSHADER_glGetErrorcxx . . $ MOJOSHADER_glGetError(33a1f659e94feb42).(void) |
| 1196 | { |
| 1197 | return error_buffercxx . . $ error_buffer.; |
| 1198 | } // MOJOSHADER_glGetError |
| 1199 | |
| 1200 | |
| 1201 | static void *loadsymcxx . . $ loadsym(8a28d4ca428a5290).(MOJOSHADER_glGetProcAddresscxx . . $ MOJOSHADER_glGetProcAddress# lookup, void *d, |
| 1202 | const char *fn, int *ext) |
| 1203 | { |
| 1204 | void *retval = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1205 | if (lookup != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1206 | retval = lookup(fn, d); |
| 1207 | |
| 1208 | if (retval == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1209 | *ext = 0; |
| 1210 | |
| 1211 | return retval; |
| 1212 | } // loadsym |
| 1213 | |
| 1214 | static void lookup_entry_pointscxx . . $ lookup_entry_points(5928c5b85337a06e).(MOJOSHADER_glGetProcAddresscxx . . $ MOJOSHADER_glGetProcAddress# lookup, void *d) |
| 1215 | { |
| 1216 | #define DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(ext, typ, fn) { \ |
| 1217 | ctx->fn = (typ) loadsym(lookup, d, #fn, &ctx->have_##ext); \ |
| 1218 | } |
| 1219 | |
| 1220 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(core_opengl, PFNGLGETSTRINGPROC, glGetString); |
| 1221 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(core_opengl, PFNGLGETERRORPROC, glGetError); |
| 1222 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(core_opengl, PFNGLGETINTEGERVPROC, glGetIntegerv); |
| 1223 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(core_opengl, PFNGLENABLEPROC, glEnable); |
| 1224 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(core_opengl, PFNGLDISABLEPROC, glDisable); |
| 1225 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_3, PFNGLGETSTRINGIPROC, glGetStringi); |
| 1226 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLDELETESHADERPROC, glDeleteShader); |
| 1227 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLDELETEPROGRAMPROC, glDeleteProgram); |
| 1228 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLATTACHSHADERPROC, glAttachShader); |
| 1229 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLCOMPILESHADERPROC, glCompileShader); |
| 1230 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLCREATESHADERPROC, glCreateShader); |
| 1231 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLCREATEPROGRAMPROC, glCreateProgram); |
| 1232 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLDISABLEVERTEXATTRIBARRAYPROC, glDisableVertexAttribArray); |
| 1233 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLENABLEVERTEXATTRIBARRAYPROC, glEnableVertexAttribArray); |
| 1234 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLGETATTRIBLOCATIONPROC, glGetAttribLocation); |
| 1235 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLGETPROGRAMINFOLOGPROC, glGetProgramInfoLog); |
| 1236 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLGETSHADERINFOLOGPROC, glGetShaderInfoLog); |
| 1237 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLGETSHADERIVPROC, glGetShaderiv); |
| 1238 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLGETPROGRAMIVPROC, glGetProgramiv); |
| 1239 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLGETUNIFORMLOCATIONPROC, glGetUniformLocation); |
| 1240 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLLINKPROGRAMPROC, glLinkProgram); |
| 1241 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLSHADERSOURCEPROC, glShaderSource); |
| 1242 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLUNIFORM1IPROC, glUniform1i); |
| 1243 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLUNIFORM1IVPROC, glUniform1iv); |
| 1244 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLUNIFORM2FPROC, glUniform2f); |
| 1245 | #ifdef MOJOSHADER_FLIP_RENDERTARGET |
| 1246 | DO_LOOKUP(opengl_2, PFNGLUNIFORM1FPROC, glUniform1f); |
| 1247 | #endif |
| 1248 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLUNIFORM4FVPROC, glUniform4fv); |
| 1249 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLUNIFORM4IVPROC, glUniform4iv); |
| 1250 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLUSEPROGRAMPROC, glUseProgram); |
| 1251 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(opengl_2, PFNGLVERTEXATTRIBPOINTERPROC, glVertexAttribPointer); |
| 1252 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_shader_objects, PFNGLDELETEOBJECTARBPROC, glDeleteObjectARB); |
| 1253 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_shader_objects, PFNGLATTACHOBJECTARBPROC, glAttachObjectARB); |
| 1254 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_shader_objects, PFNGLCOMPILESHADERARBPROC, glCompileShaderARB); |
| 1255 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_shader_objects, PFNGLCREATEPROGRAMOBJECTARBPROC, glCreateProgramObjectARB); |
| 1256 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_shader_objects, PFNGLCREATESHADEROBJECTARBPROC, glCreateShaderObjectARB); |
| 1257 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_shader_objects, PFNGLGETINFOLOGARBPROC, glGetInfoLogARB); |
| 1258 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_shader_objects, PFNGLGETOBJECTPARAMETERIVARBPROC, glGetObjectParameterivARB); |
| 1259 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_shader_objects, PFNGLGETUNIFORMLOCATIONARBPROC, glGetUniformLocationARB); |
| 1260 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_shader_objects, PFNGLLINKPROGRAMARBPROC, glLinkProgramARB); |
| 1261 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_shader_objects, PFNGLSHADERSOURCEARBPROC, glShaderSourceARB); |
| 1262 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_shader_objects, PFNGLUNIFORM1IARBPROC, glUniform1iARB); |
| 1263 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_shader_objects, PFNGLUNIFORM1IVARBPROC, glUniform1ivARB); |
| 1264 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_shader_objects, PFNGLUNIFORM4FVARBPROC, glUniform4fvARB); |
| 1265 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_shader_objects, PFNGLUNIFORM4IVARBPROC, glUniform4ivARB); |
| 1266 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_shader_objects, PFNGLUSEPROGRAMOBJECTARBPROC, glUseProgramObjectARB); |
| 1267 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_vertex_shader, PFNGLDISABLEVERTEXATTRIBARRAYARBPROC, glDisableVertexAttribArrayARB); |
| 1268 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_vertex_shader, PFNGLENABLEVERTEXATTRIBARRAYARBPROC, glEnableVertexAttribArrayARB); |
| 1269 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_vertex_shader, PFNGLGETATTRIBLOCATIONARBPROC, glGetAttribLocationARB); |
| 1270 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_vertex_shader, PFNGLVERTEXATTRIBPOINTERARBPROC, glVertexAttribPointerARB); |
| 1271 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_vertex_program, PFNGLVERTEXATTRIBPOINTERARBPROC, glVertexAttribPointerARB); |
| 1272 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_vertex_program, PFNGLGETPROGRAMIVARBPROC, glGetProgramivARB); |
| 1273 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_vertex_program, PFNGLPROGRAMLOCALPARAMETER4FVARBPROC, glProgramLocalParameter4fvARB); |
| 1274 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_vertex_program, PFNGLDELETEPROGRAMSARBPROC, glDeleteProgramsARB); |
| 1275 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_vertex_program, PFNGLGENPROGRAMSARBPROC, glGenProgramsARB); |
| 1276 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_vertex_program, PFNGLBINDPROGRAMARBPROC, glBindProgramARB); |
| 1277 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_vertex_program, PFNGLPROGRAMSTRINGARBPROC, glProgramStringARB); |
| 1278 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_NV_gpu_program4, PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC, glProgramLocalParameterI4ivNV); |
| 1279 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_instanced_arrays, PFNGLVERTEXATTRIBDIVISORARBPROC, glVertexAttribDivisorARB); |
| 1280 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_ES2_compatibility, PFNGLSHADERBINARYPROC, glShaderBinary); |
| 1281 | DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`!(GL_ARB_gl_spirv, PFNGLSPECIALIZESHADERARBPROC, glSpecializeShaderARB); |
| 1282 | |
| 1283 | #undef DO_LOOKUPcxx . . $ `mojoshader_opengl.c:1216:13`! |
| 1284 | } // lookup_entry_points |
| 1285 | |
| 1286 | static inline int opengl_version_atleastcxx . . $ opengl_version_atleast(9b79fb6aee4c0440).(const int major, const int minor) |
| 1287 | { |
| 1288 | return ( ((ctxcxx . . $ ctx.->opengl_majorcxx . . $ MOJOSHADER_glContext#opengl_major. << 16) | (ctxcxx . . $ ctx.->opengl_minorcxx . . $ MOJOSHADER_glContext#opengl_minor. & 0xFFFF)) >= |
| 1289 | ((major << 16) | (minor & 0xFFFF)) ); |
| 1290 | } // opengl_version_atleast |
| 1291 | |
| 1292 | static int verify_extensioncxx . . $ verify_extension(c09d0ec2f30a98ae).(const char *ext, int have, StringCachecxx . . $ StringCache# *exts, |
| 1293 | int major, int minor) |
| 1294 | { |
| 1295 | if (have == 0) |
| 1296 | return 0; // don't bother checking, we're missing an entry point. |
| 1297 | |
| 1298 | else if (!ctxcxx . . $ ctx.->have_core_openglcxx . . $ MOJOSHADER_glContext#have_core_opengl.) |
| 1299 | return 0; // don't bother checking, we're missing basic functionality. |
| 1300 | |
| 1301 | // See if it's in the spec for this GL implementation's version. |
| 1302 | if ((major > 0) && (opengl_version_atleastcxx . . $ opengl_version_atleast(9b79fb6aee4c0440).(major, minor))) |
| 1303 | return 1; |
| 1304 | |
| 1305 | // Not available in the GL version, check the extension list. |
| 1306 | return stringcache_iscachedcxx . . $ stringcache_iscached(4e54f2a32da2e893).(exts, ext); |
| 1307 | } // verify_extension |
| 1308 | |
| 1309 | |
| 1310 | static void parse_opengl_version_strcxx . . $ parse_opengl_version_str(e80e23532482d70f).(const char *verstr, int *maj, int *min) |
| 1311 | { |
| 1312 | if (verstr == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1313 | *maj = *min = 0; |
| 1314 | else |
| 1315 | sscanfcxx . . $ sscanf(5e8a2c12db2ea735).(verstr, "%d.%d", maj, min); |
| 1316 | } // parse_opengl_version_str |
| 1317 | |
| 1318 | |
| 1319 | #if SUPPORT_PROFILE_GLSLcxx . . $ `mojoshader_internal.h:182:9`! |
| 1320 | static inline int glsl_version_atleastcxx . . $ glsl_version_atleast(9b79fb6aee4c0440).(const int major, const int minor) |
| 1321 | { |
| 1322 | return ( ((ctxcxx . . $ ctx.->glsl_majorcxx . . $ MOJOSHADER_glContext#glsl_major. << 16) | (ctxcxx . . $ ctx.->glsl_minorcxx . . $ MOJOSHADER_glContext#glsl_minor. & 0xFFFF)) >= |
| 1323 | ((major << 16) | (minor & 0xFFFF)) ); |
| 1324 | } // glsl_version_atleast |
| 1325 | #endif |
| 1326 | |
| 1327 | static void detect_glsl_versioncxx . . $ detect_glsl_version(49f6e7a06ebc5aa8).(void) |
| 1328 | { |
| 1329 | ctxcxx . . $ ctx.->glsl_majorcxx . . $ MOJOSHADER_glContext#glsl_major. = ctxcxx . . $ ctx.->glsl_minorcxx . . $ MOJOSHADER_glContext#glsl_minor. = 0; |
| 1330 | |
| 1331 | #if SUPPORT_PROFILE_GLSLcxx . . $ `mojoshader_internal.h:182:9`! |
| 1332 | if (!ctxcxx . . $ ctx.->have_core_openglcxx . . $ MOJOSHADER_glContext#have_core_opengl.) |
| 1333 | return; // everything's busted, give up. |
| 1334 | |
| 1335 | #if PLATFORM_MACOSX |
| 1336 | // If running on Mac OS X <= 10.4, don't ever use GLSL, even if |
| 1337 | // the system claims it is available. |
| 1338 | if (!macosx_version_atleast(10, 5, 0)) |
| 1339 | return; |
| 1340 | #endif |
| 1341 | |
| 1342 | if ( ctxcxx . . $ ctx.->have_opengl_2cxx . . $ MOJOSHADER_glContext#have_opengl_2. || |
| 1343 | ( ctxcxx . . $ ctx.->have_GL_ARB_shader_objectscxx . . $ MOJOSHADER_glContext#have_GL_ARB_shader_objects. && |
| 1344 | ctxcxx . . $ ctx.->have_GL_ARB_vertex_shadercxx . . $ MOJOSHADER_glContext#have_GL_ARB_vertex_shader. && |
| 1345 | ctxcxx . . $ ctx.->have_GL_ARB_fragment_shadercxx . . $ MOJOSHADER_glContext#have_GL_ARB_fragment_shader. && |
| 1346 | ctxcxx . . $ ctx.->have_GL_ARB_shading_language_100cxx . . $ MOJOSHADER_glContext#have_GL_ARB_shading_language_100. ) ) |
| 1347 | { |
| 1348 | // the GL2.0 and ARB enum is the same value. |
| 1349 | const GLenumcxx . . $ GLenum# enumval = GL_SHADING_LANGUAGE_VERSIONcxx . . $ `GL/glext.h:458:9`!; |
| 1350 | ctxcxx . . $ ctx.->glGetErrorcxx . . $ MOJOSHADER_glContext#glGetError.(); // flush any existing error state. |
| 1351 | const char *str = (const char *) ctxcxx . . $ ctx.->glGetStringcxx . . $ MOJOSHADER_glContext#glGetString.(enumval); |
| 1352 | if (ctxcxx . . $ ctx.->glGetErrorcxx . . $ MOJOSHADER_glContext#glGetError.() == GL_INVALID_ENUMcxx . . $ `<external>/11565930711847777359/gl.h:660:9`!) |
| 1353 | str = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1354 | if (strstrcxx . . $ strstr(a713fe7b9a57cf96).(str, "OpenGL ES GLSL ")) |
| 1355 | str += 15; |
| 1356 | if (strstrcxx . . $ strstr(a713fe7b9a57cf96).(str, "ES ")) |
| 1357 | str += 3; |
| 1358 | parse_opengl_version_strcxx . . $ parse_opengl_version_str(e80e23532482d70f).(str, &ctxcxx . . $ ctx.->glsl_majorcxx . . $ MOJOSHADER_glContext#glsl_major., &ctxcxx . . $ ctx.->glsl_minorcxx . . $ MOJOSHADER_glContext#glsl_minor.); |
| 1359 | } // if |
| 1360 | #endif |
| 1361 | } // detect_glsl_version |
| 1362 | |
| 1363 | |
| 1364 | static int iswhitespacecxx . . $ iswhitespace(784f3405e7e545be).(const char ch) |
| 1365 | { |
| 1366 | switch (ch) |
| 1367 | { |
| 1368 | case ' ': case '\t': case '\r': case '\n': return 1; |
| 1369 | default: return 0; |
| 1370 | } // switch |
| 1371 | } // iswhitespace |
| 1372 | |
| 1373 | |
| 1374 | static void load_extensionscxx . . $ load_extensions(5928c5b85337a06e).(MOJOSHADER_glGetProcAddresscxx . . $ MOJOSHADER_glGetProcAddress# lookup, void *d) |
| 1375 | { |
| 1376 | StringCachecxx . . $ StringCache# *exts = stringcache_createcxx . . $ stringcache_create(b4617f7a2c1625cb).(ctxcxx . . $ ctx.->malloc_fncxx . . $ MOJOSHADER_glContext#malloc_fn., ctxcxx . . $ ctx.->free_fncxx . . $ MOJOSHADER_glContext#free_fn., ctxcxx . . $ ctx.->malloc_datacxx . . $ MOJOSHADER_glContext#malloc_data.); |
| 1377 | if (!exts) |
| 1378 | { |
| 1379 | out_of_memorycxx . . $ out_of_memory(49f6e7a06ebc5aa8).(); |
| 1380 | return; |
| 1381 | } // if |
| 1382 | |
| 1383 | ctxcxx . . $ ctx.->have_core_openglcxx . . $ MOJOSHADER_glContext#have_core_opengl. = 1; |
| 1384 | ctxcxx . . $ ctx.->have_opengl_2cxx . . $ MOJOSHADER_glContext#have_opengl_2. = 1; |
| 1385 | ctxcxx . . $ ctx.->have_opengl_3cxx . . $ MOJOSHADER_glContext#have_opengl_3. = 1; |
| 1386 | ctxcxx . . $ ctx.->have_GL_ARB_vertex_programcxx . . $ MOJOSHADER_glContext#have_GL_ARB_vertex_program. = 1; |
| 1387 | ctxcxx . . $ ctx.->have_GL_ARB_fragment_programcxx . . $ MOJOSHADER_glContext#have_GL_ARB_fragment_program. = 1; |
| 1388 | ctxcxx . . $ ctx.->have_GL_NV_vertex_program2_optioncxx . . $ MOJOSHADER_glContext#have_GL_NV_vertex_program2_option. = 1; |
| 1389 | ctxcxx . . $ ctx.->have_GL_NV_fragment_program2cxx . . $ MOJOSHADER_glContext#have_GL_NV_fragment_program2. = 1; |
| 1390 | ctxcxx . . $ ctx.->have_GL_NV_vertex_program3cxx . . $ MOJOSHADER_glContext#have_GL_NV_vertex_program3. = 1; |
| 1391 | ctxcxx . . $ ctx.->have_GL_NV_gpu_program4cxx . . $ MOJOSHADER_glContext#have_GL_NV_gpu_program4. = 1; |
| 1392 | ctxcxx . . $ ctx.->have_GL_ARB_shader_objectscxx . . $ MOJOSHADER_glContext#have_GL_ARB_shader_objects. = 1; |
| 1393 | ctxcxx . . $ ctx.->have_GL_ARB_vertex_shadercxx . . $ MOJOSHADER_glContext#have_GL_ARB_vertex_shader. = 1; |
| 1394 | ctxcxx . . $ ctx.->have_GL_ARB_fragment_shadercxx . . $ MOJOSHADER_glContext#have_GL_ARB_fragment_shader. = 1; |
| 1395 | ctxcxx . . $ ctx.->have_GL_ARB_shading_language_100cxx . . $ MOJOSHADER_glContext#have_GL_ARB_shading_language_100. = 1; |
| 1396 | ctxcxx . . $ ctx.->have_GL_NV_half_floatcxx . . $ MOJOSHADER_glContext#have_GL_NV_half_float. = 1; |
| 1397 | ctxcxx . . $ ctx.->have_GL_ARB_half_float_vertexcxx . . $ MOJOSHADER_glContext#have_GL_ARB_half_float_vertex. = 1; |
| 1398 | ctxcxx . . $ ctx.->have_GL_OES_vertex_half_floatcxx . . $ MOJOSHADER_glContext#have_GL_OES_vertex_half_float. = 1; |
| 1399 | ctxcxx . . $ ctx.->have_GL_ARB_instanced_arrayscxx . . $ MOJOSHADER_glContext#have_GL_ARB_instanced_arrays. = 1; |
| 1400 | ctxcxx . . $ ctx.->have_GL_ARB_ES2_compatibilitycxx . . $ MOJOSHADER_glContext#have_GL_ARB_ES2_compatibility. = 1; |
| 1401 | ctxcxx . . $ ctx.->have_GL_ARB_gl_spirvcxx . . $ MOJOSHADER_glContext#have_GL_ARB_gl_spirv. = 1; |
| 1402 | |
| 1403 | lookup_entry_pointscxx . . $ lookup_entry_points(5928c5b85337a06e).(lookup, d); |
| 1404 | |
| 1405 | if (!ctxcxx . . $ ctx.->have_core_openglcxx . . $ MOJOSHADER_glContext#have_core_opengl.) |
| 1406 | set_errorcxx . . $ set_error(85c52e162fed56f9).("missing basic OpenGL entry points"); |
| 1407 | else |
| 1408 | { |
| 1409 | const char *str = (const char *) ctxcxx . . $ ctx.->glGetStringcxx . . $ MOJOSHADER_glContext#glGetString.(GL_VERSIONcxx . . $ `<external>/11565930711847777359/gl.h:655:9`!); |
| 1410 | if (strstrcxx . . $ strstr(a713fe7b9a57cf96).(str, "OpenGL ES ")) |
| 1411 | { |
| 1412 | ctxcxx . . $ ctx.->have_opengl_escxx . . $ MOJOSHADER_glContext#have_opengl_es. = 1; |
| 1413 | str += 10; |
| 1414 | } |
| 1415 | parse_opengl_version_strcxx . . $ parse_opengl_version_str(e80e23532482d70f).(str, &ctxcxx . . $ ctx.->opengl_majorcxx . . $ MOJOSHADER_glContext#opengl_major., &ctxcxx . . $ ctx.->opengl_minorcxx . . $ MOJOSHADER_glContext#opengl_minor.); |
| 1416 | |
| 1417 | if (opengl_version_atleastcxx . . $ opengl_version_atleast(9b79fb6aee4c0440).(3, 0) && ctxcxx . . $ ctx.->have_opengl_escxx . . $ MOJOSHADER_glContext#have_opengl_es.) |
| 1418 | { |
| 1419 | ctxcxx . . $ ctx.->have_opengl_es3cxx . . $ MOJOSHADER_glContext#have_opengl_es3. = 1; |
| 1420 | } |
| 1421 | |
| 1422 | if ((ctxcxx . . $ ctx.->have_opengl_3cxx . . $ MOJOSHADER_glContext#have_opengl_3.) && (opengl_version_atleastcxx . . $ opengl_version_atleast(9b79fb6aee4c0440).(3, 0))) |
| 1423 | { |
| 1424 | GLintcxx . . $ GLint# i; |
| 1425 | GLintcxx . . $ GLint# num_exts = 0; |
| 1426 | ctxcxx . . $ ctx.->glGetIntegervcxx . . $ MOJOSHADER_glContext#glGetIntegerv.(GL_NUM_EXTENSIONScxx . . $ `GL/glext.h:517:9`!, &num_exts); |
| 1427 | for (i = 0; i < num_exts; i++) |
| 1428 | { |
| 1429 | if (!stringcachecxx . . $ stringcache(9a0b32e58267707a).(exts, (const char *) ctxcxx . . $ ctx.->glGetStringicxx . . $ MOJOSHADER_glContext#glGetStringi.(GL_EXTENSIONScxx . . $ `<external>/11565930711847777359/gl.h:656:9`!, i))) |
| 1430 | out_of_memorycxx . . $ out_of_memory(49f6e7a06ebc5aa8).(); |
| 1431 | } // for |
| 1432 | } // if |
| 1433 | else |
| 1434 | { |
| 1435 | const char *str = (const char *) ctxcxx . . $ ctx.->glGetStringcxx . . $ MOJOSHADER_glContext#glGetString.(GL_EXTENSIONScxx . . $ `<external>/11565930711847777359/gl.h:656:9`!); |
| 1436 | const char *ext; |
| 1437 | ctxcxx . . $ ctx.->have_opengl_3cxx . . $ MOJOSHADER_glContext#have_opengl_3. = 0; |
| 1438 | |
| 1439 | while (*str && iswhitespacecxx . . $ iswhitespace(784f3405e7e545be).(*str)) |
| 1440 | str++; |
| 1441 | ext = str; |
| 1442 | |
| 1443 | while (1) |
| 1444 | { |
| 1445 | const char ch = *str; |
| 1446 | if (ch && (!iswhitespacecxx . . $ iswhitespace(784f3405e7e545be).(ch))) |
| 1447 | { |
| 1448 | str++; |
| 1449 | continue; |
| 1450 | } // else if |
| 1451 | |
| 1452 | if (str != ext) |
| 1453 | { |
| 1454 | if (!stringcache_lencxx . . $ stringcache_len(a48eb3d5dcd20ad4).(exts, ext, (unsigned int) (str - ext))) |
| 1455 | { |
| 1456 | out_of_memorycxx . . $ out_of_memory(49f6e7a06ebc5aa8).(); |
| 1457 | break; |
| 1458 | } // if |
| 1459 | } // if |
| 1460 | |
| 1461 | if (ch == '\0') |
| 1462 | break; |
| 1463 | |
| 1464 | str++; |
| 1465 | while (*str && iswhitespacecxx . . $ iswhitespace(784f3405e7e545be).(*str)) |
| 1466 | str++; |
| 1467 | ext = str; |
| 1468 | } // while |
| 1469 | } // else |
| 1470 | } // else |
| 1471 | |
| 1472 | if ((ctxcxx . . $ ctx.->have_opengl_2cxx . . $ MOJOSHADER_glContext#have_opengl_2.) && (!opengl_version_atleastcxx . . $ opengl_version_atleast(9b79fb6aee4c0440).(2, 0))) |
| 1473 | { |
| 1474 | ctxcxx . . $ ctx.->have_opengl_2cxx . . $ MOJOSHADER_glContext#have_opengl_2. = 0; // Not GL2! must have the ARB extensions! |
| 1475 | |
| 1476 | // Force compatible ARB function pointers in...this keeps the code |
| 1477 | // cleaner when they are identical, so we don't have to if/else |
| 1478 | // every function call, but we definitely have the right entry |
| 1479 | // point. Be careful what you add here. |
| 1480 | // These may be NULL, btw. |
| 1481 | ctxcxx . . $ ctx.->glUniform1icxx . . $ MOJOSHADER_glContext#glUniform1i. = ctxcxx . . $ ctx.->glUniform1iARBcxx . . $ MOJOSHADER_glContext#glUniform1iARB.; |
| 1482 | ctxcxx . . $ ctx.->glUniform4fvcxx . . $ MOJOSHADER_glContext#glUniform4fv. = ctxcxx . . $ ctx.->glUniform4fvARBcxx . . $ MOJOSHADER_glContext#glUniform4fvARB.; |
| 1483 | ctxcxx . . $ ctx.->glUniform4ivcxx . . $ MOJOSHADER_glContext#glUniform4iv. = ctxcxx . . $ ctx.->glUniform4ivARBcxx . . $ MOJOSHADER_glContext#glUniform4ivARB.; |
| 1484 | ctxcxx . . $ ctx.->glDisableVertexAttribArraycxx . . $ MOJOSHADER_glContext#glDisableVertexAttribArray. = ctxcxx . . $ ctx.->glDisableVertexAttribArrayARBcxx . . $ MOJOSHADER_glContext#glDisableVertexAttribArrayARB.; |
| 1485 | ctxcxx . . $ ctx.->glEnableVertexAttribArraycxx . . $ MOJOSHADER_glContext#glEnableVertexAttribArray. = ctxcxx . . $ ctx.->glEnableVertexAttribArrayARBcxx . . $ MOJOSHADER_glContext#glEnableVertexAttribArrayARB.; |
| 1486 | ctxcxx . . $ ctx.->glVertexAttribPointercxx . . $ MOJOSHADER_glContext#glVertexAttribPointer. = ctxcxx . . $ ctx.->glVertexAttribPointerARBcxx . . $ MOJOSHADER_glContext#glVertexAttribPointerARB.; |
| 1487 | } // if |
| 1488 | |
| 1489 | #define VERIFY_EXTcxx . . $ `mojoshader_opengl.c:1489:13`!(ext, major, minor) \ |
| 1490 | ctx->have_##ext = verify_extension(#ext, ctx->have_##ext, exts, major, minor) |
| 1491 | |
| 1492 | VERIFY_EXTcxx . . $ `mojoshader_opengl.c:1489:13`!(GL_ARB_vertex_program, -1, -1); |
| 1493 | VERIFY_EXTcxx . . $ `mojoshader_opengl.c:1489:13`!(GL_ARB_fragment_program, -1, -1); |
| 1494 | VERIFY_EXTcxx . . $ `mojoshader_opengl.c:1489:13`!(GL_ARB_shader_objects, -1, -1); |
| 1495 | VERIFY_EXTcxx . . $ `mojoshader_opengl.c:1489:13`!(GL_ARB_vertex_shader, -1, -1); |
| 1496 | VERIFY_EXTcxx . . $ `mojoshader_opengl.c:1489:13`!(GL_ARB_fragment_shader, -1, -1); |
| 1497 | VERIFY_EXTcxx . . $ `mojoshader_opengl.c:1489:13`!(GL_ARB_shading_language_100, -1, -1); |
| 1498 | VERIFY_EXTcxx . . $ `mojoshader_opengl.c:1489:13`!(GL_NV_vertex_program2_option, -1, -1); |
| 1499 | VERIFY_EXTcxx . . $ `mojoshader_opengl.c:1489:13`!(GL_NV_fragment_program2, -1, -1); |
| 1500 | VERIFY_EXTcxx . . $ `mojoshader_opengl.c:1489:13`!(GL_NV_vertex_program3, -1, -1); |
| 1501 | VERIFY_EXTcxx . . $ `mojoshader_opengl.c:1489:13`!(GL_NV_half_float, -1, -1); |
| 1502 | VERIFY_EXTcxx . . $ `mojoshader_opengl.c:1489:13`!(GL_ARB_half_float_vertex, 3, 0); |
| 1503 | VERIFY_EXTcxx . . $ `mojoshader_opengl.c:1489:13`!(GL_OES_vertex_half_float, -1, -1); |
| 1504 | VERIFY_EXTcxx . . $ `mojoshader_opengl.c:1489:13`!(GL_ARB_instanced_arrays, 3, 3); |
| 1505 | VERIFY_EXTcxx . . $ `mojoshader_opengl.c:1489:13`!(GL_ARB_ES2_compatibility, 4, 1); |
| 1506 | VERIFY_EXTcxx . . $ `mojoshader_opengl.c:1489:13`!(GL_ARB_gl_spirv, -1, -1); |
| 1507 | |
| 1508 | #undef VERIFY_EXTcxx . . $ `mojoshader_opengl.c:1489:13`! |
| 1509 | |
| 1510 | stringcache_destroycxx . . $ stringcache_destroy(a32b2fea73ec6fd5).(exts); |
| 1511 | |
| 1512 | detect_glsl_versioncxx . . $ detect_glsl_version(49f6e7a06ebc5aa8).(); |
| 1513 | } // load_extensions |
| 1514 | |
| 1515 | |
| 1516 | static int valid_profilecxx . . $ valid_profile(5c4306d8553b3696).(const char *profile) |
| 1517 | { |
| 1518 | if (!ctxcxx . . $ ctx.->have_core_openglcxx . . $ MOJOSHADER_glContext#have_core_opengl.) |
| 1519 | return 0; |
| 1520 | |
| 1521 | #define MUST_HAVEcxx . . $ `mojoshader_opengl.c:1521:13`!(p, x) \ |
| 1522 | if (!ctx->have_##x) { set_error(#p " profile needs " #x); return 0; } |
| 1523 | |
| 1524 | // we might actually _have_ maj.min, but forcibly disabled GLSL elsewhere. |
| 1525 | #define MUST_HAVE_GLSLcxx . . $ `mojoshader_opengl.c:1525:13`!(p, maj, min) \ |
| 1526 | if (!glsl_version_atleast(maj, min)) { \ |
| 1527 | set_error(#p " profile needs missing GLSL support"); return 0; \ |
| 1528 | } |
| 1529 | |
| 1530 | if (profile == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1531 | { |
| 1532 | set_errorcxx . . $ set_error(85c52e162fed56f9).("NULL profile"); |
| 1533 | return 0; |
| 1534 | } // if |
| 1535 | |
| 1536 | #if SUPPORT_PROFILE_ARB1cxx . . $ `mojoshader_internal.h:198:9`! |
| 1537 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profile, MOJOSHADER_PROFILE_ARB1cxx . . $ `mojoshader.h:720:9`!) == 0) |
| 1538 | { |
| 1539 | MUST_HAVEcxx . . $ `mojoshader_opengl.c:1521:13`!(MOJOSHADER_PROFILE_ARB1, GL_ARB_vertex_program); |
| 1540 | MUST_HAVEcxx . . $ `mojoshader_opengl.c:1521:13`!(MOJOSHADER_PROFILE_ARB1, GL_ARB_fragment_program); |
| 1541 | } // else if |
| 1542 | #endif |
| 1543 | |
| 1544 | #if SUPPORT_PROFILE_ARB1_NVcxx . . $ `mojoshader_internal.h:202:9`! |
| 1545 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profile, MOJOSHADER_PROFILE_NV2cxx . . $ `mojoshader.h:726:9`!) == 0) |
| 1546 | { |
| 1547 | MUST_HAVEcxx . . $ `mojoshader_opengl.c:1521:13`!(MOJOSHADER_PROFILE_NV2, GL_ARB_vertex_program); |
| 1548 | MUST_HAVEcxx . . $ `mojoshader_opengl.c:1521:13`!(MOJOSHADER_PROFILE_NV2, GL_ARB_fragment_program); |
| 1549 | MUST_HAVEcxx . . $ `mojoshader_opengl.c:1521:13`!(MOJOSHADER_PROFILE_NV2, GL_NV_vertex_program2_option); |
| 1550 | MUST_HAVEcxx . . $ `mojoshader_opengl.c:1521:13`!(MOJOSHADER_PROFILE_NV2, GL_NV_fragment_program2); |
| 1551 | } // else if |
| 1552 | |
| 1553 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profile, MOJOSHADER_PROFILE_NV3cxx . . $ `mojoshader.h:732:9`!) == 0) |
| 1554 | { |
| 1555 | MUST_HAVEcxx . . $ `mojoshader_opengl.c:1521:13`!(MOJOSHADER_PROFILE_NV3, GL_ARB_vertex_program); |
| 1556 | MUST_HAVEcxx . . $ `mojoshader_opengl.c:1521:13`!(MOJOSHADER_PROFILE_NV3, GL_ARB_fragment_program); |
| 1557 | MUST_HAVEcxx . . $ `mojoshader_opengl.c:1521:13`!(MOJOSHADER_PROFILE_NV3, GL_NV_vertex_program3); |
| 1558 | MUST_HAVEcxx . . $ `mojoshader_opengl.c:1521:13`!(MOJOSHADER_PROFILE_NV3, GL_NV_fragment_program2); |
| 1559 | } // else if |
| 1560 | |
| 1561 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profile, MOJOSHADER_PROFILE_NV4cxx . . $ `mojoshader.h:738:9`!) == 0) |
| 1562 | { |
| 1563 | MUST_HAVEcxx . . $ `mojoshader_opengl.c:1521:13`!(MOJOSHADER_PROFILE_NV4, GL_NV_gpu_program4); |
| 1564 | } // else if |
| 1565 | #endif |
| 1566 | |
| 1567 | #if SUPPORT_PROFILE_GLSPIRVcxx . . $ `mojoshader_internal.h:214:9`! |
| 1568 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profile, MOJOSHADER_PROFILE_GLSPIRVcxx . . $ `mojoshader.h:753:9`!) == 0) |
| 1569 | { |
| 1570 | MUST_HAVEcxx . . $ `mojoshader_opengl.c:1521:13`!(MOJOSHADER_PROFILE_GLSPIRV, GL_ARB_ES2_compatibility); |
| 1571 | MUST_HAVEcxx . . $ `mojoshader_opengl.c:1521:13`!(MOJOSHADER_PROFILE_GLSPIRV, GL_ARB_gl_spirv); |
| 1572 | } // else if |
| 1573 | #endif |
| 1574 | |
| 1575 | #if SUPPORT_PROFILE_GLSLEScxx . . $ `mojoshader_internal.h:190:9`! |
| 1576 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profile, MOJOSHADER_PROFILE_GLSLES3cxx . . $ `mojoshader.h:715:9`!) == 0) |
| 1577 | { |
| 1578 | MUST_HAVE_GLSLcxx . . $ `mojoshader_opengl.c:1525:13`!(MOJOSHADER_PROFILE_GLSLES3, 3, 00); |
| 1579 | } // else if |
| 1580 | #endif |
| 1581 | |
| 1582 | #if SUPPORT_PROFILE_GLSLEScxx . . $ `mojoshader_internal.h:190:9`! |
| 1583 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profile, MOJOSHADER_PROFILE_GLSLEScxx . . $ `mojoshader.h:710:9`!) == 0) |
| 1584 | { |
| 1585 | MUST_HAVE_GLSLcxx . . $ `mojoshader_opengl.c:1525:13`!(MOJOSHADER_PROFILE_GLSLES, 1, 00); |
| 1586 | } // else if |
| 1587 | #endif |
| 1588 | |
| 1589 | #if SUPPORT_PROFILE_GLSL120cxx . . $ `mojoshader_internal.h:186:9`! |
| 1590 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profile, MOJOSHADER_PROFILE_GLSL120cxx . . $ `mojoshader.h:705:9`!) == 0) |
| 1591 | { |
| 1592 | MUST_HAVE_GLSLcxx . . $ `mojoshader_opengl.c:1525:13`!(MOJOSHADER_PROFILE_GLSL120, 1, 20); |
| 1593 | } // else if |
| 1594 | #endif |
| 1595 | |
| 1596 | #if SUPPORT_PROFILE_GLSLcxx . . $ `mojoshader_internal.h:182:9`! |
| 1597 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profile, MOJOSHADER_PROFILE_GLSLcxx . . $ `mojoshader.h:700:9`!) == 0) |
| 1598 | { |
| 1599 | MUST_HAVE_GLSLcxx . . $ `mojoshader_opengl.c:1525:13`!(MOJOSHADER_PROFILE_GLSL, 1, 10); |
| 1600 | } // else if |
| 1601 | #endif |
| 1602 | |
| 1603 | else |
| 1604 | { |
| 1605 | set_errorcxx . . $ set_error(85c52e162fed56f9).("unknown or unsupported profile"); |
| 1606 | return 0; |
| 1607 | } // else |
| 1608 | |
| 1609 | #undef MUST_HAVEcxx . . $ `mojoshader_opengl.c:1521:13`! |
| 1610 | |
| 1611 | return 1; |
| 1612 | } // valid_profile |
| 1613 | |
| 1614 | |
| 1615 | static const char *profile_prioritiescxx . . $ profile_priorities.[] = { |
| 1616 | #if SUPPORT_PROFILE_GLSPIRVcxx . . $ `mojoshader_internal.h:214:9`! |
| 1617 | MOJOSHADER_PROFILE_GLSPIRVcxx . . $ `mojoshader.h:753:9`!, |
| 1618 | #endif |
| 1619 | #if SUPPORT_PROFILE_GLSL120cxx . . $ `mojoshader_internal.h:186:9`! |
| 1620 | MOJOSHADER_PROFILE_GLSL120cxx . . $ `mojoshader.h:705:9`!, |
| 1621 | #endif |
| 1622 | #if SUPPORT_PROFILE_GLSLcxx . . $ `mojoshader_internal.h:182:9`! |
| 1623 | MOJOSHADER_PROFILE_GLSLcxx . . $ `mojoshader.h:700:9`!, |
| 1624 | #endif |
| 1625 | #if SUPPORT_PROFILE_ARB1_NVcxx . . $ `mojoshader_internal.h:202:9`! |
| 1626 | MOJOSHADER_PROFILE_NV4cxx . . $ `mojoshader.h:738:9`!, |
| 1627 | MOJOSHADER_PROFILE_NV3cxx . . $ `mojoshader.h:732:9`!, |
| 1628 | MOJOSHADER_PROFILE_NV2cxx . . $ `mojoshader.h:726:9`!, |
| 1629 | #endif |
| 1630 | #if SUPPORT_PROFILE_ARB1cxx . . $ `mojoshader_internal.h:198:9`! |
| 1631 | MOJOSHADER_PROFILE_ARB1cxx . . $ `mojoshader.h:720:9`!, |
| 1632 | #endif |
| 1633 | }; |
| 1634 | |
| 1635 | int MOJOSHADER_glAvailableProfilescxx . . $ MOJOSHADER_glAvailableProfiles(3b3a24d9228d4570).(MOJOSHADER_glGetProcAddresscxx . . $ MOJOSHADER_glGetProcAddress# lookup, |
| 1636 | void *lookup_d, |
| 1637 | const char **profs, const int size, |
| 1638 | MOJOSHADER_malloccxx . . $ MOJOSHADER_malloc# m, MOJOSHADER_freecxx . . $ MOJOSHADER_free# f, |
| 1639 | void *malloc_d) |
| 1640 | { |
| 1641 | int retval = 0; |
| 1642 | MOJOSHADER_glContextcxx . . $ MOJOSHADER_glContext# _ctx; |
| 1643 | MOJOSHADER_glContextcxx . . $ MOJOSHADER_glContext# *current_ctx = ctxcxx . . $ ctx.; |
| 1644 | |
| 1645 | if (m == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) m = MOJOSHADER_internal_malloccxx . . $ MOJOSHADER_internal_malloc(d0e8a54466770ee5).; |
| 1646 | if (f == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) f = MOJOSHADER_internal_freecxx . . $ MOJOSHADER_internal_free(6c58c5e2437d25a2).; |
| 1647 | |
| 1648 | ctxcxx . . $ ctx. = &_ctx; |
| 1649 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(ctxcxx . . $ ctx., '\0', sizeof (MOJOSHADER_glContextcxx . . $ MOJOSHADER_glContext#)); |
| 1650 | ctxcxx . . $ ctx.->malloc_fncxx . . $ MOJOSHADER_glContext#malloc_fn. = m; |
| 1651 | ctxcxx . . $ ctx.->free_fncxx . . $ MOJOSHADER_glContext#free_fn. = f; |
| 1652 | ctxcxx . . $ ctx.->malloc_datacxx . . $ MOJOSHADER_glContext#malloc_data. = malloc_d; |
| 1653 | |
| 1654 | load_extensionscxx . . $ load_extensions(5928c5b85337a06e).(lookup, lookup_d); |
| 1655 | |
| 1656 | #if SUPPORT_PROFILE_GLSLES3cxx . . $ `<built-in>:412:9`! |
| 1657 | if (ctx->have_opengl_es3) |
| 1658 | { |
| 1659 | profs[0] = MOJOSHADER_PROFILE_GLSLES3; |
| 1660 | return 1; |
| 1661 | } // if |
| 1662 | #endif |
| 1663 | |
| 1664 | #if SUPPORT_PROFILE_GLSLEScxx . . $ `mojoshader_internal.h:190:9`! |
| 1665 | if (ctxcxx . . $ ctx.->have_opengl_escxx . . $ MOJOSHADER_glContext#have_opengl_es.) |
| 1666 | { |
| 1667 | profs[0] = MOJOSHADER_PROFILE_GLSLEScxx . . $ `mojoshader.h:710:9`!; |
| 1668 | return 1; |
| 1669 | } // if |
| 1670 | #endif |
| 1671 | |
| 1672 | if (ctxcxx . . $ ctx.->have_core_openglcxx . . $ MOJOSHADER_glContext#have_core_opengl.) |
| 1673 | { |
| 1674 | size_t i; |
| 1675 | for (i = 0; i < STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(profile_priorities); i++) |
| 1676 | { |
| 1677 | const char *profile = profile_prioritiescxx . . $ profile_priorities.[i]; |
| 1678 | if (valid_profilecxx . . $ valid_profile(5c4306d8553b3696).(profile)) |
| 1679 | { |
| 1680 | if (retval < size) |
| 1681 | profs[retval] = profile; |
| 1682 | retval++; |
| 1683 | } // if |
| 1684 | } // for |
| 1685 | } // if |
| 1686 | |
| 1687 | ctxcxx . . $ ctx. = current_ctx; |
| 1688 | return retval; |
| 1689 | } // MOJOSHADER_glAvailableProfiles |
| 1690 | |
| 1691 | |
| 1692 | const char *MOJOSHADER_glBestProfilecxx . . $ MOJOSHADER_glBestProfile(9e574eee0221474a).(MOJOSHADER_glGetProcAddresscxx . . $ MOJOSHADER_glGetProcAddress# gpa, |
| 1693 | void *lookup_d, |
| 1694 | MOJOSHADER_malloccxx . . $ MOJOSHADER_malloc# m, MOJOSHADER_freecxx . . $ MOJOSHADER_free# f, |
| 1695 | void *malloc_d) |
| 1696 | { |
| 1697 | const char *prof[STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(profile_priorities)]; |
| 1698 | const int avail = MOJOSHADER_glAvailableProfilescxx . . $ MOJOSHADER_glAvailableProfiles(3b3a24d9228d4570).(gpa, lookup_d, prof, |
| 1699 | STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(prof), |
| 1700 | m, f, malloc_d); |
| 1701 | if (avail <= 0) |
| 1702 | { |
| 1703 | set_errorcxx . . $ set_error(85c52e162fed56f9).("no profiles available"); |
| 1704 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1705 | } // if |
| 1706 | |
| 1707 | return prof[0]; // profiles are sorted "best" to "worst." |
| 1708 | } // MOJOSHADER_glBestProfile |
| 1709 | |
| 1710 | |
| 1711 | MOJOSHADER_glContextcxx . . $ MOJOSHADER_glContext# *MOJOSHADER_glCreateContextcxx . . $ MOJOSHADER_glCreateContext(9bd61f5b213a9467).(const char *profile, |
| 1712 | MOJOSHADER_glGetProcAddresscxx . . $ MOJOSHADER_glGetProcAddress# lookup, |
| 1713 | void *lookup_d, |
| 1714 | MOJOSHADER_malloccxx . . $ MOJOSHADER_malloc# m, MOJOSHADER_freecxx . . $ MOJOSHADER_free# f, |
| 1715 | void *malloc_d) |
| 1716 | { |
| 1717 | MOJOSHADER_glContextcxx . . $ MOJOSHADER_glContext# *retval = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1718 | MOJOSHADER_glContextcxx . . $ MOJOSHADER_glContext# *current_ctx = ctxcxx . . $ ctx.; |
| 1719 | |
| 1720 | ctxcxx . . $ ctx. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1721 | |
| 1722 | if (m == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) m = MOJOSHADER_internal_malloccxx . . $ MOJOSHADER_internal_malloc(d0e8a54466770ee5).; |
| 1723 | if (f == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) f = MOJOSHADER_internal_freecxx . . $ MOJOSHADER_internal_free(6c58c5e2437d25a2).; |
| 1724 | |
| 1725 | ctxcxx . . $ ctx. = (MOJOSHADER_glContextcxx . . $ MOJOSHADER_glContext# *) m(sizeof (MOJOSHADER_glContextcxx . . $ MOJOSHADER_glContext#), malloc_d); |
| 1726 | if (ctxcxx . . $ ctx. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1727 | { |
| 1728 | out_of_memorycxx . . $ out_of_memory(49f6e7a06ebc5aa8).(); |
| 1729 | goto init_fail; |
| 1730 | } // if |
| 1731 | |
| 1732 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(ctxcxx . . $ ctx., '\0', sizeof (MOJOSHADER_glContextcxx . . $ MOJOSHADER_glContext#)); |
| 1733 | ctxcxx . . $ ctx.->malloc_fncxx . . $ MOJOSHADER_glContext#malloc_fn. = m; |
| 1734 | ctxcxx . . $ ctx.->free_fncxx . . $ MOJOSHADER_glContext#free_fn. = f; |
| 1735 | ctxcxx . . $ ctx.->malloc_datacxx . . $ MOJOSHADER_glContext#malloc_data. = malloc_d; |
| 1736 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(ctxcxx . . $ ctx.->profilecxx . . $ MOJOSHADER_glContext#profile., sizeof (ctxcxx . . $ ctx.->profilecxx . . $ MOJOSHADER_glContext#profile.), "%s", profile); |
| 1737 | |
| 1738 | load_extensionscxx . . $ load_extensions(5928c5b85337a06e).(lookup, lookup_d); |
| 1739 | if (!valid_profilecxx . . $ valid_profile(5c4306d8553b3696).(profile)) |
| 1740 | goto init_fail; |
| 1741 | |
| 1742 | #ifdef MOJOSHADER_XNA4_VERTEX_TEXTURES |
| 1743 | GLint maxTextures; |
| 1744 | GLint maxVertexTextures; |
| 1745 | ctx->glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextures); |
| 1746 | if (maxTextures > 20) |
| 1747 | maxTextures = 20; |
| 1748 | if (maxTextures > 16) |
| 1749 | maxVertexTextures = maxTextures - 16; |
| 1750 | else |
| 1751 | maxVertexTextures = 0; |
| 1752 | ctx->vertex_sampler_offset = maxTextures - maxVertexTextures; |
| 1753 | #endif |
| 1754 | |
| 1755 | MOJOSHADER_glBindProgramcxx . . $ MOJOSHADER_glBindProgram(b6cc5ff6e33eca9d).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1756 | |
| 1757 | // !!! FIXME: generalize this part. |
| 1758 | if (profile == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {} |
| 1759 | |
| 1760 | // We don't check SUPPORT_PROFILE_GLSPIRV here, since valid_profile() does. |
| 1761 | #if SUPPORT_PROFILE_GLSPIRVcxx . . $ `mojoshader_internal.h:214:9`! |
| 1762 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profile, MOJOSHADER_PROFILE_GLSPIRVcxx . . $ `mojoshader.h:753:9`!) == 0) |
| 1763 | { |
| 1764 | ctxcxx . . $ ctx.->profileMaxUniformscxx . . $ MOJOSHADER_glContext#profileMaxUniforms. = impl_GLSL_MaxUniformscxx . . $ impl_GLSL_MaxUniforms(31af91354e387fe).; |
| 1765 | ctxcxx . . $ ctx.->profileCompileShadercxx . . $ MOJOSHADER_glContext#profileCompileShader. = impl_SPIRV_CompileShadercxx . . $ impl_SPIRV_CompileShader(ec98bc26451bb3a1).; |
| 1766 | ctxcxx . . $ ctx.->profileDeleteShadercxx . . $ MOJOSHADER_glContext#profileDeleteShader. = impl_SPIRV_DeleteShadercxx . . $ impl_SPIRV_DeleteShader(cb2f890c2fdad230).; |
| 1767 | ctxcxx . . $ ctx.->profileDeleteProgramcxx . . $ MOJOSHADER_glContext#profileDeleteProgram. = impl_SPIRV_DeleteProgramcxx . . $ impl_SPIRV_DeleteProgram(cb2f890c2fdad230).; |
| 1768 | ctxcxx . . $ ctx.->profileGetAttribLocationcxx . . $ MOJOSHADER_glContext#profileGetAttribLocation. = impl_SPIRV_GetAttribLocationcxx . . $ impl_SPIRV_GetAttribLocation(68cbdf50a567c948).; |
| 1769 | ctxcxx . . $ ctx.->profileGetUniformLocationcxx . . $ MOJOSHADER_glContext#profileGetUniformLocation. = impl_SPIRV_GetUniformLocationcxx . . $ impl_SPIRV_GetUniformLocation(68ce97c0384b6dea).; |
| 1770 | ctxcxx . . $ ctx.->profileGetSamplerLocationcxx . . $ MOJOSHADER_glContext#profileGetSamplerLocation. = impl_SPIRV_GetSamplerLocationcxx . . $ impl_SPIRV_GetSamplerLocation(68ce97c0384b6dea).; |
| 1771 | ctxcxx . . $ ctx.->profileLinkProgramcxx . . $ MOJOSHADER_glContext#profileLinkProgram. = impl_SPIRV_LinkProgramcxx . . $ impl_SPIRV_LinkProgram(3128a097761c2828).; |
| 1772 | ctxcxx . . $ ctx.->profileFinalInitProgramcxx . . $ MOJOSHADER_glContext#profileFinalInitProgram. = impl_SPIRV_FinalInitProgramcxx . . $ impl_SPIRV_FinalInitProgram(b6cc5ff6e33eca9d).; |
| 1773 | ctxcxx . . $ ctx.->profileUseProgramcxx . . $ MOJOSHADER_glContext#profileUseProgram. = impl_GLSL_UseProgramcxx . . $ impl_GLSL_UseProgram(b6cc5ff6e33eca9d).; |
| 1774 | ctxcxx . . $ ctx.->profilePushConstantArraycxx . . $ MOJOSHADER_glContext#profilePushConstantArray. = impl_GLSL_PushConstantArraycxx . . $ impl_GLSL_PushConstantArray(d04408542d836fa4).; |
| 1775 | ctxcxx . . $ ctx.->profilePushUniformscxx . . $ MOJOSHADER_glContext#profilePushUniforms. = impl_GLSL_PushUniformscxx . . $ impl_GLSL_PushUniforms(49f6e7a06ebc5aa8).; |
| 1776 | ctxcxx . . $ ctx.->profilePushSamplercxx . . $ MOJOSHADER_glContext#profilePushSampler. = impl_GLSL_PushSamplercxx . . $ impl_GLSL_PushSampler(c8dafc4a64bf4a1c).; |
| 1777 | ctxcxx . . $ ctx.->profileMustPushConstantArrayscxx . . $ MOJOSHADER_glContext#profileMustPushConstantArrays. = impl_GLSL_MustPushConstantArrayscxx . . $ impl_GLSL_MustPushConstantArrays(b126dc7c1de90089).; |
| 1778 | ctxcxx . . $ ctx.->profileMustPushSamplerscxx . . $ MOJOSHADER_glContext#profileMustPushSamplers. = impl_GLSL_MustPushSamplerscxx . . $ impl_GLSL_MustPushSamplers(b126dc7c1de90089).; |
| 1779 | ctxcxx . . $ ctx.->profileToggleProgramPointSizecxx . . $ MOJOSHADER_glContext#profileToggleProgramPointSize. = impl_REAL_ToggleProgramPointSizecxx . . $ impl_REAL_ToggleProgramPointSize(d4f767463ce0a6b3).; |
| 1780 | } // if |
| 1781 | #endif |
| 1782 | |
| 1783 | // We don't check SUPPORT_PROFILE_GLSL120/ES here, since valid_profile() does. |
| 1784 | #if SUPPORT_PROFILE_GLSLcxx . . $ `mojoshader_internal.h:182:9`! |
| 1785 | else if ( (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profile, MOJOSHADER_PROFILE_GLSLcxx . . $ `mojoshader.h:700:9`!) == 0) || |
| 1786 | (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profile, MOJOSHADER_PROFILE_GLSL120cxx . . $ `mojoshader.h:705:9`!) == 0) || |
| 1787 | (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profile, MOJOSHADER_PROFILE_GLSLEScxx . . $ `mojoshader.h:710:9`!) == 0) || |
| 1788 | (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profile, MOJOSHADER_PROFILE_GLSLES3cxx . . $ `mojoshader.h:715:9`!) == 0) ) |
| 1789 | { |
| 1790 | ctxcxx . . $ ctx.->profileMaxUniformscxx . . $ MOJOSHADER_glContext#profileMaxUniforms. = impl_GLSL_MaxUniformscxx . . $ impl_GLSL_MaxUniforms(31af91354e387fe).; |
| 1791 | ctxcxx . . $ ctx.->profileCompileShadercxx . . $ MOJOSHADER_glContext#profileCompileShader. = impl_GLSL_CompileShadercxx . . $ impl_GLSL_CompileShader(ec98bc26451bb3a1).; |
| 1792 | ctxcxx . . $ ctx.->profileDeleteShadercxx . . $ MOJOSHADER_glContext#profileDeleteShader. = impl_GLSL_DeleteShadercxx . . $ impl_GLSL_DeleteShader(cb2f890c2fdad230).; |
| 1793 | ctxcxx . . $ ctx.->profileDeleteProgramcxx . . $ MOJOSHADER_glContext#profileDeleteProgram. = impl_GLSL_DeleteProgramcxx . . $ impl_GLSL_DeleteProgram(cb2f890c2fdad230).; |
| 1794 | ctxcxx . . $ ctx.->profileGetAttribLocationcxx . . $ MOJOSHADER_glContext#profileGetAttribLocation. = impl_GLSL_GetAttribLocationcxx . . $ impl_GLSL_GetAttribLocation(68cbdf50a567c948).; |
| 1795 | ctxcxx . . $ ctx.->profileGetUniformLocationcxx . . $ MOJOSHADER_glContext#profileGetUniformLocation. = impl_GLSL_GetUniformLocationcxx . . $ impl_GLSL_GetUniformLocation(68ce97c0384b6dea).; |
| 1796 | ctxcxx . . $ ctx.->profileGetSamplerLocationcxx . . $ MOJOSHADER_glContext#profileGetSamplerLocation. = impl_GLSL_GetSamplerLocationcxx . . $ impl_GLSL_GetSamplerLocation(68ce97c0384b6dea).; |
| 1797 | ctxcxx . . $ ctx.->profileLinkProgramcxx . . $ MOJOSHADER_glContext#profileLinkProgram. = impl_GLSL_LinkProgramcxx . . $ impl_GLSL_LinkProgram(3128a097761c2828).; |
| 1798 | ctxcxx . . $ ctx.->profileFinalInitProgramcxx . . $ MOJOSHADER_glContext#profileFinalInitProgram. = impl_GLSL_FinalInitProgramcxx . . $ impl_GLSL_FinalInitProgram(b6cc5ff6e33eca9d).; |
| 1799 | ctxcxx . . $ ctx.->profileUseProgramcxx . . $ MOJOSHADER_glContext#profileUseProgram. = impl_GLSL_UseProgramcxx . . $ impl_GLSL_UseProgram(b6cc5ff6e33eca9d).; |
| 1800 | ctxcxx . . $ ctx.->profilePushConstantArraycxx . . $ MOJOSHADER_glContext#profilePushConstantArray. = impl_GLSL_PushConstantArraycxx . . $ impl_GLSL_PushConstantArray(d04408542d836fa4).; |
| 1801 | ctxcxx . . $ ctx.->profilePushUniformscxx . . $ MOJOSHADER_glContext#profilePushUniforms. = impl_GLSL_PushUniformscxx . . $ impl_GLSL_PushUniforms(49f6e7a06ebc5aa8).; |
| 1802 | ctxcxx . . $ ctx.->profilePushSamplercxx . . $ MOJOSHADER_glContext#profilePushSampler. = impl_GLSL_PushSamplercxx . . $ impl_GLSL_PushSampler(c8dafc4a64bf4a1c).; |
| 1803 | ctxcxx . . $ ctx.->profileMustPushConstantArrayscxx . . $ MOJOSHADER_glContext#profileMustPushConstantArrays. = impl_GLSL_MustPushConstantArrayscxx . . $ impl_GLSL_MustPushConstantArrays(b126dc7c1de90089).; |
| 1804 | ctxcxx . . $ ctx.->profileMustPushSamplerscxx . . $ MOJOSHADER_glContext#profileMustPushSamplers. = impl_GLSL_MustPushSamplerscxx . . $ impl_GLSL_MustPushSamplers(b126dc7c1de90089).; |
| 1805 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profile, MOJOSHADER_PROFILE_GLSLEScxx . . $ `mojoshader.h:710:9`!) == 0 || strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profile, MOJOSHADER_PROFILE_GLSLES3cxx . . $ `mojoshader.h:715:9`!) == 0) |
| 1806 | ctxcxx . . $ ctx.->profileToggleProgramPointSizecxx . . $ MOJOSHADER_glContext#profileToggleProgramPointSize. = impl_NOOP_ToggleProgramPointSizecxx . . $ impl_NOOP_ToggleProgramPointSize(d4f767463ce0a6b3).; |
| 1807 | else |
| 1808 | ctxcxx . . $ ctx.->profileToggleProgramPointSizecxx . . $ MOJOSHADER_glContext#profileToggleProgramPointSize. = impl_REAL_ToggleProgramPointSizecxx . . $ impl_REAL_ToggleProgramPointSize(d4f767463ce0a6b3).; |
| 1809 | } // if |
| 1810 | #endif |
| 1811 | |
| 1812 | // We don't check SUPPORT_PROFILE_ARB1_NV here, since valid_profile() does. |
| 1813 | #if SUPPORT_PROFILE_ARB1cxx . . $ `mojoshader_internal.h:198:9`! |
| 1814 | else if ( (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profile, MOJOSHADER_PROFILE_ARB1cxx . . $ `mojoshader.h:720:9`!) == 0) || |
| 1815 | (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profile, MOJOSHADER_PROFILE_NV2cxx . . $ `mojoshader.h:726:9`!) == 0) || |
| 1816 | (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profile, MOJOSHADER_PROFILE_NV3cxx . . $ `mojoshader.h:732:9`!) == 0) || |
| 1817 | (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profile, MOJOSHADER_PROFILE_NV4cxx . . $ `mojoshader.h:738:9`!) == 0) ) |
| 1818 | { |
| 1819 | ctxcxx . . $ ctx.->profileMaxUniformscxx . . $ MOJOSHADER_glContext#profileMaxUniforms. = impl_ARB1_MaxUniformscxx . . $ impl_ARB1_MaxUniforms(31af91354e387fe).; |
| 1820 | ctxcxx . . $ ctx.->profileCompileShadercxx . . $ MOJOSHADER_glContext#profileCompileShader. = impl_ARB1_CompileShadercxx . . $ impl_ARB1_CompileShader(ec98bc26451bb3a1).; |
| 1821 | ctxcxx . . $ ctx.->profileDeleteShadercxx . . $ MOJOSHADER_glContext#profileDeleteShader. = impl_ARB1_DeleteShadercxx . . $ impl_ARB1_DeleteShader(cb2f890c2fdad230).; |
| 1822 | ctxcxx . . $ ctx.->profileDeleteProgramcxx . . $ MOJOSHADER_glContext#profileDeleteProgram. = impl_ARB1_DeleteProgramcxx . . $ impl_ARB1_DeleteProgram(cb2f890c2fdad230).; |
| 1823 | ctxcxx . . $ ctx.->profileGetAttribLocationcxx . . $ MOJOSHADER_glContext#profileGetAttribLocation. = impl_ARB1_GetAttribLocationcxx . . $ impl_ARB1_GetAttribLocation(68cbdf50a567c948).; |
| 1824 | ctxcxx . . $ ctx.->profileGetUniformLocationcxx . . $ MOJOSHADER_glContext#profileGetUniformLocation. = impl_ARB1_GetUniformLocationcxx . . $ impl_ARB1_GetUniformLocation(68ce97c0384b6dea).; |
| 1825 | ctxcxx . . $ ctx.->profileGetSamplerLocationcxx . . $ MOJOSHADER_glContext#profileGetSamplerLocation. = impl_ARB1_GetSamplerLocationcxx . . $ impl_ARB1_GetSamplerLocation(68ce97c0384b6dea).; |
| 1826 | ctxcxx . . $ ctx.->profileLinkProgramcxx . . $ MOJOSHADER_glContext#profileLinkProgram. = impl_ARB1_LinkProgramcxx . . $ impl_ARB1_LinkProgram(3128a097761c2828).; |
| 1827 | ctxcxx . . $ ctx.->profileFinalInitProgramcxx . . $ MOJOSHADER_glContext#profileFinalInitProgram. = impl_ARB1_FinalInitProgramcxx . . $ impl_ARB1_FinalInitProgram(b6cc5ff6e33eca9d).; |
| 1828 | ctxcxx . . $ ctx.->profileUseProgramcxx . . $ MOJOSHADER_glContext#profileUseProgram. = impl_ARB1_UseProgramcxx . . $ impl_ARB1_UseProgram(b6cc5ff6e33eca9d).; |
| 1829 | ctxcxx . . $ ctx.->profilePushConstantArraycxx . . $ MOJOSHADER_glContext#profilePushConstantArray. = impl_ARB1_PushConstantArraycxx . . $ impl_ARB1_PushConstantArray(d04408542d836fa4).; |
| 1830 | ctxcxx . . $ ctx.->profilePushUniformscxx . . $ MOJOSHADER_glContext#profilePushUniforms. = impl_ARB1_PushUniformscxx . . $ impl_ARB1_PushUniforms(49f6e7a06ebc5aa8).; |
| 1831 | ctxcxx . . $ ctx.->profilePushSamplercxx . . $ MOJOSHADER_glContext#profilePushSampler. = impl_ARB1_PushSamplercxx . . $ impl_ARB1_PushSampler(c8dafc4a64bf4a1c).; |
| 1832 | ctxcxx . . $ ctx.->profileMustPushConstantArrayscxx . . $ MOJOSHADER_glContext#profileMustPushConstantArrays. = impl_ARB1_MustPushConstantArrayscxx . . $ impl_ARB1_MustPushConstantArrays(b126dc7c1de90089).; |
| 1833 | ctxcxx . . $ ctx.->profileMustPushSamplerscxx . . $ MOJOSHADER_glContext#profileMustPushSamplers. = impl_ARB1_MustPushSamplerscxx . . $ impl_ARB1_MustPushSamplers(b126dc7c1de90089).; |
| 1834 | ctxcxx . . $ ctx.->profileToggleProgramPointSizecxx . . $ MOJOSHADER_glContext#profileToggleProgramPointSize. = impl_REAL_ToggleProgramPointSizecxx . . $ impl_REAL_ToggleProgramPointSize(d4f767463ce0a6b3).; |
| 1835 | } // if |
| 1836 | #endif |
| 1837 | |
| 1838 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->profileMaxUniforms != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1839 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->profileCompileShader != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1840 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->profileDeleteShader != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1841 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->profileDeleteProgram != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1842 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->profileMaxUniforms != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1843 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->profileGetAttribLocation != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1844 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->profileGetUniformLocation != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1845 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->profileGetSamplerLocation != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1846 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->profileLinkProgram != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1847 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->profileFinalInitProgram != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1848 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->profileUseProgram != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1849 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->profilePushConstantArray != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1850 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->profilePushUniforms != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1851 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->profilePushSampler != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1852 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->profileMustPushConstantArrays != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1853 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->profileMustPushSamplers != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1854 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->profileToggleProgramPointSize != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1855 | |
| 1856 | retval = ctxcxx . . $ ctx.; |
| 1857 | ctxcxx . . $ ctx. = current_ctx; |
| 1858 | return retval; |
| 1859 | |
| 1860 | init_fail: |
| 1861 | if (ctxcxx . . $ ctx. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1862 | f(ctxcxx . . $ ctx., malloc_d); |
| 1863 | ctxcxx . . $ ctx. = current_ctx; |
| 1864 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1865 | } // MOJOSHADER_glCreateContext |
| 1866 | |
| 1867 | |
| 1868 | void MOJOSHADER_glMakeContextCurrentcxx . . $ MOJOSHADER_glMakeContextCurrent(512d40087428bebb).(MOJOSHADER_glContextcxx . . $ MOJOSHADER_glContext# *_ctx) |
| 1869 | { |
| 1870 | ctxcxx . . $ ctx. = _ctx; |
| 1871 | } // MOJOSHADER_glMakeContextCurrent |
| 1872 | |
| 1873 | |
| 1874 | int MOJOSHADER_glMaxUniformscxx . . $ MOJOSHADER_glMaxUniforms(31af91354e387fe).(MOJOSHADER_shaderTypecxx . . $ MOJOSHADER_shaderType# shader_type) |
| 1875 | { |
| 1876 | return ctxcxx . . $ ctx.->profileMaxUniformscxx . . $ MOJOSHADER_glContext#profileMaxUniforms.(shader_type); |
| 1877 | } // MOJOSHADER_glMaxUniforms |
| 1878 | |
| 1879 | |
| 1880 | MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *MOJOSHADER_glCompileShadercxx . . $ MOJOSHADER_glCompileShader(d9f5a783dddaff9b).(const unsigned char *tokenbuf, |
| 1881 | const unsigned int bufsize, |
| 1882 | const MOJOSHADER_swizzlecxx . . $ MOJOSHADER_swizzle# *swiz, |
| 1883 | const unsigned int swizcount, |
| 1884 | const MOJOSHADER_samplerMapcxx . . $ MOJOSHADER_samplerMap# *smap, |
| 1885 | const unsigned int smapcount) |
| 1886 | { |
| 1887 | MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *retval = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1888 | GLuintcxx . . $ GLuint# shader = 0; |
| 1889 | |
| 1890 | // This doesn't need a mainfn, since there's no GL lang that does. |
| 1891 | const MOJOSHADER_parseDatacxx . . $ MOJOSHADER_parseData# *pd = MOJOSHADER_parsecxx . . $ MOJOSHADER_parse(ff0909865cf9979a).(ctxcxx . . $ ctx.->profilecxx . . $ MOJOSHADER_glContext#profile., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 1892 | tokenbuf, bufsize, |
| 1893 | swiz, swizcount, |
| 1894 | smap, smapcount, |
| 1895 | ctxcxx . . $ ctx.->malloc_fncxx . . $ MOJOSHADER_glContext#malloc_fn., |
| 1896 | ctxcxx . . $ ctx.->free_fncxx . . $ MOJOSHADER_glContext#free_fn., |
| 1897 | ctxcxx . . $ ctx.->malloc_datacxx . . $ MOJOSHADER_glContext#malloc_data.); |
| 1898 | if (pd->error_countcxx . . $ MOJOSHADER_parseData#error_count. > 0) |
| 1899 | { |
| 1900 | // !!! FIXME: put multiple errors in the buffer? Don't use |
| 1901 | // !!! FIXME: MOJOSHADER_glGetError() for this? |
| 1902 | set_errorcxx . . $ set_error(85c52e162fed56f9).(pd->errorscxx . . $ MOJOSHADER_parseData#errors.[0].errorcxx . . $ MOJOSHADER_error#error.); |
| 1903 | goto compile_shader_fail; |
| 1904 | } // if |
| 1905 | |
| 1906 | retval = (MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *) Malloccxx . . $ Malloc(bfcfa4d6b7f7ef64).(sizeof (MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader#)); |
| 1907 | if (retval == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1908 | goto compile_shader_fail; |
| 1909 | |
| 1910 | if (!ctxcxx . . $ ctx.->profileCompileShadercxx . . $ MOJOSHADER_glContext#profileCompileShader.(pd, &shader)) |
| 1911 | goto compile_shader_fail; |
| 1912 | |
| 1913 | retval->parseDatacxx . . $ MOJOSHADER_glShader#parseData. = pd; |
| 1914 | retval->handlecxx . . $ MOJOSHADER_glShader#handle. = shader; |
| 1915 | retval->refcountcxx . . $ MOJOSHADER_glShader#refcount. = 1; |
| 1916 | return retval; |
| 1917 | |
| 1918 | compile_shader_fail: |
| 1919 | MOJOSHADER_freeParseDatacxx . . $ MOJOSHADER_freeParseData(c292f651a0772a1d).(pd); |
| 1920 | Freecxx . . $ Free(5d22bdacc48458e8).(retval); |
| 1921 | if (shader != 0) |
| 1922 | ctxcxx . . $ ctx.->profileDeleteShadercxx . . $ MOJOSHADER_glContext#profileDeleteShader.(shader); |
| 1923 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1924 | } // MOJOSHADER_glCompileShader |
| 1925 | |
| 1926 | |
| 1927 | void MOJOSHADER_glShaderAddRefcxx . . $ MOJOSHADER_glShaderAddRef(faf9002d9d72f6c2).(MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *shader) |
| 1928 | { |
| 1929 | if (shader != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1930 | shader->refcountcxx . . $ MOJOSHADER_glShader#refcount.++; |
| 1931 | } // MOJOSHADER_glShaderAddRef |
| 1932 | |
| 1933 | |
| 1934 | const MOJOSHADER_parseDatacxx . . $ MOJOSHADER_parseData# *MOJOSHADER_glGetShaderParseDatacxx . . $ MOJOSHADER_glGetShaderParseData(6c5741abd4b24cbc).( |
| 1935 | MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *shader) |
| 1936 | { |
| 1937 | return (shader != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ? shader->parseDatacxx . . $ MOJOSHADER_glShader#parseData. : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1938 | } // MOJOSHADER_glGetShaderParseData |
| 1939 | |
| 1940 | |
| 1941 | static void shader_unrefcxx . . $ shader_unref(faf9002d9d72f6c2).(MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *shader) |
| 1942 | { |
| 1943 | if (shader != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1944 | { |
| 1945 | const uint32cxx . . $ uint32# refcount = shader->refcountcxx . . $ MOJOSHADER_glShader#refcount.; |
| 1946 | if (refcount > 1) |
| 1947 | shader->refcountcxx . . $ MOJOSHADER_glShader#refcount.--; |
| 1948 | else |
| 1949 | { |
| 1950 | ctxcxx . . $ ctx.->profileDeleteShadercxx . . $ MOJOSHADER_glContext#profileDeleteShader.(shader->handlecxx . . $ MOJOSHADER_glShader#handle.); |
| 1951 | MOJOSHADER_freeParseDatacxx . . $ MOJOSHADER_freeParseData(c292f651a0772a1d).(shader->parseDatacxx . . $ MOJOSHADER_glShader#parseData.); |
| 1952 | Freecxx . . $ Free(5d22bdacc48458e8).(shader); |
| 1953 | } // else |
| 1954 | } // if |
| 1955 | } // shader_unref |
| 1956 | |
| 1957 | |
| 1958 | static void program_unrefcxx . . $ program_unref(b6cc5ff6e33eca9d).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program) |
| 1959 | { |
| 1960 | if (program != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1961 | { |
| 1962 | const uint32cxx . . $ uint32# refcount = program->refcountcxx . . $ MOJOSHADER_glProgram#refcount.; |
| 1963 | if (refcount > 1) |
| 1964 | program->refcountcxx . . $ MOJOSHADER_glProgram#refcount.--; |
| 1965 | else |
| 1966 | { |
| 1967 | ctxcxx . . $ ctx.->profileDeleteProgramcxx . . $ MOJOSHADER_glContext#profileDeleteProgram.(program->handlecxx . . $ MOJOSHADER_glProgram#handle.); |
| 1968 | shader_unrefcxx . . $ shader_unref(faf9002d9d72f6c2).(program->vertexcxx . . $ MOJOSHADER_glProgram#vertex.); |
| 1969 | shader_unrefcxx . . $ shader_unref(faf9002d9d72f6c2).(program->fragmentcxx . . $ MOJOSHADER_glProgram#fragment.); |
| 1970 | Freecxx . . $ Free(5d22bdacc48458e8).(program->vs_uniforms_float4cxx . . $ MOJOSHADER_glProgram#vs_uniforms_float4.); |
| 1971 | Freecxx . . $ Free(5d22bdacc48458e8).(program->vs_uniforms_int4cxx . . $ MOJOSHADER_glProgram#vs_uniforms_int4.); |
| 1972 | Freecxx . . $ Free(5d22bdacc48458e8).(program->vs_uniforms_boolcxx . . $ MOJOSHADER_glProgram#vs_uniforms_bool.); |
| 1973 | Freecxx . . $ Free(5d22bdacc48458e8).(program->ps_uniforms_float4cxx . . $ MOJOSHADER_glProgram#ps_uniforms_float4.); |
| 1974 | Freecxx . . $ Free(5d22bdacc48458e8).(program->ps_uniforms_int4cxx . . $ MOJOSHADER_glProgram#ps_uniforms_int4.); |
| 1975 | Freecxx . . $ Free(5d22bdacc48458e8).(program->ps_uniforms_boolcxx . . $ MOJOSHADER_glProgram#ps_uniforms_bool.); |
| 1976 | Freecxx . . $ Free(5d22bdacc48458e8).(program->uniformscxx . . $ MOJOSHADER_glProgram#uniforms.); |
| 1977 | Freecxx . . $ Free(5d22bdacc48458e8).(program->attributescxx . . $ MOJOSHADER_glProgram#attributes.); |
| 1978 | Freecxx . . $ Free(5d22bdacc48458e8).(program); |
| 1979 | } // else |
| 1980 | } // if |
| 1981 | } // program_unref |
| 1982 | |
| 1983 | |
| 1984 | static void fill_constant_arraycxx . . $ fill_constant_array(353934d41e594be2).(GLfloatcxx . . $ GLfloat# *f, const int base, const int size, |
| 1985 | const MOJOSHADER_parseDatacxx . . $ MOJOSHADER_parseData# *pd) |
| 1986 | { |
| 1987 | int i; |
| 1988 | int filled = 0; |
| 1989 | for (i = 0; i < pd->constant_countcxx . . $ MOJOSHADER_parseData#constant_count.; i++) |
| 1990 | { |
| 1991 | const MOJOSHADER_constantcxx . . $ MOJOSHADER_constant# *c = &pd->constantscxx . . $ MOJOSHADER_parseData#constants.[i]; |
| 1992 | if (c->typecxx . . $ MOJOSHADER_constant#type. != MOJOSHADER_UNIFORM_FLOATcxx . . $ MOJOSHADER_UNIFORM_FLOAT.) |
| 1993 | continue; |
| 1994 | else if (c->indexcxx . . $ MOJOSHADER_constant#index. < base) |
| 1995 | continue; |
| 1996 | else if (c->indexcxx . . $ MOJOSHADER_constant#index. >= (base+size)) |
| 1997 | continue; |
| 1998 | memcpycxx . . $ memcpy(cc817cb175f282d).(&f[(c->indexcxx . . $ MOJOSHADER_constant#index.-base) * 4], &c->valuecxx . . $ MOJOSHADER_constant#value..fcxx . . $ MOJOSHADER_constant#$anonymous_type_3#f., sizeof (c->valuecxx . . $ MOJOSHADER_constant#value..fcxx . . $ MOJOSHADER_constant#$anonymous_type_3#f.)); |
| 1999 | filled++; |
| 2000 | } // for |
| 2001 | |
| 2002 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(filled == size); |
| 2003 | } // fill_constant_array |
| 2004 | |
| 2005 | |
| 2006 | static int lookup_uniformscxx . . $ lookup_uniforms(dd0f2c3b2898b958).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program, |
| 2007 | MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *shader, int *bound) |
| 2008 | { |
| 2009 | const MOJOSHADER_parseDatacxx . . $ MOJOSHADER_parseData# *pd = shader->parseDatacxx . . $ MOJOSHADER_glShader#parseData.; |
| 2010 | const MOJOSHADER_shaderTypecxx . . $ MOJOSHADER_shaderType# shader_type = pd->shader_typecxx . . $ MOJOSHADER_parseData#shader_type.; |
| 2011 | uint32cxx . . $ uint32# float4_count = 0; |
| 2012 | uint32cxx . . $ uint32# int4_count = 0; |
| 2013 | uint32cxx . . $ uint32# bool_count = 0; |
| 2014 | int i; |
| 2015 | |
| 2016 | for (i = 0; i < pd->uniform_countcxx . . $ MOJOSHADER_parseData#uniform_count.; i++) |
| 2017 | { |
| 2018 | const MOJOSHADER_uniformcxx . . $ MOJOSHADER_uniform# *u = &pd->uniformscxx . . $ MOJOSHADER_parseData#uniforms.[i]; |
| 2019 | |
| 2020 | if (u->constantcxx . . $ MOJOSHADER_uniform#constant.) |
| 2021 | { |
| 2022 | // only do constants once, at link time. These aren't changed ever. |
| 2023 | if (ctxcxx . . $ ctx.->profileMustPushConstantArrayscxx . . $ MOJOSHADER_glContext#profileMustPushConstantArrays.()) |
| 2024 | { |
| 2025 | const int base = u->indexcxx . . $ MOJOSHADER_uniform#index.; |
| 2026 | const int size = u->array_countcxx . . $ MOJOSHADER_uniform#array_count.; |
| 2027 | GLfloatcxx . . $ GLfloat# *f = (GLfloatcxx . . $ GLfloat# *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(sizeof (GLfloat) * (size * 4)); |
| 2028 | fill_constant_arraycxx . . $ fill_constant_array(353934d41e594be2).(f, base, size, pd); |
| 2029 | if (!(*bound)) |
| 2030 | { |
| 2031 | ctxcxx . . $ ctx.->profileUseProgramcxx . . $ MOJOSHADER_glContext#profileUseProgram.(program); |
| 2032 | *bound = 1; |
| 2033 | } // if |
| 2034 | ctxcxx . . $ ctx.->profilePushConstantArraycxx . . $ MOJOSHADER_glContext#profilePushConstantArray.(program, u, f); |
| 2035 | } // if |
| 2036 | } // if |
| 2037 | |
| 2038 | else |
| 2039 | { |
| 2040 | const GLintcxx . . $ GLint# loc = ctxcxx . . $ ctx.->profileGetUniformLocationcxx . . $ MOJOSHADER_glContext#profileGetUniformLocation.(program, shader, i); |
| 2041 | if (loc != -1) // -1 means it was optimized out, or failure. |
| 2042 | { |
| 2043 | const int regcount = u->array_countcxx . . $ MOJOSHADER_uniform#array_count.; |
| 2044 | UniformMapcxx . . $ UniformMap# *map = &program->uniformscxx . . $ MOJOSHADER_glProgram#uniforms.[program->uniform_countcxx . . $ MOJOSHADER_glProgram#uniform_count.]; |
| 2045 | map->shader_typecxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_0#shader_type. = shader_type; |
| 2046 | map->uniformcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_0#uniform. = u; |
| 2047 | map->locationcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_0#location. = (GLuintcxx . . $ GLuint#) loc; |
| 2048 | program->uniform_countcxx . . $ MOJOSHADER_glProgram#uniform_count.++; |
| 2049 | |
| 2050 | if (u->typecxx . . $ MOJOSHADER_uniform#type. == MOJOSHADER_UNIFORM_FLOATcxx . . $ MOJOSHADER_UNIFORM_FLOAT.) |
| 2051 | float4_count += regcount ? regcount : 1; |
| 2052 | else if (u->typecxx . . $ MOJOSHADER_uniform#type. == MOJOSHADER_UNIFORM_INTcxx . . $ MOJOSHADER_UNIFORM_INT.) |
| 2053 | int4_count += regcount ? regcount : 1; |
| 2054 | else if (u->typecxx . . $ MOJOSHADER_uniform#type. == MOJOSHADER_UNIFORM_BOOLcxx . . $ MOJOSHADER_UNIFORM_BOOL.) |
| 2055 | bool_count += regcount ? regcount : 1; |
| 2056 | else |
| 2057 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(0 && "Unexpected register type"); |
| 2058 | } // if |
| 2059 | } // else |
| 2060 | } // for |
| 2061 | |
| 2062 | if (shader_type == MOJOSHADER_TYPE_PIXELcxx . . $ MOJOSHADER_TYPE_PIXEL.) |
| 2063 | { |
| 2064 | for (i = 0; i < pd->sampler_countcxx . . $ MOJOSHADER_parseData#sampler_count.; i++) |
| 2065 | { |
| 2066 | if (pd->samplerscxx . . $ MOJOSHADER_parseData#samplers.[i].texbemcxx . . $ MOJOSHADER_sampler#texbem.) |
| 2067 | { |
| 2068 | float4_count += 2; |
| 2069 | program->texbem_countcxx . . $ MOJOSHADER_glProgram#texbem_count.++; |
| 2070 | } // if |
| 2071 | } // for |
| 2072 | } // if |
| 2073 | |
| 2074 | #define MAKE_ARRAYcxx . . $ `mojoshader_opengl.c:2074:13`!(typ, gltyp, siz, count) \ |
| 2075 | if (count) { \ |
| 2076 | const size_t buflen = sizeof (gltyp) * siz * count; \ |
| 2077 | gltyp *ptr = (gltyp *) Malloc(buflen); \ |
| 2078 | if (ptr == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { \ |
| 2079 | return 0; \ |
| 2080 | } else if (shader_type == MOJOSHADER_TYPE_VERTEX) { \ |
| 2081 | program->vs_uniforms_##typ = ptr; \ |
| 2082 | program->vs_uniforms_##typ##_count = count; \ |
| 2083 | } else if (shader_type == MOJOSHADER_TYPE_PIXEL) { \ |
| 2084 | program->ps_uniforms_##typ = ptr; \ |
| 2085 | program->ps_uniforms_##typ##_count = count; \ |
| 2086 | } else { \ |
| 2087 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(0 && "unsupported shader type"); \ |
| 2088 | } \ |
| 2089 | memset(ptr, '\0', buflen); \ |
| 2090 | } |
| 2091 | |
| 2092 | MAKE_ARRAYcxx . . $ `mojoshader_opengl.c:2074:13`!(float4, GLfloat, 4, float4_count); |
| 2093 | MAKE_ARRAYcxx . . $ `mojoshader_opengl.c:2074:13`!(int4, GLint, 4, int4_count); |
| 2094 | MAKE_ARRAYcxx . . $ `mojoshader_opengl.c:2074:13`!(bool, GLint, 1, bool_count); |
| 2095 | |
| 2096 | #undef MAKE_ARRAYcxx . . $ `mojoshader_opengl.c:2074:13`! |
| 2097 | |
| 2098 | return 1; |
| 2099 | } // lookup_uniforms |
| 2100 | |
| 2101 | |
| 2102 | static void lookup_samplerscxx . . $ lookup_samplers(7b01e9e7564959a9).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program, |
| 2103 | MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *shader, int *bound) |
| 2104 | { |
| 2105 | const MOJOSHADER_parseDatacxx . . $ MOJOSHADER_parseData# *pd = shader->parseDatacxx . . $ MOJOSHADER_glShader#parseData.; |
| 2106 | const MOJOSHADER_samplercxx . . $ MOJOSHADER_sampler# *s = pd->samplerscxx . . $ MOJOSHADER_parseData#samplers.; |
| 2107 | int i; |
| 2108 | |
| 2109 | if ((pd->sampler_countcxx . . $ MOJOSHADER_parseData#sampler_count. == 0) || (!ctxcxx . . $ ctx.->profileMustPushSamplerscxx . . $ MOJOSHADER_glContext#profileMustPushSamplers.())) |
| 2110 | return; // nothing to do here, so don't bother binding, etc. |
| 2111 | |
| 2112 | // Link up the Samplers. These never change after link time, since they |
| 2113 | // are meant to be constant texture unit ids and not textures. |
| 2114 | |
| 2115 | if (!(*bound)) |
| 2116 | { |
| 2117 | ctxcxx . . $ ctx.->profileUseProgramcxx . . $ MOJOSHADER_glContext#profileUseProgram.(program); |
| 2118 | *bound = 1; |
| 2119 | } // if |
| 2120 | |
| 2121 | for (i = 0; i < pd->sampler_countcxx . . $ MOJOSHADER_parseData#sampler_count.; i++) |
| 2122 | { |
| 2123 | const GLintcxx . . $ GLint# loc = ctxcxx . . $ ctx.->profileGetSamplerLocationcxx . . $ MOJOSHADER_glContext#profileGetSamplerLocation.(program, shader, i); |
| 2124 | if (loc >= 0) // maybe the Sampler was optimized out? |
| 2125 | { |
| 2126 | #ifdef MOJOSHADER_XNA4_VERTEX_TEXTURES |
| 2127 | if (pd->shader_type == MOJOSHADER_TYPE_VERTEX) |
| 2128 | ctx->profilePushSampler(loc, s[i].index + ctx->vertex_sampler_offset); |
| 2129 | else |
| 2130 | #endif |
| 2131 | ctxcxx . . $ ctx.->profilePushSamplercxx . . $ MOJOSHADER_glContext#profilePushSampler.(loc, s[i].indexcxx . . $ MOJOSHADER_sampler#index.); |
| 2132 | } // if |
| 2133 | } // for |
| 2134 | } // lookup_samplers |
| 2135 | |
| 2136 | |
| 2137 | // Right now, this just decides if we have to toggle pointsize support later. |
| 2138 | static void lookup_outputscxx . . $ lookup_outputs(b9b2164fff995352).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program, |
| 2139 | MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *shader) |
| 2140 | { |
| 2141 | if (shader == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2142 | return; |
| 2143 | |
| 2144 | const MOJOSHADER_parseDatacxx . . $ MOJOSHADER_parseData# *pd = shader->parseDatacxx . . $ MOJOSHADER_glShader#parseData.; |
| 2145 | int i; |
| 2146 | |
| 2147 | for (i = 0; i < pd->output_countcxx . . $ MOJOSHADER_parseData#output_count.; i++) |
| 2148 | { |
| 2149 | if (pd->outputscxx . . $ MOJOSHADER_parseData#outputs.[i].usagecxx . . $ MOJOSHADER_attribute#usage. == MOJOSHADER_USAGE_POINTSIZEcxx . . $ MOJOSHADER_USAGE_POINTSIZE.) |
| 2150 | { |
| 2151 | program->uses_pointsizecxx . . $ MOJOSHADER_glProgram#uses_pointsize. = 1; |
| 2152 | break; |
| 2153 | } // if |
| 2154 | } // for |
| 2155 | } // lookup_outputs |
| 2156 | |
| 2157 | |
| 2158 | static int lookup_attributescxx . . $ lookup_attributes(c4836f995b94e1fe).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program) |
| 2159 | { |
| 2160 | int i; |
| 2161 | const MOJOSHADER_parseDatacxx . . $ MOJOSHADER_parseData# *pd = program->vertexcxx . . $ MOJOSHADER_glProgram#vertex.->parseDatacxx . . $ MOJOSHADER_glShader#parseData.; |
| 2162 | const MOJOSHADER_attributecxx . . $ MOJOSHADER_attribute# *a = pd->attributescxx . . $ MOJOSHADER_parseData#attributes.; |
| 2163 | |
| 2164 | for (i = 0; i < pd->attribute_countcxx . . $ MOJOSHADER_parseData#attribute_count.; i++) |
| 2165 | { |
| 2166 | const GLintcxx . . $ GLint# loc = ctxcxx . . $ ctx.->profileGetAttribLocationcxx . . $ MOJOSHADER_glContext#profileGetAttribLocation.(program, i); |
| 2167 | if (loc >= 0) // maybe the Attribute was optimized out? |
| 2168 | { |
| 2169 | AttributeMapcxx . . $ AttributeMap# *map = &program->attributescxx . . $ MOJOSHADER_glProgram#attributes.[program->attribute_countcxx . . $ MOJOSHADER_glProgram#attribute_count.]; |
| 2170 | map->attributecxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_1#attribute. = &a[i]; |
| 2171 | map->locationcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_1#location. = loc; |
| 2172 | program->vertex_attrib_loccxx . . $ MOJOSHADER_glProgram#vertex_attrib_loc.[map->attributecxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_1#attribute.->usagecxx . . $ MOJOSHADER_attribute#usage.][map->attributecxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_1#attribute.->indexcxx . . $ MOJOSHADER_attribute#index.] = loc; |
| 2173 | program->attribute_countcxx . . $ MOJOSHADER_glProgram#attribute_count.++; |
| 2174 | |
| 2175 | if (((size_t)loc) > STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->want_attr)) |
| 2176 | { |
| 2177 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(0 && "Static array is too small."); // laziness fail. |
| 2178 | return 0; |
| 2179 | } // if |
| 2180 | } // if |
| 2181 | } // for |
| 2182 | |
| 2183 | return 1; |
| 2184 | } // lookup_attributes |
| 2185 | |
| 2186 | |
| 2187 | // !!! FIXME: misnamed |
| 2188 | // build a list of indexes that need to be overwritten with constant values |
| 2189 | // when pushing a uniform array to the GL. |
| 2190 | static int build_constants_listscxx . . $ build_constants_lists(c4836f995b94e1fe).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program) |
| 2191 | { |
| 2192 | int i; |
| 2193 | const int count = program->uniform_countcxx . . $ MOJOSHADER_glProgram#uniform_count.; |
| 2194 | for (i = 0; i < count; i++) |
| 2195 | { |
| 2196 | UniformMapcxx . . $ UniformMap# *map = &program->uniformscxx . . $ MOJOSHADER_glProgram#uniforms.[i]; |
| 2197 | const MOJOSHADER_uniformcxx . . $ MOJOSHADER_uniform# *u = map->uniformcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_0#uniform.; |
| 2198 | const int size = u->array_countcxx . . $ MOJOSHADER_uniform#array_count.; |
| 2199 | |
| 2200 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(!u->constant); |
| 2201 | |
| 2202 | if (size == 0) |
| 2203 | continue; // nothing to see here. |
| 2204 | |
| 2205 | // only use arrays for 'c' registers. |
| 2206 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(u->type == MOJOSHADER_UNIFORM_FLOAT); |
| 2207 | |
| 2208 | // !!! FIXME: deal with this. |
| 2209 | } // for |
| 2210 | |
| 2211 | return 1; |
| 2212 | } // build_constants_lists |
| 2213 | |
| 2214 | |
| 2215 | MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *MOJOSHADER_glLinkProgramcxx . . $ MOJOSHADER_glLinkProgram(cadeb3b15fc44e60).(MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *vshader, |
| 2216 | MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *pshader) |
| 2217 | { |
| 2218 | int bound = 0; |
| 2219 | |
| 2220 | if ((vshader == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) && (pshader == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) |
| 2221 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 2222 | |
| 2223 | int numregs = 0; |
| 2224 | MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *retval = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 2225 | const GLuintcxx . . $ GLuint# program = ctxcxx . . $ ctx.->profileLinkProgramcxx . . $ MOJOSHADER_glContext#profileLinkProgram.(vshader, pshader); |
| 2226 | if (program == 0) |
| 2227 | goto link_program_fail; |
| 2228 | |
| 2229 | retval = (MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *) Malloccxx . . $ Malloc(bfcfa4d6b7f7ef64).(sizeof (MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram#)); |
| 2230 | if (retval == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2231 | goto link_program_fail; |
| 2232 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(retval, '\0', sizeof (MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram#)); |
| 2233 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(retval->vertex_attrib_loccxx . . $ MOJOSHADER_glProgram#vertex_attrib_loc., 0xFF, sizeof(retval->vertex_attrib_loccxx . . $ MOJOSHADER_glProgram#vertex_attrib_loc.)); |
| 2234 | |
| 2235 | numregs = 0; |
| 2236 | if (vshader != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) numregs += vshader->parseDatacxx . . $ MOJOSHADER_glShader#parseData.->uniform_countcxx . . $ MOJOSHADER_parseData#uniform_count.; |
| 2237 | if (pshader != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) numregs += pshader->parseDatacxx . . $ MOJOSHADER_glShader#parseData.->uniform_countcxx . . $ MOJOSHADER_parseData#uniform_count.; |
| 2238 | if (numregs > 0) |
| 2239 | { |
| 2240 | const size_t len = sizeof (UniformMapcxx . . $ UniformMap#) * numregs; |
| 2241 | retval->uniformscxx . . $ MOJOSHADER_glProgram#uniforms. = (UniformMapcxx . . $ UniformMap# *) Malloccxx . . $ Malloc(bfcfa4d6b7f7ef64).(len); |
| 2242 | if (retval->uniformscxx . . $ MOJOSHADER_glProgram#uniforms. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2243 | goto link_program_fail; |
| 2244 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(retval->uniformscxx . . $ MOJOSHADER_glProgram#uniforms., '\0', len); |
| 2245 | } // if |
| 2246 | |
| 2247 | retval->handlecxx . . $ MOJOSHADER_glProgram#handle. = program; |
| 2248 | retval->vertexcxx . . $ MOJOSHADER_glProgram#vertex. = vshader; |
| 2249 | retval->fragmentcxx . . $ MOJOSHADER_glProgram#fragment. = pshader; |
| 2250 | retval->generationcxx . . $ MOJOSHADER_glProgram#generation. = ctxcxx . . $ ctx.->generationcxx . . $ MOJOSHADER_glContext#generation. - 1; |
| 2251 | retval->refcountcxx . . $ MOJOSHADER_glProgram#refcount. = 1; |
| 2252 | |
| 2253 | if (vshader != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2254 | { |
| 2255 | if (vshader->parseDatacxx . . $ MOJOSHADER_glShader#parseData.->attribute_countcxx . . $ MOJOSHADER_parseData#attribute_count. > 0) |
| 2256 | { |
| 2257 | const int count = vshader->parseDatacxx . . $ MOJOSHADER_glShader#parseData.->attribute_countcxx . . $ MOJOSHADER_parseData#attribute_count.; |
| 2258 | const size_t len = sizeof (AttributeMapcxx . . $ AttributeMap#) * count; |
| 2259 | retval->attributescxx . . $ MOJOSHADER_glProgram#attributes. = (AttributeMapcxx . . $ AttributeMap# *) Malloccxx . . $ Malloc(bfcfa4d6b7f7ef64).(len); |
| 2260 | if (retval->attributescxx . . $ MOJOSHADER_glProgram#attributes. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2261 | goto link_program_fail; |
| 2262 | |
| 2263 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(retval->attributescxx . . $ MOJOSHADER_glProgram#attributes., '\0', len); |
| 2264 | if (!lookup_attributescxx . . $ lookup_attributes(c4836f995b94e1fe).(retval)) |
| 2265 | goto link_program_fail; |
| 2266 | } // if |
| 2267 | |
| 2268 | if (!lookup_uniformscxx . . $ lookup_uniforms(dd0f2c3b2898b958).(retval, vshader, &bound)) |
| 2269 | goto link_program_fail; |
| 2270 | lookup_samplerscxx . . $ lookup_samplers(7b01e9e7564959a9).(retval, vshader, &bound); |
| 2271 | lookup_outputscxx . . $ lookup_outputs(b9b2164fff995352).(retval, vshader); |
| 2272 | vshader->refcountcxx . . $ MOJOSHADER_glShader#refcount.++; |
| 2273 | } // if |
| 2274 | |
| 2275 | if (pshader != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2276 | { |
| 2277 | if (!lookup_uniformscxx . . $ lookup_uniforms(dd0f2c3b2898b958).(retval, pshader, &bound)) |
| 2278 | goto link_program_fail; |
| 2279 | lookup_samplerscxx . . $ lookup_samplers(7b01e9e7564959a9).(retval, pshader, &bound); |
| 2280 | lookup_outputscxx . . $ lookup_outputs(b9b2164fff995352).(retval, pshader); |
| 2281 | pshader->refcountcxx . . $ MOJOSHADER_glShader#refcount.++; |
| 2282 | } // if |
| 2283 | |
| 2284 | if (!build_constants_listscxx . . $ build_constants_lists(c4836f995b94e1fe).(retval)) |
| 2285 | goto link_program_fail; |
| 2286 | |
| 2287 | if (bound) // reset the old binding. |
| 2288 | ctxcxx . . $ ctx.->profileUseProgramcxx . . $ MOJOSHADER_glContext#profileUseProgram.(ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program.); |
| 2289 | |
| 2290 | ctxcxx . . $ ctx.->profileFinalInitProgramcxx . . $ MOJOSHADER_glContext#profileFinalInitProgram.(retval); |
| 2291 | |
| 2292 | return retval; |
| 2293 | |
| 2294 | link_program_fail: |
| 2295 | if (retval != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2296 | { |
| 2297 | Freecxx . . $ Free(5d22bdacc48458e8).(retval->vs_uniforms_float4cxx . . $ MOJOSHADER_glProgram#vs_uniforms_float4.); |
| 2298 | Freecxx . . $ Free(5d22bdacc48458e8).(retval->vs_uniforms_int4cxx . . $ MOJOSHADER_glProgram#vs_uniforms_int4.); |
| 2299 | Freecxx . . $ Free(5d22bdacc48458e8).(retval->vs_uniforms_boolcxx . . $ MOJOSHADER_glProgram#vs_uniforms_bool.); |
| 2300 | Freecxx . . $ Free(5d22bdacc48458e8).(retval->ps_uniforms_float4cxx . . $ MOJOSHADER_glProgram#ps_uniforms_float4.); |
| 2301 | Freecxx . . $ Free(5d22bdacc48458e8).(retval->ps_uniforms_int4cxx . . $ MOJOSHADER_glProgram#ps_uniforms_int4.); |
| 2302 | Freecxx . . $ Free(5d22bdacc48458e8).(retval->ps_uniforms_boolcxx . . $ MOJOSHADER_glProgram#ps_uniforms_bool.); |
| 2303 | Freecxx . . $ Free(5d22bdacc48458e8).(retval->uniformscxx . . $ MOJOSHADER_glProgram#uniforms.); |
| 2304 | Freecxx . . $ Free(5d22bdacc48458e8).(retval->attributescxx . . $ MOJOSHADER_glProgram#attributes.); |
| 2305 | Freecxx . . $ Free(5d22bdacc48458e8).(retval); |
| 2306 | } // if |
| 2307 | |
| 2308 | if (program != 0) |
| 2309 | ctxcxx . . $ ctx.->profileDeleteProgramcxx . . $ MOJOSHADER_glContext#profileDeleteProgram.(program); |
| 2310 | |
| 2311 | if (bound) |
| 2312 | ctxcxx . . $ ctx.->profileUseProgramcxx . . $ MOJOSHADER_glContext#profileUseProgram.(ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program.); |
| 2313 | |
| 2314 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 2315 | } // MOJOSHADER_glLinkProgram |
| 2316 | |
| 2317 | |
| 2318 | static void update_enabled_arrayscxx . . $ update_enabled_arrays(49f6e7a06ebc5aa8).(void) |
| 2319 | { |
| 2320 | int highest_enabled = 0; |
| 2321 | int i; |
| 2322 | |
| 2323 | // Enable/disable vertex arrays to match our needs. |
| 2324 | // this happens to work in both ARB1 and GLSL, but if something alien |
| 2325 | // shows up, we'll have to split these into profile*() functions. |
| 2326 | for (i = 0; i < ctxcxx . . $ ctx.->max_attrscxx . . $ MOJOSHADER_glContext#max_attrs.; i++) |
| 2327 | { |
| 2328 | const int want = (const int) ctxcxx . . $ ctx.->want_attrcxx . . $ MOJOSHADER_glContext#want_attr.[i]; |
| 2329 | const int have = (const int) ctxcxx . . $ ctx.->have_attrcxx . . $ MOJOSHADER_glContext#have_attr.[i]; |
| 2330 | if (want != have) |
| 2331 | { |
| 2332 | if (want) |
| 2333 | ctxcxx . . $ ctx.->glEnableVertexAttribArraycxx . . $ MOJOSHADER_glContext#glEnableVertexAttribArray.(i); |
| 2334 | else |
| 2335 | ctxcxx . . $ ctx.->glDisableVertexAttribArraycxx . . $ MOJOSHADER_glContext#glDisableVertexAttribArray.(i); |
| 2336 | ctxcxx . . $ ctx.->have_attrcxx . . $ MOJOSHADER_glContext#have_attr.[i] = want; |
| 2337 | } // if |
| 2338 | |
| 2339 | if (want) |
| 2340 | highest_enabled = i + 1; |
| 2341 | } // for |
| 2342 | |
| 2343 | ctxcxx . . $ ctx.->max_attrscxx . . $ MOJOSHADER_glContext#max_attrs. = highest_enabled; // trim unneeded iterations next time. |
| 2344 | } // update_enabled_arrays |
| 2345 | |
| 2346 | |
| 2347 | void MOJOSHADER_glBindProgramcxx . . $ MOJOSHADER_glBindProgram(b6cc5ff6e33eca9d).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program) |
| 2348 | { |
| 2349 | if (program == ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program.) |
| 2350 | return; // nothing to do. |
| 2351 | |
| 2352 | if (program != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2353 | program->refcountcxx . . $ MOJOSHADER_glProgram#refcount.++; |
| 2354 | |
| 2355 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(ctxcxx . . $ ctx.->want_attrcxx . . $ MOJOSHADER_glContext#want_attr., '\0', sizeof (ctxcxx . . $ ctx.->want_attrcxx . . $ MOJOSHADER_glContext#want_attr.[0]) * ctxcxx . . $ ctx.->max_attrscxx . . $ MOJOSHADER_glContext#max_attrs.); |
| 2356 | |
| 2357 | // If no program bound, disable all arrays, in case we're switching to |
| 2358 | // fixed function pipeline. Otherwise, we try to minimize state changes |
| 2359 | // by toggling just the changed set of needed arrays in ProgramReady(). |
| 2360 | if (program == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2361 | update_enabled_arrayscxx . . $ update_enabled_arrays(49f6e7a06ebc5aa8).(); |
| 2362 | |
| 2363 | ctxcxx . . $ ctx.->profileUseProgramcxx . . $ MOJOSHADER_glContext#profileUseProgram.(program); |
| 2364 | program_unrefcxx . . $ program_unref(b6cc5ff6e33eca9d).(ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program.); |
| 2365 | ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program. = program; |
| 2366 | } // MOJOSHADER_glBindProgram |
| 2367 | |
| 2368 | |
| 2369 | typedef structcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_2# |
| 2370 | { |
| 2371 | MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *vertexcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_2#vertex.; |
| 2372 | MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *fragmentcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_2#fragment.; |
| 2373 | } BoundShaderscxx . . $ BoundShaders#; |
| 2374 | |
| 2375 | static uint32cxx . . $ uint32# hash_shaderscxx . . $ hash_shaders(3be275e70c14adf4).(const void *sym, void *data) |
| 2376 | { |
| 2377 | (void) data; |
| 2378 | const BoundShaderscxx . . $ BoundShaders# *s = (const BoundShaderscxx . . $ BoundShaders# *) sym; |
| 2379 | const uint32cxx . . $ uint32# v = (s->vertexcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_2#vertex.) ? (uint32cxx . . $ uint32#) s->vertexcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_2#vertex.->handlecxx . . $ MOJOSHADER_glShader#handle. : 0; |
| 2380 | const uint32cxx . . $ uint32# f = (s->fragmentcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_2#fragment.) ? (uint32cxx . . $ uint32#) s->fragmentcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_2#fragment.->handlecxx . . $ MOJOSHADER_glShader#handle. : 0; |
| 2381 | return ((v & 0xFFFF) << 16) | (f & 0xFFFF); |
| 2382 | } // hash_shaders |
| 2383 | |
| 2384 | static int match_shaderscxx . . $ match_shaders(b8f62d2ccbc12f7d).(const void *_a, const void *_b, void *data) |
| 2385 | { |
| 2386 | (void) data; |
| 2387 | const BoundShaderscxx . . $ BoundShaders# *a = (const BoundShaderscxx . . $ BoundShaders# *) _a; |
| 2388 | const BoundShaderscxx . . $ BoundShaders# *b = (const BoundShaderscxx . . $ BoundShaders# *) _b; |
| 2389 | |
| 2390 | const GLuintcxx . . $ GLuint# av = (a->vertexcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_2#vertex.) ? a->vertexcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_2#vertex.->handlecxx . . $ MOJOSHADER_glShader#handle. : 0; |
| 2391 | const GLuintcxx . . $ GLuint# bv = (b->vertexcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_2#vertex.) ? b->vertexcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_2#vertex.->handlecxx . . $ MOJOSHADER_glShader#handle. : 0; |
| 2392 | if (av != bv) |
| 2393 | return 0; |
| 2394 | |
| 2395 | const GLuintcxx . . $ GLuint# af = (a->fragmentcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_2#fragment.) ? a->fragmentcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_2#fragment.->handlecxx . . $ MOJOSHADER_glShader#handle. : 0; |
| 2396 | const GLuintcxx . . $ GLuint# bf = (b->fragmentcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_2#fragment.) ? b->fragmentcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_2#fragment.->handlecxx . . $ MOJOSHADER_glShader#handle. : 0; |
| 2397 | if (af != bf) |
| 2398 | return 0; |
| 2399 | |
| 2400 | return 1; |
| 2401 | } // match_shaders |
| 2402 | |
| 2403 | static void nuke_shaderscxx . . $ nuke_shaders(12471b72f5b802e8).(const void *_ctx, const void *key, const void *value, void *data) |
| 2404 | { |
| 2405 | (void) _ctx; |
| 2406 | (void) data; |
| 2407 | Freecxx . . $ Free(5d22bdacc48458e8).((void *) key); // this was a BoundShaders struct. |
| 2408 | MOJOSHADER_glDeleteProgramcxx . . $ MOJOSHADER_glDeleteProgram(b6cc5ff6e33eca9d).((MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *) value); |
| 2409 | } // nuke_shaders |
| 2410 | |
| 2411 | void MOJOSHADER_glBindShaderscxx . . $ MOJOSHADER_glBindShaders(63618d261cfc072a).(MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *v, MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *p) |
| 2412 | { |
| 2413 | if ((v == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) && (p == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) |
| 2414 | { |
| 2415 | MOJOSHADER_glBindProgramcxx . . $ MOJOSHADER_glBindProgram(b6cc5ff6e33eca9d).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 2416 | return; |
| 2417 | } // if |
| 2418 | |
| 2419 | // !!! FIXME: eventually support GL_EXT_separate_shader_objects. |
| 2420 | if (ctxcxx . . $ ctx.->linker_cachecxx . . $ MOJOSHADER_glContext#linker_cache. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2421 | { |
| 2422 | ctxcxx . . $ ctx.->linker_cachecxx . . $ MOJOSHADER_glContext#linker_cache. = hash_createcxx . . $ hash_create(8335872bcb6e2f75).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, hash_shaderscxx . . $ hash_shaders(3be275e70c14adf4)., match_shaderscxx . . $ match_shaders(b8f62d2ccbc12f7d)., |
| 2423 | nuke_shaderscxx . . $ nuke_shaders(12471b72f5b802e8)., 0, ctxcxx . . $ ctx.->malloc_fncxx . . $ MOJOSHADER_glContext#malloc_fn., |
| 2424 | ctxcxx . . $ ctx.->free_fncxx . . $ MOJOSHADER_glContext#free_fn., ctxcxx . . $ ctx.->malloc_datacxx . . $ MOJOSHADER_glContext#malloc_data.); |
| 2425 | |
| 2426 | if (ctxcxx . . $ ctx.->linker_cachecxx . . $ MOJOSHADER_glContext#linker_cache. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2427 | { |
| 2428 | out_of_memorycxx . . $ out_of_memory(49f6e7a06ebc5aa8).(); |
| 2429 | return; |
| 2430 | } // if |
| 2431 | } // if |
| 2432 | |
| 2433 | MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 2434 | BoundShaderscxx . . $ BoundShaders# shaders; |
| 2435 | shaders.vertexcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_2#vertex. = v; |
| 2436 | shaders.fragmentcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_2#fragment. = p; |
| 2437 | |
| 2438 | const void *val = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 2439 | if (hash_findcxx . . $ hash_find(7ef6c75da24368fe).(ctxcxx . . $ ctx.->linker_cachecxx . . $ MOJOSHADER_glContext#linker_cache., &shaders, &val)) |
| 2440 | program = (MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *) val; |
| 2441 | else |
| 2442 | { |
| 2443 | program = MOJOSHADER_glLinkProgramcxx . . $ MOJOSHADER_glLinkProgram(cadeb3b15fc44e60).(v, p); |
| 2444 | if (program == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2445 | return; |
| 2446 | |
| 2447 | BoundShaderscxx . . $ BoundShaders# *item = (BoundShaderscxx . . $ BoundShaders# *) Malloccxx . . $ Malloc(bfcfa4d6b7f7ef64).(sizeof (BoundShaderscxx . . $ BoundShaders#)); |
| 2448 | if (item == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2449 | { |
| 2450 | MOJOSHADER_glDeleteProgramcxx . . $ MOJOSHADER_glDeleteProgram(b6cc5ff6e33eca9d).(program); |
| 2451 | return; |
| 2452 | } // if |
| 2453 | |
| 2454 | memcpycxx . . $ memcpy(cc817cb175f282d).(item, &shaders, sizeof (BoundShaderscxx . . $ BoundShaders#)); |
| 2455 | if (hash_insertcxx . . $ hash_insert(1d30a91d107a3de).(ctxcxx . . $ ctx.->linker_cachecxx . . $ MOJOSHADER_glContext#linker_cache., item, program) != 1) |
| 2456 | { |
| 2457 | Freecxx . . $ Free(5d22bdacc48458e8).(item); |
| 2458 | MOJOSHADER_glDeleteProgramcxx . . $ MOJOSHADER_glDeleteProgram(b6cc5ff6e33eca9d).(program); |
| 2459 | out_of_memorycxx . . $ out_of_memory(49f6e7a06ebc5aa8).(); |
| 2460 | return; |
| 2461 | } // if |
| 2462 | } // else |
| 2463 | |
| 2464 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(program != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 2465 | MOJOSHADER_glBindProgramcxx . . $ MOJOSHADER_glBindProgram(b6cc5ff6e33eca9d).(program); |
| 2466 | } // MOJOSHADER_glBindShaders |
| 2467 | |
| 2468 | |
| 2469 | void MOJOSHADER_glGetBoundShaderscxx . . $ MOJOSHADER_glGetBoundShaders(b68bb660a2720edd).(MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# **v, |
| 2470 | MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# **p) |
| 2471 | { |
| 2472 | if (v != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2473 | { |
| 2474 | if (ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2475 | *v = ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program.->vertexcxx . . $ MOJOSHADER_glProgram#vertex.; |
| 2476 | else |
| 2477 | *v = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 2478 | } // if |
| 2479 | if (p != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2480 | { |
| 2481 | if (ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2482 | *p = ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program.->fragmentcxx . . $ MOJOSHADER_glProgram#fragment.; |
| 2483 | else |
| 2484 | *p = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 2485 | } // if |
| 2486 | } // MOJOSHADER_glGetBoundShaders |
| 2487 | |
| 2488 | |
| 2489 | static inline uintcxx . . $ uint# minuintcxx . . $ minuint(83f10ac8959d5577).(const uintcxx . . $ uint# a, const uintcxx . . $ uint# b) |
| 2490 | { |
| 2491 | return ((a < b) ? a : b); |
| 2492 | } // minuint |
| 2493 | |
| 2494 | |
| 2495 | void MOJOSHADER_glSetVertexShaderUniformFcxx . . $ MOJOSHADER_glSetVertexShaderUniformF(ab18346244e02b37).(unsigned int idx, const float *data, |
| 2496 | unsigned int vec4n) |
| 2497 | { |
| 2498 | const uintcxx . . $ uint# maxregs = STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->vs_reg_file_f) / 4; |
| 2499 | if (idx < maxregs) |
| 2500 | { |
| 2501 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(sizeof (GLfloat) == sizeof (float)); |
| 2502 | const uintcxx . . $ uint# cpy = (minuintcxx . . $ minuint(83f10ac8959d5577).(maxregs - idx, vec4n) * sizeof (*data)) * 4; |
| 2503 | memcpycxx . . $ memcpy(cc817cb175f282d).(ctxcxx . . $ ctx.->vs_reg_file_fcxx . . $ MOJOSHADER_glContext#vs_reg_file_f. + (idx * 4), data, cpy); |
| 2504 | ctxcxx . . $ ctx.->generationcxx . . $ MOJOSHADER_glContext#generation.++; |
| 2505 | } // if |
| 2506 | } // MOJOSHADER_glSetVertexShaderUniformF |
| 2507 | |
| 2508 | |
| 2509 | void MOJOSHADER_glGetVertexShaderUniformFcxx . . $ MOJOSHADER_glGetVertexShaderUniformF(2a42829f5589e07f).(unsigned int idx, float *data, |
| 2510 | unsigned int vec4n) |
| 2511 | { |
| 2512 | const uintcxx . . $ uint# maxregs = STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->vs_reg_file_f) / 4; |
| 2513 | if (idx < maxregs) |
| 2514 | { |
| 2515 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(sizeof (GLfloat) == sizeof (float)); |
| 2516 | const uintcxx . . $ uint# cpy = (minuintcxx . . $ minuint(83f10ac8959d5577).(maxregs - idx, vec4n) * sizeof (*data)) * 4; |
| 2517 | memcpycxx . . $ memcpy(cc817cb175f282d).(data, ctxcxx . . $ ctx.->vs_reg_file_fcxx . . $ MOJOSHADER_glContext#vs_reg_file_f. + (idx * 4), cpy); |
| 2518 | } // if |
| 2519 | } // MOJOSHADER_glGetVertexShaderUniformF |
| 2520 | |
| 2521 | |
| 2522 | void MOJOSHADER_glSetVertexShaderUniformIcxx . . $ MOJOSHADER_glSetVertexShaderUniformI(888c01118f5b337b).(unsigned int idx, const int *data, |
| 2523 | unsigned int ivec4n) |
| 2524 | { |
| 2525 | const uintcxx . . $ uint# maxregs = STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->vs_reg_file_i) / 4; |
| 2526 | if (idx < maxregs) |
| 2527 | { |
| 2528 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(sizeof (GLint) == sizeof (int)); |
| 2529 | const uintcxx . . $ uint# cpy = (minuintcxx . . $ minuint(83f10ac8959d5577).(maxregs - idx, ivec4n) * sizeof (*data)) * 4; |
| 2530 | memcpycxx . . $ memcpy(cc817cb175f282d).(ctxcxx . . $ ctx.->vs_reg_file_icxx . . $ MOJOSHADER_glContext#vs_reg_file_i. + (idx * 4), data, cpy); |
| 2531 | ctxcxx . . $ ctx.->generationcxx . . $ MOJOSHADER_glContext#generation.++; |
| 2532 | } // if |
| 2533 | } // MOJOSHADER_glSetVertexShaderUniformI |
| 2534 | |
| 2535 | |
| 2536 | void MOJOSHADER_glGetVertexShaderUniformIcxx . . $ MOJOSHADER_glGetVertexShaderUniformI(cc39dc86876ea3dd).(unsigned int idx, int *data, |
| 2537 | unsigned int ivec4n) |
| 2538 | { |
| 2539 | const uintcxx . . $ uint# maxregs = STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->vs_reg_file_i) / 4; |
| 2540 | if (idx < maxregs) |
| 2541 | { |
| 2542 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(sizeof (GLint) == sizeof (int)); |
| 2543 | const uintcxx . . $ uint# cpy = (minuintcxx . . $ minuint(83f10ac8959d5577).(maxregs - idx, ivec4n) * sizeof (*data)) * 4; |
| 2544 | memcpycxx . . $ memcpy(cc817cb175f282d).(data, ctxcxx . . $ ctx.->vs_reg_file_icxx . . $ MOJOSHADER_glContext#vs_reg_file_i. + (idx * 4), cpy); |
| 2545 | } // if |
| 2546 | } // MOJOSHADER_glGetVertexShaderUniformI |
| 2547 | |
| 2548 | |
| 2549 | void MOJOSHADER_glSetVertexShaderUniformBcxx . . $ MOJOSHADER_glSetVertexShaderUniformB(888c01118f5b337b).(unsigned int idx, const int *data, |
| 2550 | unsigned int bcount) |
| 2551 | { |
| 2552 | const uintcxx . . $ uint# maxregs = STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->vs_reg_file_b) / 4; |
| 2553 | if (idx < maxregs) |
| 2554 | { |
| 2555 | uint8cxx . . $ uint8# *wptr = ctxcxx . . $ ctx.->vs_reg_file_bcxx . . $ MOJOSHADER_glContext#vs_reg_file_b. + idx; |
| 2556 | uint8cxx . . $ uint8# *endptr = wptr + minuintcxx . . $ minuint(83f10ac8959d5577).(maxregs - idx, bcount); |
| 2557 | while (wptr != endptr) |
| 2558 | *(wptr++) = *(data++) ? 1 : 0; |
| 2559 | ctxcxx . . $ ctx.->generationcxx . . $ MOJOSHADER_glContext#generation.++; |
| 2560 | } // if |
| 2561 | } // MOJOSHADER_glSetVertexShaderUniformB |
| 2562 | |
| 2563 | |
| 2564 | void MOJOSHADER_glGetVertexShaderUniformBcxx . . $ MOJOSHADER_glGetVertexShaderUniformB(cc39dc86876ea3dd).(unsigned int idx, int *data, |
| 2565 | unsigned int bcount) |
| 2566 | { |
| 2567 | const uintcxx . . $ uint# maxregs = STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->vs_reg_file_b) / 4; |
| 2568 | if (idx < maxregs) |
| 2569 | { |
| 2570 | uint8cxx . . $ uint8# *rptr = ctxcxx . . $ ctx.->vs_reg_file_bcxx . . $ MOJOSHADER_glContext#vs_reg_file_b. + idx; |
| 2571 | uint8cxx . . $ uint8# *endptr = rptr + minuintcxx . . $ minuint(83f10ac8959d5577).(maxregs - idx, bcount); |
| 2572 | while (rptr != endptr) |
| 2573 | *(data++) = (int) *(rptr++); |
| 2574 | } // if |
| 2575 | } // MOJOSHADER_glGetVertexShaderUniformB |
| 2576 | |
| 2577 | |
| 2578 | void MOJOSHADER_glSetPixelShaderUniformFcxx . . $ MOJOSHADER_glSetPixelShaderUniformF(ab18346244e02b37).(unsigned int idx, const float *data, |
| 2579 | unsigned int vec4n) |
| 2580 | { |
| 2581 | const uintcxx . . $ uint# maxregs = STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->ps_reg_file_f) / 4; |
| 2582 | if (idx < maxregs) |
| 2583 | { |
| 2584 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(sizeof (GLfloat) == sizeof (float)); |
| 2585 | const uintcxx . . $ uint# cpy = (minuintcxx . . $ minuint(83f10ac8959d5577).(maxregs - idx, vec4n) * sizeof (*data)) * 4; |
| 2586 | memcpycxx . . $ memcpy(cc817cb175f282d).(ctxcxx . . $ ctx.->ps_reg_file_fcxx . . $ MOJOSHADER_glContext#ps_reg_file_f. + (idx * 4), data, cpy); |
| 2587 | ctxcxx . . $ ctx.->generationcxx . . $ MOJOSHADER_glContext#generation.++; |
| 2588 | } // if |
| 2589 | } // MOJOSHADER_glSetPixelShaderUniformF |
| 2590 | |
| 2591 | |
| 2592 | void MOJOSHADER_glGetPixelShaderUniformFcxx . . $ MOJOSHADER_glGetPixelShaderUniformF(2a42829f5589e07f).(unsigned int idx, float *data, |
| 2593 | unsigned int vec4n) |
| 2594 | { |
| 2595 | const uintcxx . . $ uint# maxregs = STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->ps_reg_file_f) / 4; |
| 2596 | if (idx < maxregs) |
| 2597 | { |
| 2598 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(sizeof (GLfloat) == sizeof (float)); |
| 2599 | const uintcxx . . $ uint# cpy = (minuintcxx . . $ minuint(83f10ac8959d5577).(maxregs - idx, vec4n) * sizeof (*data)) * 4; |
| 2600 | memcpycxx . . $ memcpy(cc817cb175f282d).(data, ctxcxx . . $ ctx.->ps_reg_file_fcxx . . $ MOJOSHADER_glContext#ps_reg_file_f. + (idx * 4), cpy); |
| 2601 | } // if |
| 2602 | } // MOJOSHADER_glGetPixelShaderUniformF |
| 2603 | |
| 2604 | |
| 2605 | void MOJOSHADER_glSetPixelShaderUniformIcxx . . $ MOJOSHADER_glSetPixelShaderUniformI(888c01118f5b337b).(unsigned int idx, const int *data, |
| 2606 | unsigned int ivec4n) |
| 2607 | { |
| 2608 | const uintcxx . . $ uint# maxregs = STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->ps_reg_file_i) / 4; |
| 2609 | if (idx < maxregs) |
| 2610 | { |
| 2611 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(sizeof (GLint) == sizeof (int)); |
| 2612 | const uintcxx . . $ uint# cpy = (minuintcxx . . $ minuint(83f10ac8959d5577).(maxregs - idx, ivec4n) * sizeof (*data)) * 4; |
| 2613 | memcpycxx . . $ memcpy(cc817cb175f282d).(ctxcxx . . $ ctx.->ps_reg_file_icxx . . $ MOJOSHADER_glContext#ps_reg_file_i. + (idx * 4), data, cpy); |
| 2614 | ctxcxx . . $ ctx.->generationcxx . . $ MOJOSHADER_glContext#generation.++; |
| 2615 | } // if |
| 2616 | } // MOJOSHADER_glSetPixelShaderUniformI |
| 2617 | |
| 2618 | |
| 2619 | void MOJOSHADER_glGetPixelShaderUniformIcxx . . $ MOJOSHADER_glGetPixelShaderUniformI(cc39dc86876ea3dd).(unsigned int idx, int *data, |
| 2620 | unsigned int ivec4n) |
| 2621 | { |
| 2622 | const uintcxx . . $ uint# maxregs = STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->ps_reg_file_i) / 4; |
| 2623 | if (idx < maxregs) |
| 2624 | { |
| 2625 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(sizeof (GLint) == sizeof (int)); |
| 2626 | const uintcxx . . $ uint# cpy = (minuintcxx . . $ minuint(83f10ac8959d5577).(maxregs - idx, ivec4n) * sizeof (*data)) * 4; |
| 2627 | memcpycxx . . $ memcpy(cc817cb175f282d).(data, ctxcxx . . $ ctx.->ps_reg_file_icxx . . $ MOJOSHADER_glContext#ps_reg_file_i. + (idx * 4), cpy); |
| 2628 | } // if |
| 2629 | } // MOJOSHADER_glGetPixelShaderUniformI |
| 2630 | |
| 2631 | |
| 2632 | void MOJOSHADER_glSetPixelShaderUniformBcxx . . $ MOJOSHADER_glSetPixelShaderUniformB(888c01118f5b337b).(unsigned int idx, const int *data, |
| 2633 | unsigned int bcount) |
| 2634 | { |
| 2635 | const uintcxx . . $ uint# maxregs = STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->ps_reg_file_b) / 4; |
| 2636 | if (idx < maxregs) |
| 2637 | { |
| 2638 | uint8cxx . . $ uint8# *wptr = ctxcxx . . $ ctx.->ps_reg_file_bcxx . . $ MOJOSHADER_glContext#ps_reg_file_b. + idx; |
| 2639 | uint8cxx . . $ uint8# *endptr = wptr + minuintcxx . . $ minuint(83f10ac8959d5577).(maxregs - idx, bcount); |
| 2640 | while (wptr != endptr) |
| 2641 | *(wptr++) = *(data++) ? 1 : 0; |
| 2642 | ctxcxx . . $ ctx.->generationcxx . . $ MOJOSHADER_glContext#generation.++; |
| 2643 | } // if |
| 2644 | } // MOJOSHADER_glSetPixelShaderUniformB |
| 2645 | |
| 2646 | |
| 2647 | void MOJOSHADER_glGetPixelShaderUniformBcxx . . $ MOJOSHADER_glGetPixelShaderUniformB(cc39dc86876ea3dd).(unsigned int idx, int *data, |
| 2648 | unsigned int bcount) |
| 2649 | { |
| 2650 | const uintcxx . . $ uint# maxregs = STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->ps_reg_file_b) / 4; |
| 2651 | if (idx < maxregs) |
| 2652 | { |
| 2653 | uint8cxx . . $ uint8# *rptr = ctxcxx . . $ ctx.->ps_reg_file_bcxx . . $ MOJOSHADER_glContext#ps_reg_file_b. + idx; |
| 2654 | uint8cxx . . $ uint8# *endptr = rptr + minuintcxx . . $ minuint(83f10ac8959d5577).(maxregs - idx, bcount); |
| 2655 | while (rptr != endptr) |
| 2656 | *(data++) = (int) *(rptr++); |
| 2657 | } // if |
| 2658 | } // MOJOSHADER_glGetPixelShaderUniformB |
| 2659 | |
| 2660 | |
| 2661 | void MOJOSHADER_glMapUniformBufferMemorycxx . . $ MOJOSHADER_glMapUniformBufferMemory(6e9d59e50a3cee90).(float **vsf, int **vsi, unsigned char **vsb, |
| 2662 | float **psf, int **psi, unsigned char **psb) |
| 2663 | { |
| 2664 | *vsf = ctxcxx . . $ ctx.->vs_reg_file_fcxx . . $ MOJOSHADER_glContext#vs_reg_file_f.; |
| 2665 | *vsi = ctxcxx . . $ ctx.->vs_reg_file_icxx . . $ MOJOSHADER_glContext#vs_reg_file_i.; |
| 2666 | *vsb = ctxcxx . . $ ctx.->vs_reg_file_bcxx . . $ MOJOSHADER_glContext#vs_reg_file_b.; |
| 2667 | *psf = ctxcxx . . $ ctx.->ps_reg_file_fcxx . . $ MOJOSHADER_glContext#ps_reg_file_f.; |
| 2668 | *psi = ctxcxx . . $ ctx.->ps_reg_file_icxx . . $ MOJOSHADER_glContext#ps_reg_file_i.; |
| 2669 | *psb = ctxcxx . . $ ctx.->ps_reg_file_bcxx . . $ MOJOSHADER_glContext#ps_reg_file_b.; |
| 2670 | } // MOJOSHADER_glMapUniformBufferMemory |
| 2671 | |
| 2672 | |
| 2673 | void MOJOSHADER_glUnmapUniformBufferMemorycxx . . $ MOJOSHADER_glUnmapUniformBufferMemory(d878ad36e69247c7).() |
| 2674 | { |
| 2675 | ctxcxx . . $ ctx.->generationcxx . . $ MOJOSHADER_glContext#generation.++; |
| 2676 | } // MOJOSHADER_glUnmapUniformBufferMemory |
| 2677 | |
| 2678 | |
| 2679 | static inline GLenumcxx . . $ GLenum# opengl_attr_typecxx . . $ opengl_attr_type(1c39e30d59415a4b).(const MOJOSHADER_attributeTypecxx . . $ MOJOSHADER_attributeType# type) |
| 2680 | { |
| 2681 | switch (type) |
| 2682 | { |
| 2683 | case MOJOSHADER_ATTRIBUTE_UNKNOWNcxx . . $ MOJOSHADER_ATTRIBUTE_UNKNOWN.: return GL_NONEcxx . . $ `<external>/11565930711847777359/gl.h:431:9`!; // oh well. |
| 2684 | case MOJOSHADER_ATTRIBUTE_BYTEcxx . . $ MOJOSHADER_ATTRIBUTE_BYTE.: return GL_BYTEcxx . . $ `<external>/11565930711847777359/gl.h:143:9`!; |
| 2685 | case MOJOSHADER_ATTRIBUTE_UBYTEcxx . . $ MOJOSHADER_ATTRIBUTE_UBYTE.: return GL_UNSIGNED_BYTEcxx . . $ `<external>/11565930711847777359/gl.h:144:9`!; |
| 2686 | case MOJOSHADER_ATTRIBUTE_SHORTcxx . . $ MOJOSHADER_ATTRIBUTE_SHORT.: return GL_SHORTcxx . . $ `<external>/11565930711847777359/gl.h:145:9`!; |
| 2687 | case MOJOSHADER_ATTRIBUTE_USHORTcxx . . $ MOJOSHADER_ATTRIBUTE_USHORT.: return GL_UNSIGNED_SHORTcxx . . $ `<external>/11565930711847777359/gl.h:146:9`!; |
| 2688 | case MOJOSHADER_ATTRIBUTE_INTcxx . . $ MOJOSHADER_ATTRIBUTE_INT.: return GL_INTcxx . . $ `<external>/11565930711847777359/gl.h:147:9`!; |
| 2689 | case MOJOSHADER_ATTRIBUTE_UINTcxx . . $ MOJOSHADER_ATTRIBUTE_UINT.: return GL_UNSIGNED_INTcxx . . $ `<external>/11565930711847777359/gl.h:148:9`!; |
| 2690 | case MOJOSHADER_ATTRIBUTE_FLOATcxx . . $ MOJOSHADER_ATTRIBUTE_FLOAT.: return GL_FLOATcxx . . $ `<external>/11565930711847777359/gl.h:149:9`!; |
| 2691 | case MOJOSHADER_ATTRIBUTE_DOUBLEcxx . . $ MOJOSHADER_ATTRIBUTE_DOUBLE.: return GL_DOUBLEcxx . . $ `<external>/11565930711847777359/gl.h:153:9`!; |
| 2692 | |
| 2693 | case MOJOSHADER_ATTRIBUTE_HALF_FLOATcxx . . $ MOJOSHADER_ATTRIBUTE_HALF_FLOAT.: |
| 2694 | if (ctxcxx . . $ ctx.->have_GL_NV_half_floatcxx . . $ MOJOSHADER_glContext#have_GL_NV_half_float.) |
| 2695 | return GL_HALF_FLOAT_NVcxx . . $ `GL/glext.h:4328:9`!; |
| 2696 | else if (ctxcxx . . $ ctx.->have_GL_ARB_half_float_vertexcxx . . $ MOJOSHADER_glContext#have_GL_ARB_half_float_vertex.) |
| 2697 | return GL_HALF_FLOAT_ARBcxx . . $ `GL/glext.h:1628:9`!; |
| 2698 | else if (ctxcxx . . $ ctx.->have_GL_OES_vertex_half_floatcxx . . $ MOJOSHADER_glContext#have_GL_OES_vertex_half_float.) |
| 2699 | return GL_HALF_FLOAT_OEScxx . . $ `mojoshader_opengl.c:46:9`!; |
| 2700 | break; |
| 2701 | } // switch |
| 2702 | |
| 2703 | return GL_NONEcxx . . $ `<external>/11565930711847777359/gl.h:431:9`!; // oh well. Raises a GL error later. |
| 2704 | } // opengl_attr_type |
| 2705 | |
| 2706 | |
| 2707 | int MOJOSHADER_glGetVertexAttribLocationcxx . . $ MOJOSHADER_glGetVertexAttribLocation(42d8cb8c798fe890).(MOJOSHADER_usagecxx . . $ MOJOSHADER_usage# usage, int index) |
| 2708 | { |
| 2709 | if ((ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program.->vertexcxx . . $ MOJOSHADER_glProgram#vertex. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) |
| 2710 | return -1; |
| 2711 | |
| 2712 | return ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program.->vertex_attrib_loccxx . . $ MOJOSHADER_glProgram#vertex_attrib_loc.[usage][index]; |
| 2713 | } // MOJOSHADER_glGetVertexAttribLocation |
| 2714 | |
| 2715 | |
| 2716 | // !!! FIXME: shouldn't (index) be unsigned? |
| 2717 | void MOJOSHADER_glSetVertexAttributecxx . . $ MOJOSHADER_glSetVertexAttribute(6df45b7f96483cdb).(MOJOSHADER_usagecxx . . $ MOJOSHADER_usage# usage, |
| 2718 | int index, unsigned int size, |
| 2719 | MOJOSHADER_attributeTypecxx . . $ MOJOSHADER_attributeType# type, |
| 2720 | int normalized, unsigned int stride, |
| 2721 | const void *ptr) |
| 2722 | { |
| 2723 | if ((ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program.->vertexcxx . . $ MOJOSHADER_glProgram#vertex. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) |
| 2724 | return; |
| 2725 | |
| 2726 | const GLenumcxx . . $ GLenum# gl_type = opengl_attr_typecxx . . $ opengl_attr_type(1c39e30d59415a4b).(type); |
| 2727 | const GLbooleancxx . . $ GLboolean# norm = (normalized) ? GL_TRUEcxx . . $ `<external>/11565930711847777359/gl.h:140:9`! : GL_FALSEcxx . . $ `<external>/11565930711847777359/gl.h:139:9`!; |
| 2728 | const GLintcxx . . $ GLint# gl_index = ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program.->vertex_attrib_loccxx . . $ MOJOSHADER_glProgram#vertex_attrib_loc.[usage][index]; |
| 2729 | |
| 2730 | if (gl_index == -1) |
| 2731 | return; // Nothing to do, this shader doesn't use this stream. |
| 2732 | |
| 2733 | // this happens to work in both ARB1 and GLSL, but if something alien |
| 2734 | // shows up, we'll have to split these into profile*() functions. |
| 2735 | ctxcxx . . $ ctx.->glVertexAttribPointercxx . . $ MOJOSHADER_glContext#glVertexAttribPointer.(gl_index, size, gl_type, norm, stride, ptr); |
| 2736 | |
| 2737 | // flag this array as in use, so we can enable it later. |
| 2738 | ctxcxx . . $ ctx.->want_attrcxx . . $ MOJOSHADER_glContext#want_attr.[gl_index] = 1; |
| 2739 | if (ctxcxx . . $ ctx.->max_attrscxx . . $ MOJOSHADER_glContext#max_attrs. < (gl_index + 1)) |
| 2740 | ctxcxx . . $ ctx.->max_attrscxx . . $ MOJOSHADER_glContext#max_attrs. = gl_index + 1; |
| 2741 | } // MOJOSHADER_glSetVertexAttribute |
| 2742 | |
| 2743 | |
| 2744 | // !!! FIXME: shouldn't (index) be unsigned? |
| 2745 | void MOJOSHADER_glSetVertexAttribDivisorcxx . . $ MOJOSHADER_glSetVertexAttribDivisor(16e0bb98d649a25d).(MOJOSHADER_usagecxx . . $ MOJOSHADER_usage# usage, |
| 2746 | int index, unsigned int divisor) |
| 2747 | { |
| 2748 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->have_GL_ARB_instanced_arrays); |
| 2749 | |
| 2750 | if ((ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) || (ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program.->vertexcxx . . $ MOJOSHADER_glProgram#vertex. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) |
| 2751 | return; |
| 2752 | |
| 2753 | const GLintcxx . . $ GLint# gl_index = ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program.->vertex_attrib_loccxx . . $ MOJOSHADER_glProgram#vertex_attrib_loc.[usage][index]; |
| 2754 | |
| 2755 | if (gl_index == -1) |
| 2756 | return; // Nothing to do, this shader doesn't use this stream. |
| 2757 | |
| 2758 | if (divisor != ctxcxx . . $ ctx.->attr_divisorcxx . . $ MOJOSHADER_glContext#attr_divisor.[gl_index]) |
| 2759 | { |
| 2760 | ctxcxx . . $ ctx.->glVertexAttribDivisorARBcxx . . $ MOJOSHADER_glContext#glVertexAttribDivisorARB.(gl_index, divisor); |
| 2761 | ctxcxx . . $ ctx.->attr_divisorcxx . . $ MOJOSHADER_glContext#attr_divisor.[gl_index] = divisor; |
| 2762 | } // if |
| 2763 | } // MOJOSHADER_glSetVertexAttribDivisor |
| 2764 | |
| 2765 | |
| 2766 | void MOJOSHADER_glSetLegacyBumpMapEnvcxx . . $ MOJOSHADER_glSetLegacyBumpMapEnv(c7dc24266a8c329b).(unsigned int sampler, float mat00, |
| 2767 | float mat01, float mat10, float mat11, |
| 2768 | float lscale, float loffset) |
| 2769 | { |
| 2770 | if ((sampler == 0) || (sampler > (MAX_TEXBEMScxx . . $ `mojoshader_opengl.c:156:9`!+1))) |
| 2771 | return; |
| 2772 | |
| 2773 | GLfloatcxx . . $ GLfloat# *dstf = ctxcxx . . $ ctx.->texbem_statecxx . . $ MOJOSHADER_glContext#texbem_state. + (6 * (sampler-1)); |
| 2774 | *(dstf++) = (GLfloatcxx . . $ GLfloat#) mat00; |
| 2775 | *(dstf++) = (GLfloatcxx . . $ GLfloat#) mat01; |
| 2776 | *(dstf++) = (GLfloatcxx . . $ GLfloat#) mat10; |
| 2777 | *(dstf++) = (GLfloatcxx . . $ GLfloat#) mat11; |
| 2778 | *(dstf++) = (GLfloatcxx . . $ GLfloat#) lscale; |
| 2779 | *(dstf++) = (GLfloatcxx . . $ GLfloat#) loffset; |
| 2780 | ctxcxx . . $ ctx.->generationcxx . . $ MOJOSHADER_glContext#generation.++; |
| 2781 | } // MOJOSHADER_glSetLegacyBumpMapEnv |
| 2782 | |
| 2783 | |
| 2784 | void MOJOSHADER_glProgramReadycxx . . $ MOJOSHADER_glProgramReady(49f6e7a06ebc5aa8).(void) |
| 2785 | { |
| 2786 | MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program = ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program.; |
| 2787 | |
| 2788 | if (program == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2789 | return; // nothing to do. |
| 2790 | |
| 2791 | // Toggle vertex attribute arrays on/off, based on our needs. |
| 2792 | update_enabled_arrayscxx . . $ update_enabled_arrays(49f6e7a06ebc5aa8).(); |
| 2793 | |
| 2794 | if (program->uses_pointsizecxx . . $ MOJOSHADER_glProgram#uses_pointsize. != ctxcxx . . $ ctx.->pointsize_enabledcxx . . $ MOJOSHADER_glContext#pointsize_enabled.) |
| 2795 | { |
| 2796 | ctxcxx . . $ ctx.->profileToggleProgramPointSizecxx . . $ MOJOSHADER_glContext#profileToggleProgramPointSize.(program->uses_pointsizecxx . . $ MOJOSHADER_glProgram#uses_pointsize.); |
| 2797 | ctxcxx . . $ ctx.->pointsize_enabledcxx . . $ MOJOSHADER_glContext#pointsize_enabled. = program->uses_pointsizecxx . . $ MOJOSHADER_glProgram#uses_pointsize.; |
| 2798 | } // if |
| 2799 | |
| 2800 | // push Uniforms to the program from our register files... |
| 2801 | if ( ((program->uniform_countcxx . . $ MOJOSHADER_glProgram#uniform_count.) || (program->texbem_countcxx . . $ MOJOSHADER_glProgram#texbem_count.)) && |
| 2802 | (program->generationcxx . . $ MOJOSHADER_glProgram#generation. != ctxcxx . . $ ctx.->generationcxx . . $ MOJOSHADER_glContext#generation.)) |
| 2803 | { |
| 2804 | // vertex shader uniforms come first in program->uniforms array. |
| 2805 | const uint32cxx . . $ uint32# count = program->uniform_countcxx . . $ MOJOSHADER_glProgram#uniform_count.; |
| 2806 | const GLfloatcxx . . $ GLfloat# *srcf = ctxcxx . . $ ctx.->vs_reg_file_fcxx . . $ MOJOSHADER_glContext#vs_reg_file_f.; |
| 2807 | const GLintcxx . . $ GLint# *srci = ctxcxx . . $ ctx.->vs_reg_file_icxx . . $ MOJOSHADER_glContext#vs_reg_file_i.; |
| 2808 | const uint8cxx . . $ uint8# *srcb = ctxcxx . . $ ctx.->vs_reg_file_bcxx . . $ MOJOSHADER_glContext#vs_reg_file_b.; |
| 2809 | MOJOSHADER_shaderTypecxx . . $ MOJOSHADER_shaderType# shader_type = MOJOSHADER_TYPE_VERTEXcxx . . $ MOJOSHADER_TYPE_VERTEX.; |
| 2810 | GLfloatcxx . . $ GLfloat# *dstf = program->vs_uniforms_float4cxx . . $ MOJOSHADER_glProgram#vs_uniforms_float4.; |
| 2811 | GLintcxx . . $ GLint# *dsti = program->vs_uniforms_int4cxx . . $ MOJOSHADER_glProgram#vs_uniforms_int4.; |
| 2812 | GLintcxx . . $ GLint# *dstb = program->vs_uniforms_boolcxx . . $ MOJOSHADER_glProgram#vs_uniforms_bool.; |
| 2813 | uint8cxx . . $ uint8# uniforms_changed = 0; |
| 2814 | uint32cxx . . $ uint32# i; |
| 2815 | |
| 2816 | for (i = 0; i < count; i++) |
| 2817 | { |
| 2818 | UniformMapcxx . . $ UniformMap# *map = &program->uniformscxx . . $ MOJOSHADER_glProgram#uniforms.[i]; |
| 2819 | const MOJOSHADER_shaderTypecxx . . $ MOJOSHADER_shaderType# uniform_shader_type = map->shader_typecxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_0#shader_type.; |
| 2820 | const MOJOSHADER_uniformcxx . . $ MOJOSHADER_uniform# *u = map->uniformcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_0#uniform.; |
| 2821 | const MOJOSHADER_uniformTypecxx . . $ MOJOSHADER_uniformType# type = u->typecxx . . $ MOJOSHADER_uniform#type.; |
| 2822 | const int index = u->indexcxx . . $ MOJOSHADER_uniform#index.; |
| 2823 | const int size = u->array_countcxx . . $ MOJOSHADER_uniform#array_count. ? u->array_countcxx . . $ MOJOSHADER_uniform#array_count. : 1; |
| 2824 | |
| 2825 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(!u->constant); |
| 2826 | |
| 2827 | // Did we switch from vertex to pixel (to geometry, etc)? |
| 2828 | if (shader_type != uniform_shader_type) |
| 2829 | { |
| 2830 | // we start with vertex, move to pixel, then to geometry, etc. |
| 2831 | // The array should always be sorted as such. |
| 2832 | if (uniform_shader_type == MOJOSHADER_TYPE_PIXELcxx . . $ MOJOSHADER_TYPE_PIXEL.) |
| 2833 | { |
| 2834 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(shader_type == MOJOSHADER_TYPE_VERTEX); |
| 2835 | srcf = ctxcxx . . $ ctx.->ps_reg_file_fcxx . . $ MOJOSHADER_glContext#ps_reg_file_f.; |
| 2836 | srci = ctxcxx . . $ ctx.->ps_reg_file_icxx . . $ MOJOSHADER_glContext#ps_reg_file_i.; |
| 2837 | srcb = ctxcxx . . $ ctx.->ps_reg_file_bcxx . . $ MOJOSHADER_glContext#ps_reg_file_b.; |
| 2838 | dstf = program->ps_uniforms_float4cxx . . $ MOJOSHADER_glProgram#ps_uniforms_float4.; |
| 2839 | dsti = program->ps_uniforms_int4cxx . . $ MOJOSHADER_glProgram#ps_uniforms_int4.; |
| 2840 | dstb = program->ps_uniforms_boolcxx . . $ MOJOSHADER_glProgram#ps_uniforms_bool.; |
| 2841 | } // if |
| 2842 | else |
| 2843 | { |
| 2844 | // Should be ordered vertex, then pixel, then geometry. |
| 2845 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(0 && "Unexpected shader type"); |
| 2846 | } // else |
| 2847 | |
| 2848 | shader_type = uniform_shader_type; |
| 2849 | } // if |
| 2850 | |
| 2851 | if (type == MOJOSHADER_UNIFORM_FLOATcxx . . $ MOJOSHADER_UNIFORM_FLOAT.) |
| 2852 | { |
| 2853 | const size_t count = 4 * size; |
| 2854 | const GLfloatcxx . . $ GLfloat# *f = &srcf[index * 4]; |
| 2855 | if (memcmpcxx . . $ memcmp(36f949851efa3055).(dstf, f, sizeof (GLfloatcxx . . $ GLfloat#) * count) != 0) |
| 2856 | { |
| 2857 | memcpycxx . . $ memcpy(cc817cb175f282d).(dstf, f, sizeof (GLfloatcxx . . $ GLfloat#) * count); |
| 2858 | uniforms_changed = 1; |
| 2859 | } |
| 2860 | dstf += count; |
| 2861 | } // if |
| 2862 | else if (type == MOJOSHADER_UNIFORM_INTcxx . . $ MOJOSHADER_UNIFORM_INT.) |
| 2863 | { |
| 2864 | const size_t count = 4 * size; |
| 2865 | const GLintcxx . . $ GLint# *i = &srci[index * 4]; |
| 2866 | if (memcmpcxx . . $ memcmp(36f949851efa3055).(dsti, i, sizeof (GLintcxx . . $ GLint#) * count) != 0) |
| 2867 | { |
| 2868 | memcpycxx . . $ memcpy(cc817cb175f282d).(dsti, i, sizeof (GLintcxx . . $ GLint#) * count); |
| 2869 | uniforms_changed = 1; |
| 2870 | } // if |
| 2871 | dsti += count; |
| 2872 | } // else if |
| 2873 | else if (type == MOJOSHADER_UNIFORM_BOOLcxx . . $ MOJOSHADER_UNIFORM_BOOL.) |
| 2874 | { |
| 2875 | const size_t count = size; |
| 2876 | const uint8cxx . . $ uint8# *b = &srcb[index]; |
| 2877 | size_t i; |
| 2878 | for (i = 0; i < count; i++) |
| 2879 | if (dstb[i] != b[i]) |
| 2880 | { |
| 2881 | dstb[i] = (GLintcxx . . $ GLint#) b[i]; |
| 2882 | uniforms_changed = 1; |
| 2883 | } // if |
| 2884 | dstb += count; |
| 2885 | } // else if |
| 2886 | |
| 2887 | // !!! FIXME: set constants that overlap the array. |
| 2888 | } // for |
| 2889 | |
| 2890 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((!program->texbem_count) || (program->fragment)); |
| 2891 | if ((program->texbem_countcxx . . $ MOJOSHADER_glProgram#texbem_count.) && (program->fragmentcxx . . $ MOJOSHADER_glProgram#fragment.)) |
| 2892 | { |
| 2893 | const MOJOSHADER_parseDatacxx . . $ MOJOSHADER_parseData# *pd = program->fragmentcxx . . $ MOJOSHADER_glProgram#fragment.->parseDatacxx . . $ MOJOSHADER_glShader#parseData.; |
| 2894 | const int samp_count = pd->sampler_countcxx . . $ MOJOSHADER_parseData#sampler_count.; |
| 2895 | const MOJOSHADER_samplercxx . . $ MOJOSHADER_sampler# *samps = pd->samplerscxx . . $ MOJOSHADER_parseData#samplers.; |
| 2896 | GLfloatcxx . . $ GLfloat# *dstf = program->ps_uniforms_float4cxx . . $ MOJOSHADER_glProgram#ps_uniforms_float4.; |
| 2897 | int texbem_count = 0; |
| 2898 | |
| 2899 | dstf += (program->ps_uniforms_float4_countcxx . . $ MOJOSHADER_glProgram#ps_uniforms_float4_count. * 4) - |
| 2900 | (program->texbem_countcxx . . $ MOJOSHADER_glProgram#texbem_count. * 8); |
| 2901 | |
| 2902 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(program->texbem_count <= MAX_TEXBEMScxx . . $ `mojoshader_opengl.c:156:9`!); |
| 2903 | for (i = 0; i < samp_count; i++) |
| 2904 | { |
| 2905 | if (samps[i].texbemcxx . . $ MOJOSHADER_sampler#texbem.) |
| 2906 | { |
| 2907 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(samps[i].index > 0); |
| 2908 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(samps[i].index <= MAX_TEXBEMScxx . . $ `mojoshader_opengl.c:156:9`!); |
| 2909 | memcpycxx . . $ memcpy(cc817cb175f282d).(dstf, &ctxcxx . . $ ctx.->texbem_statecxx . . $ MOJOSHADER_glContext#texbem_state.[6 * (samps[i].indexcxx . . $ MOJOSHADER_sampler#index.-1)], |
| 2910 | sizeof (GLfloatcxx . . $ GLfloat#) * 6); |
| 2911 | dstf[6] = 0.0f; |
| 2912 | dstf[7] = 0.0f; |
| 2913 | dstf += 8; |
| 2914 | texbem_count++; |
| 2915 | } // if |
| 2916 | } // for |
| 2917 | |
| 2918 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(texbem_count == program->texbem_count); |
| 2919 | } // if |
| 2920 | |
| 2921 | program->generationcxx . . $ MOJOSHADER_glProgram#generation. = ctxcxx . . $ ctx.->generationcxx . . $ MOJOSHADER_glContext#generation.; |
| 2922 | |
| 2923 | if (uniforms_changed) |
| 2924 | ctxcxx . . $ ctx.->profilePushUniformscxx . . $ MOJOSHADER_glContext#profilePushUniforms.(); |
| 2925 | } // if |
| 2926 | } // MOJOSHADER_glProgramReady |
| 2927 | |
| 2928 | |
| 2929 | void MOJOSHADER_glProgramViewportInfocxx . . $ MOJOSHADER_glProgramViewportInfo(1559a299834bcdd5).(int viewportW, int viewportH, |
| 2930 | int backbufferW, int backbufferH, |
| 2931 | int renderTargetBound) |
| 2932 | { |
| 2933 | int vposFlip[2]; |
| 2934 | |
| 2935 | /* The uniform is only going to exist if VPOS is used! */ |
| 2936 | if (ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program.->ps_vpos_flip_loccxx . . $ MOJOSHADER_glProgram#ps_vpos_flip_loc. != -1) |
| 2937 | { |
| 2938 | if (renderTargetBound) |
| 2939 | { |
| 2940 | vposFlip[0] = 1; |
| 2941 | vposFlip[1] = 0; |
| 2942 | } // if |
| 2943 | else |
| 2944 | { |
| 2945 | vposFlip[0] = -1; |
| 2946 | vposFlip[1] = backbufferH; |
| 2947 | } // else |
| 2948 | if ( (ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program.->current_vpos_flipcxx . . $ MOJOSHADER_glProgram#current_vpos_flip.[0] != vposFlip[0]) || |
| 2949 | (ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program.->current_vpos_flipcxx . . $ MOJOSHADER_glProgram#current_vpos_flip.[1] != vposFlip[1]) ) |
| 2950 | { |
| 2951 | ctxcxx . . $ ctx.->glUniform2fcxx . . $ MOJOSHADER_glContext#glUniform2f.( |
| 2952 | ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program.->ps_vpos_flip_loccxx . . $ MOJOSHADER_glProgram#ps_vpos_flip_loc., |
| 2953 | (float) vposFlip[0], |
| 2954 | (float) vposFlip[1] |
| 2955 | ); |
| 2956 | ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program.->current_vpos_flipcxx . . $ MOJOSHADER_glProgram#current_vpos_flip.[0] = vposFlip[0]; |
| 2957 | ctxcxx . . $ ctx.->bound_programcxx . . $ MOJOSHADER_glContext#bound_program.->current_vpos_flipcxx . . $ MOJOSHADER_glProgram#current_vpos_flip.[1] = vposFlip[1]; |
| 2958 | } // if |
| 2959 | } // if |
| 2960 | |
| 2961 | #ifdef MOJOSHADER_FLIP_RENDERTARGET |
| 2962 | if (ctx->bound_program->vs_flip_loc != -1) |
| 2963 | { |
| 2964 | /* Some compilers require that vpFlip be a float value, rather than int. |
| 2965 | * However, there's no real reason for it to be a float in the API, so we |
| 2966 | * do a cast in here. That's not so bad, right...? |
| 2967 | * -flibit |
| 2968 | */ |
| 2969 | const int flip = renderTargetBound ? -1 : 1; |
| 2970 | if (flip != ctx->bound_program->current_flip) |
| 2971 | { |
| 2972 | ctx->glUniform1f(ctx->bound_program->vs_flip_loc, (float) flip); |
| 2973 | ctx->bound_program->current_flip = flip; |
| 2974 | } // if |
| 2975 | } // if |
| 2976 | #endif |
| 2977 | } // MOJOSHADER_glViewportInfo |
| 2978 | |
| 2979 | |
| 2980 | void MOJOSHADER_glDeleteProgramcxx . . $ MOJOSHADER_glDeleteProgram(b6cc5ff6e33eca9d).(MOJOSHADER_glProgramcxx . . $ MOJOSHADER_glProgram# *program) |
| 2981 | { |
| 2982 | program_unrefcxx . . $ program_unref(b6cc5ff6e33eca9d).(program); |
| 2983 | } // MOJOSHADER_glDeleteProgram |
| 2984 | |
| 2985 | |
| 2986 | void MOJOSHADER_glDeleteShadercxx . . $ MOJOSHADER_glDeleteShader(faf9002d9d72f6c2).(MOJOSHADER_glShadercxx . . $ MOJOSHADER_glShader# *shader) |
| 2987 | { |
| 2988 | // See if this was bound as an unlinked program anywhere... |
| 2989 | if (ctxcxx . . $ ctx.->linker_cachecxx . . $ MOJOSHADER_glContext#linker_cache.) |
| 2990 | { |
| 2991 | const void *key = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 2992 | void *iter = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 2993 | int morekeys = hash_iter_keyscxx . . $ hash_iter_keys(c68c721387e4f0a2).(ctxcxx . . $ ctx.->linker_cachecxx . . $ MOJOSHADER_glContext#linker_cache., &key, &iter); |
| 2994 | while (morekeys) |
| 2995 | { |
| 2996 | const BoundShaderscxx . . $ BoundShaders# *shaders = (const BoundShaderscxx . . $ BoundShaders# *) key; |
| 2997 | // Do this here so we don't confuse the iteration by removing... |
| 2998 | morekeys = hash_iter_keyscxx . . $ hash_iter_keys(c68c721387e4f0a2).(ctxcxx . . $ ctx.->linker_cachecxx . . $ MOJOSHADER_glContext#linker_cache., &key, &iter); |
| 2999 | if ((shaders->vertexcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_2#vertex. == shader) || (shaders->fragmentcxx . . $ $anonymous_type_6e4d53cd9e0ac3c5_2#fragment. == shader)) |
| 3000 | { |
| 3001 | // Deletes the linked program, which will unref the shader. |
| 3002 | hash_removecxx . . $ hash_remove(1d30a91d107a3de).(ctxcxx . . $ ctx.->linker_cachecxx . . $ MOJOSHADER_glContext#linker_cache., shaders, ctxcxx . . $ ctx.); |
| 3003 | } // if |
| 3004 | } // while |
| 3005 | } // if |
| 3006 | |
| 3007 | shader_unrefcxx . . $ shader_unref(faf9002d9d72f6c2).(shader); |
| 3008 | } // MOJOSHADER_glDeleteShader |
| 3009 | |
| 3010 | |
| 3011 | void MOJOSHADER_glDestroyContextcxx . . $ MOJOSHADER_glDestroyContext(512d40087428bebb).(MOJOSHADER_glContextcxx . . $ MOJOSHADER_glContext# *_ctx) |
| 3012 | { |
| 3013 | MOJOSHADER_glContextcxx . . $ MOJOSHADER_glContext# *current_ctx = ctxcxx . . $ ctx.; |
| 3014 | ctxcxx . . $ ctx. = _ctx; |
| 3015 | MOJOSHADER_glBindProgramcxx . . $ MOJOSHADER_glBindProgram(b6cc5ff6e33eca9d).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 3016 | if (ctxcxx . . $ ctx.->linker_cachecxx . . $ MOJOSHADER_glContext#linker_cache.) |
| 3017 | hash_destroycxx . . $ hash_destroy(801354b631669f34).(ctxcxx . . $ ctx.->linker_cachecxx . . $ MOJOSHADER_glContext#linker_cache., ctxcxx . . $ ctx.); |
| 3018 | lookup_entry_pointscxx . . $ lookup_entry_points(5928c5b85337a06e).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); // !!! FIXME: is there a value to this? |
| 3019 | Freecxx . . $ Free(5d22bdacc48458e8).(ctxcxx . . $ ctx.); |
| 3020 | ctxcxx . . $ ctx. = ((current_ctx == _ctx) ? NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! : current_ctx); |
| 3021 | } // MOJOSHADER_glDestroyContext |
| 3022 | |
| 3023 | // end of mojoshader_opengl.c ... |
| 3024 |