@@ -31,7 +31,7 @@ static const char *texture_semantic_names[] = {
3131 " PassOutput" ,
3232 " PassFeedback" ,
3333 " User" ,
34- nullptr
34+ NULL
3535};
3636
3737static const char *texture_semantic_uniform_names[] = {
@@ -41,7 +41,7 @@ static const char *texture_semantic_uniform_names[] = {
4141 " PassOutputSize" ,
4242 " PassFeedbackSize" ,
4343 " UserSize" ,
44- nullptr
44+ NULL
4545};
4646
4747static const char *semantic_uniform_names[] = {
@@ -74,8 +74,9 @@ static slang_texture_semantic slang_name_to_texture_semantic(
7474 const std::unordered_map<std::string, slang_texture_semantic_map> &semantic_map,
7575 const std::string &name, unsigned *index)
7676{
77- auto itr = semantic_map.find (name);
78- if (itr != end (semantic_map))
77+ std::unordered_map<std::string, slang_texture_semantic_map>::const_iterator itr =
78+ semantic_map.find (name);
79+ if (itr != semantic_map.end ())
7980 {
8081 *index = itr->second .index ;
8182 return itr->second .semantic ;
@@ -89,8 +90,9 @@ static slang_texture_semantic slang_uniform_name_to_texture_semantic(
8990 const std::unordered_map<std::string, slang_texture_semantic_map> &semantic_map,
9091 const std::string &name, unsigned *index)
9192{
92- auto itr = semantic_map.find (name);
93- if (itr != end (semantic_map))
93+ std::unordered_map<std::string, slang_texture_semantic_map>::const_iterator itr =
94+ semantic_map.find (name);
95+ if (itr != semantic_map.end ())
9496 {
9597 *index = itr->second .index ;
9698 return itr->second .semantic ;
@@ -105,21 +107,21 @@ static slang_semantic slang_uniform_name_to_semantic(
105107 const std::string &name, unsigned *index)
106108{
107109 unsigned i = 0 ;
108- auto itr = semantic_map.find (name);
110+ std::unordered_map<std::string, slang_semantic_map>::const_iterator itr =
111+ semantic_map.find (name);
109112
110- if (itr != end (semantic_map ))
113+ if (itr != semantic_map. end ())
111114 {
112115 *index = itr->second .index ;
113116 return itr->second .semantic ;
114117 }
115118
116119 /* No builtin semantics are arrayed. */
117120 *index = 0 ;
118- for (auto n : semantic_uniform_names)
121+ for (i = 0 ; i < sizeof ( semantic_uniform_names) / sizeof (semantic_uniform_names[ 0 ]); i++ )
119122 {
120- if (name == n )
123+ if (name == semantic_uniform_names[i] )
121124 return static_cast <slang_semantic>(i);
122- i++;
123125 }
124126
125127 return SLANG_INVALID_SEMANTIC;
@@ -140,7 +142,7 @@ static bool set_ubo_texture_offset(
140142{
141143 resize_minimum (reflection->semantic_textures [semantic], index + 1 );
142144 slang_texture_semantic_meta &sem = reflection->semantic_textures [semantic][index];
143- bool &active = push_constant ? sem.push_constant : sem.uniform ;
145+ bool &active = push_constant ? sem.push_constant : sem.uniform ;
144146 size_t &active_offset = push_constant ? sem.push_constant_offset : sem.ubo_offset ;
145147
146148 if (active)
@@ -209,7 +211,7 @@ static bool set_ubo_offset(
209211 size_t offset, unsigned num_components, bool push_constant)
210212{
211213 slang_semantic_meta &sem = reflection->semantics [semantic];
212- bool &active = push_constant ? sem.push_constant : sem.uniform ;
214+ bool &active = push_constant ? sem.push_constant : sem.uniform ;
213215 size_t &active_offset = push_constant ? sem.push_constant_offset : sem.ubo_offset ;
214216
215217 if (active)
@@ -223,7 +225,6 @@ static bool set_ubo_offset(
223225 unsigned (offset));
224226 return false ;
225227 }
226-
227228 }
228229
229230 if ( (sem.num_components != num_components) &&
@@ -372,7 +373,8 @@ static bool add_active_buffer_ranges(
372373{
373374 unsigned i;
374375 /* Get which uniforms are actually in use by this shader. */
375- auto ranges = compiler.get_active_buffer_ranges (resource.id );
376+ spirv_cross::SmallVector<spirv_cross::BufferRange> ranges =
377+ compiler.get_active_buffer_ranges (resource.id );
376378
377379 for (i = 0 ; i < ranges.size (); i++)
378380 {
@@ -389,7 +391,8 @@ static bool add_active_buffer_ranges(
389391 *reflection->texture_semantic_uniform_map ,
390392 name, &tex_sem_index);
391393
392- if (tex_sem == SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT && tex_sem_index >= reflection->pass_number )
394+ if (tex_sem == SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT &&
395+ tex_sem_index >= reflection->pass_number )
393396 {
394397 RARCH_ERR (" [Slang] Non causal filter chain detected. "
395398 " Shader is trying to use output from pass #%u,"
@@ -447,9 +450,17 @@ static bool add_active_buffer_ranges(
447450
448451
449452slang_reflection::slang_reflection ()
453+ : ubo_size(0 ),
454+ push_constant_size(0 ),
455+ ubo_binding(0 ),
456+ ubo_stage_mask(0 ),
457+ push_constant_stage_mask(0 ),
458+ texture_semantic_map(NULL ),
459+ texture_semantic_uniform_map(NULL ),
460+ semantic_map(NULL ),
461+ pass_number(0 )
450462{
451463 unsigned i;
452-
453464 for (i = 0 ; i < SLANG_NUM_TEXTURE_SEMANTICS; i++)
454465 semantic_textures[i].resize (
455466 slang_texture_semantic_is_array (
@@ -537,14 +548,18 @@ bool slang_reflect(
537548
538549 if (fragment.push_constant_buffers .size () > 1 )
539550 {
540- RARCH_ERR (" [Slang] Fragment must use zero or one push cosntant buffer.\n " );
551+ RARCH_ERR (" [Slang] Fragment must use zero or one push constant buffer.\n " );
541552 return false ;
542553 }
543554
544- uint32_t vertex_ubo = vertex.uniform_buffers .empty () ? 0 : (uint32_t )vertex.uniform_buffers [0 ].id ;
545- uint32_t fragment_ubo = fragment.uniform_buffers .empty () ? 0 : (uint32_t )fragment.uniform_buffers [0 ].id ;
546- uint32_t vertex_push = vertex.push_constant_buffers .empty () ? 0 : (uint32_t )vertex.push_constant_buffers [0 ].id ;
547- uint32_t fragment_push = fragment.push_constant_buffers .empty () ? 0 : (uint32_t )fragment.push_constant_buffers [0 ].id ;
555+ uint32_t vertex_ubo = vertex.uniform_buffers .empty ()
556+ ? 0 : (uint32_t )vertex.uniform_buffers [0 ].id ;
557+ uint32_t fragment_ubo = fragment.uniform_buffers .empty ()
558+ ? 0 : (uint32_t )fragment.uniform_buffers [0 ].id ;
559+ uint32_t vertex_push = vertex.push_constant_buffers .empty ()
560+ ? 0 : (uint32_t )vertex.push_constant_buffers [0 ].id ;
561+ uint32_t fragment_push = fragment.push_constant_buffers .empty ()
562+ ? 0 : (uint32_t )fragment.push_constant_buffers [0 ].id ;
548563
549564 if (vertex_ubo &&
550565 vertex_compiler.get_decoration (
@@ -564,21 +579,21 @@ bool slang_reflect(
564579
565580 unsigned vertex_ubo_binding = vertex_ubo
566581 ? vertex_compiler.get_decoration (vertex_ubo, spv::DecorationBinding)
567- : - 1u ;
582+ : ( unsigned )- 1 ;
568583 unsigned fragment_ubo_binding = fragment_ubo
569584 ? fragment_compiler.get_decoration (fragment_ubo, spv::DecorationBinding)
570- : - 1u ;
585+ : ( unsigned )- 1 ;
571586 bool has_ubo = vertex_ubo || fragment_ubo;
572587
573- if ( (vertex_ubo_binding != - 1u ) &&
574- (fragment_ubo_binding != - 1u ) &&
588+ if ( (vertex_ubo_binding != ( unsigned )- 1 ) &&
589+ (fragment_ubo_binding != ( unsigned )- 1 ) &&
575590 (vertex_ubo_binding != fragment_ubo_binding))
576591 {
577592 RARCH_ERR (" [Slang] Vertex and fragment uniform buffer must have same binding.\n " );
578593 return false ;
579594 }
580595
581- unsigned ubo_binding = (vertex_ubo_binding != - 1u )
596+ unsigned ubo_binding = (vertex_ubo_binding != ( unsigned )- 1 )
582597 ? vertex_ubo_binding
583598 : fragment_ubo_binding;
584599
@@ -696,7 +711,8 @@ bool slang_reflect(
696711 *reflection->texture_semantic_map ,
697712 fragment.sampled_images [i].name , &array_index);
698713
699- if (index == SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT && array_index >= reflection->pass_number )
714+ if (index == SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT &&
715+ array_index >= reflection->pass_number )
700716 {
701717 RARCH_ERR (" [Slang] Non causal filter chain detected. "
702718 " Shader is trying to use output from pass #%u,"
@@ -728,8 +744,10 @@ bool slang_reflect(
728744 for (i = 0 ; i < SLANG_NUM_TEXTURE_SEMANTICS; i++)
729745 {
730746 unsigned index = 0 ;
731- for (auto &sem : reflection->semantic_textures [i])
747+ unsigned j;
748+ for (j = 0 ; j < reflection->semantic_textures [i].size (); j++)
732749 {
750+ const slang_texture_semantic_meta &sem = reflection->semantic_textures [i][j];
733751 if (sem.texture )
734752 RARCH_LOG (" [Slang] %s (#%u)\n " ,
735753 texture_semantic_names[i], index);
@@ -764,8 +782,10 @@ bool slang_reflect(
764782 for (i = 0 ; i < SLANG_NUM_TEXTURE_SEMANTICS; i++)
765783 {
766784 unsigned index = 0 ;
767- for (auto &sem : reflection->semantic_textures [i])
785+ unsigned j;
786+ for (j = 0 ; j < reflection->semantic_textures [i].size (); j++)
768787 {
788+ const slang_texture_semantic_meta &sem = reflection->semantic_textures [i][j];
769789 if (sem.uniform )
770790 {
771791 RARCH_LOG (" [Slang] %s (#%u) (Offset: %u)\n " ,
@@ -789,18 +809,14 @@ bool slang_reflect(
789809
790810 for (i = 0 ; i < reflection->semantic_float_parameters .size (); i++)
791811 {
792- slang_semantic_meta *param = (slang_semantic_meta*)
793- &reflection->semantic_float_parameters [i];
794-
795- if (!param)
796- continue ;
812+ const slang_semantic_meta ¶m = reflection->semantic_float_parameters [i];
797813
798- if (param-> uniform )
814+ if (param. uniform )
799815 RARCH_LOG (" [Slang] #%u (Offset: %u)\n " , i,
800- (unsigned int )param-> ubo_offset );
801- if (param-> push_constant )
816+ (unsigned int )param. ubo_offset );
817+ if (param. push_constant )
802818 RARCH_LOG (" [Slang] #%u (PushOffset: %u)\n " , i,
803- (unsigned int )param-> push_constant_offset );
819+ (unsigned int )param. push_constant_offset );
804820 }
805821#endif
806822
0 commit comments