@@ -184,7 +184,7 @@ enum slang_texture_semantic slang_name_to_texture_semantic_array(
184184 return semantic ;
185185 }
186186 }
187- else if (string_is_equal (name , * names ))
187+ else if (strcmp (name , * names ) == 0 )
188188 {
189189 * index = 0 ;
190190 return semantic ;
@@ -194,9 +194,8 @@ enum slang_texture_semantic slang_name_to_texture_semantic_array(
194194}
195195
196196/* -------------------------------------------------------------------
197- * glslang_read_shader_file — rewritten to use shader_line_buf
197+ * glslang_read_shader_file
198198 * ------------------------------------------------------------------- */
199-
200199bool glslang_read_shader_file (const char * path ,
201200 struct shader_line_buf * output , bool root_file , bool is_optional )
202201{
@@ -209,12 +208,12 @@ bool glslang_read_shader_file(const char *path,
209208 tmp [0 ] = '\0' ;
210209
211210 /* Sanity check */
212- if (string_is_empty ( path ) || !output )
211+ if (! path || path [ 0 ] == '\0' || !output )
213212 return false;
214213
215214 basename = path_basename_nocompression (path );
216215
217- if (string_is_empty ( basename ) )
216+ if (! basename || basename [ 0 ] == '\0' )
218217 return false;
219218
220219 /* Read file contents */
@@ -239,7 +238,7 @@ bool glslang_read_shader_file(const char *path,
239238 /* If this is the 'parent' shader file and a slang file,
240239 * ensure that first line is a 'VERSION' string */
241240 bool check_version = root_file
242- && string_is_equal ( path_get_extension (path ), "slang" );
241+ && ( strcmp ( path_get_extension (path ), "slang" ) == 0 );
243242
244243 while (* cursor != '\0' )
245244 {
@@ -259,7 +258,7 @@ bool glslang_read_shader_file(const char *path,
259258
260259 if (check_version )
261260 {
262- if (strncmp ("#version " , line_start , STRLEN_CONST ("#version " )))
261+ if (strncmp ("#version " , line_start , sizeof ("#version " )- 1 ))
263262 {
264263 RARCH_ERR ("[Slang] First line of the shader must contain a valid "
265264 "#version string.\n" );
@@ -277,16 +276,16 @@ bool glslang_read_shader_file(const char *path,
277276 * errors easier. */
278277 if (!shader_line_buf_append (output ,
279278 "#extension GL_GOOGLE_cpp_style_line_directive : require" ,
280- STRLEN_CONST ("#extension GL_GOOGLE_cpp_style_line_directive : require" )))
279+ sizeof ("#extension GL_GOOGLE_cpp_style_line_directive : require" )- 1 ))
281280 {
282281 * newline = saved ;
283282 goto cleanup ;
284283 }
285284
286285 /* Append feature defines */
287- if (!shader_line_buf_append (output , "#define _HAS_ORIGINALASPECT_UNIFORMS" , STRLEN_CONST ("#define _HAS_ORIGINALASPECT_UNIFORMS" ))
288- || !shader_line_buf_append (output , "#define _HAS_FRAMETIME_UNIFORMS" , STRLEN_CONST ("#define _HAS_FRAMETIME_UNIFORMS" ))
289- || !shader_line_buf_append (output , "#define _HAS_SENSOR_UNIFORMS" , STRLEN_CONST ("#define _HAS_SENSOR_UNIFORMS" )))
286+ if (!shader_line_buf_append (output , "#define _HAS_ORIGINALASPECT_UNIFORMS" , sizeof ("#define _HAS_ORIGINALASPECT_UNIFORMS" )- 1 )
287+ || !shader_line_buf_append (output , "#define _HAS_FRAMETIME_UNIFORMS" , sizeof ("#define _HAS_FRAMETIME_UNIFORMS" )- 1 )
288+ || !shader_line_buf_append (output , "#define _HAS_SENSOR_UNIFORMS" , sizeof ("#define _HAS_SENSOR_UNIFORMS" )- 1 ))
290289 {
291290 * newline = saved ;
292291 goto cleanup ;
@@ -309,9 +308,9 @@ bool glslang_read_shader_file(const char *path,
309308 /* Non-root or non-slang: emit feature defines + #line once */
310309 if (root_file )
311310 {
312- if (!shader_line_buf_append (output , "#define _HAS_ORIGINALASPECT_UNIFORMS" , STRLEN_CONST ("#define _HAS_ORIGINALASPECT_UNIFORMS" ))
313- || !shader_line_buf_append (output , "#define _HAS_FRAMETIME_UNIFORMS" , STRLEN_CONST ("#define _HAS_FRAMETIME_UNIFORMS" ))
314- || !shader_line_buf_append (output , "#define _HAS_SENSOR_UNIFORMS" , STRLEN_CONST ("#define _HAS_SENSOR_UNIFORMS" )))
311+ if (!shader_line_buf_append (output , "#define _HAS_ORIGINALASPECT_UNIFORMS" , sizeof ("#define _HAS_ORIGINALASPECT_UNIFORMS" )- 1 )
312+ || !shader_line_buf_append (output , "#define _HAS_FRAMETIME_UNIFORMS" , sizeof ("#define _HAS_FRAMETIME_UNIFORMS" )- 1 )
313+ || !shader_line_buf_append (output , "#define _HAS_SENSOR_UNIFORMS" , sizeof ("#define _HAS_SENSOR_UNIFORMS" )- 1 ))
315314 {
316315 * newline = saved ;
317316 goto cleanup ;
@@ -326,9 +325,9 @@ bool glslang_read_shader_file(const char *path,
326325 }
327326 else
328327 {
329- if (!shader_line_buf_append (output , "#define _HAS_ORIGINALASPECT_UNIFORMS" , STRLEN_CONST ("#define _HAS_ORIGINALASPECT_UNIFORMS" ))
330- || !shader_line_buf_append (output , "#define _HAS_FRAMETIME_UNIFORMS" , STRLEN_CONST ("#define _HAS_FRAMETIME_UNIFORMS" ))
331- || !shader_line_buf_append (output , "#define _HAS_SENSOR_UNIFORMS" , STRLEN_CONST ("#define _HAS_SENSOR_UNIFORMS" )))
328+ if (!shader_line_buf_append (output , "#define _HAS_ORIGINALASPECT_UNIFORMS" , sizeof ("#define _HAS_ORIGINALASPECT_UNIFORMS" )- 1 )
329+ || !shader_line_buf_append (output , "#define _HAS_FRAMETIME_UNIFORMS" , sizeof ("#define _HAS_FRAMETIME_UNIFORMS" )- 1 )
330+ || !shader_line_buf_append (output , "#define _HAS_SENSOR_UNIFORMS" , sizeof ("#define _HAS_SENSOR_UNIFORMS" )- 1 ))
332331 {
333332 * newline = saved ;
334333 goto cleanup ;
@@ -356,16 +355,16 @@ bool glslang_read_shader_file(const char *path,
356355 /* Process the line */
357356 {
358357 bool include_optional = !strncmp ("#pragma include_optional " ,
359- line_start , STRLEN_CONST ("#pragma include_optional " ));
358+ line_start , sizeof ("#pragma include_optional " )- 1 );
360359
361- if ( !strncmp ("#include " , line_start , STRLEN_CONST ("#include " ))
360+ if ( !strncmp ("#include " , line_start , sizeof ("#include " )- 1 )
362361 || include_optional )
363362 {
364363 char include_path [PATH_MAX_LENGTH ];
365364 char * include_file = slang_get_include_file (
366365 line_start , strlen (line_start ));
367366
368- if (string_is_empty ( include_file ) )
367+ if (! include_file || include_file [ 0 ] == '\0' )
369368 {
370369 RARCH_ERR ("[Slang] Invalid include statement \"%s\".\n" ,
371370 line_start );
@@ -393,8 +392,8 @@ bool glslang_read_shader_file(const char *path,
393392 if (!shader_line_buf_append_str (output , tmp ))
394393 goto cleanup ;
395394 }
396- else if ( !strncmp ("#endif" , line_start , STRLEN_CONST ("#endif" ))
397- || !strncmp ("#pragma" , line_start , STRLEN_CONST ("#pragma" )))
395+ else if ( !strncmp ("#endif" , line_start , sizeof ("#endif" )- 1 )
396+ || !strncmp ("#pragma" , line_start , sizeof ("#pragma" )- 1 ))
398397 {
399398 if (!shader_line_buf_append_str (output , line_start ))
400399 {
@@ -483,8 +482,13 @@ const char *glslang_format_to_string(enum glslang_format fmt)
483482
484483enum glslang_format glslang_find_format (const char * fmt )
485484{
485+ size_t len = strlen (fmt );
486486#undef FMT
487- #define FMT (x ) if (string_is_equal(fmt, #x)) return SLANG_FORMAT_ ## x
487+ #define FMT (x ) do { \
488+ static const char s[] = #x; \
489+ if (sizeof(s) - 1 == len && memcmp(fmt, s, sizeof(s) - 1) == 0) \
490+ return SLANG_FORMAT_ ## x; \
491+ } while(0)
488492 FMT (R8_UNORM );
489493 FMT (R8_UINT );
490494 FMT (R8_SINT );
@@ -495,10 +499,8 @@ enum glslang_format glslang_find_format(const char *fmt)
495499 FMT (R8G8B8A8_UINT );
496500 FMT (R8G8B8A8_SINT );
497501 FMT (R8G8B8A8_SRGB );
498-
499502 FMT (A2B10G10R10_UNORM_PACK32 );
500503 FMT (A2B10G10R10_UINT_PACK32 );
501-
502504 FMT (R16_UINT );
503505 FMT (R16_SINT );
504506 FMT (R16_SFLOAT );
@@ -508,7 +510,6 @@ enum glslang_format glslang_find_format(const char *fmt)
508510 FMT (R16G16B16A16_UINT );
509511 FMT (R16G16B16A16_SINT );
510512 FMT (R16G16B16A16_SFLOAT );
511-
512513 FMT (R32_UINT );
513514 FMT (R32_SINT );
514515 FMT (R32_SFLOAT );
@@ -518,7 +519,6 @@ enum glslang_format glslang_find_format(const char *fmt)
518519 FMT (R32G32B32A32_UINT );
519520 FMT (R32G32B32A32_SINT );
520521 FMT (R32G32B32A32_SFLOAT );
521-
522522 return SLANG_FORMAT_UNKNOWN ;
523523}
524524
0 commit comments