profiles/mojoshader_profile_spirv.c
changeset 1278 be0f548f321f
parent 1277 da61410edbc9
child 1299 02d36217591b
equal deleted inserted replaced
1277:da61410edbc9 1278:be0f548f321f
   269     spv_emit(ctx, 4, SpvOpDecorate, id, SpvDecorationLocation, loc);
   269     spv_emit(ctx, 4, SpvOpDecorate, id, SpvDecorationLocation, loc);
   270     pop_output(ctx);
   270     pop_output(ctx);
   271     return (buffer_size(ctx->helpers) >> 2) - 1;
   271     return (buffer_size(ctx->helpers) >> 2) - 1;
   272 } // spv_output_location
   272 } // spv_output_location
   273 
   273 
   274 static uint32 spv_output_attrib_location(Context *ctx, uint32 id,
   274 static void spv_output_attrib_location(Context *ctx, uint32 id,
   275                                          MOJOSHADER_usage usage, uint32 index)
   275                                        MOJOSHADER_usage usage, uint32 index)
   276 {
   276 {
   277     uint32 result;
       
   278     SpirvPatchTable* table = &ctx->spirv.patch_table;
   277     SpirvPatchTable* table = &ctx->spirv.patch_table;
   279     push_output(ctx, &ctx->helpers);
   278     push_output(ctx, &ctx->helpers);
   280     spv_emit(ctx, 4, SpvOpDecorate, id, SpvDecorationLocation, 0xDEADBEEF);
   279     spv_emit(ctx, 4, SpvOpDecorate, id, SpvDecorationLocation, 0xDEADBEEF);
   281     pop_output(ctx);
   280     pop_output(ctx);
   282     result = (buffer_size(ctx->helpers) >> 2) - 1;
   281     table->attrib_offsets[usage][index] = (buffer_size(ctx->helpers) >> 2) - 1;
   283     table->attrib_offsets[usage][index] = result;
       
   284     return result;
       
   285 } // spv_output_attrib_location
   282 } // spv_output_attrib_location
   286 
   283 
   287 static void spv_output_sampler_binding(Context *ctx, uint32 id, uint32 binding)
   284 static void spv_output_sampler_binding(Context *ctx, uint32 id, uint32 binding)
   288 {
   285 {
   289     if (isfail(ctx))
   286     if (isfail(ctx))
  1629                                    MOJOSHADER_usage usage, int index)
  1626                                    MOJOSHADER_usage usage, int index)
  1630 {
  1627 {
  1631     if (usage == MOJOSHADER_USAGE_POSITION && index == 0)
  1628     if (usage == MOJOSHADER_USAGE_POSITION && index == 0)
  1632         spv_output_builtin(ctx, id, SpvBuiltInPosition);
  1629         spv_output_builtin(ctx, id, SpvBuiltInPosition);
  1633     else if (usage == MOJOSHADER_USAGE_POINTSIZE && index == 0)
  1630     else if (usage == MOJOSHADER_USAGE_POINTSIZE && index == 0)
       
  1631     {
  1634         spv_output_builtin(ctx, id, SpvBuiltInPointSize);
  1632         spv_output_builtin(ctx, id, SpvBuiltInPointSize);
       
  1633         ctx->spirv.patch_table.attrib_offsets[usage][index] = 1;
       
  1634     } // else if
  1635     else if (usage == MOJOSHADER_USAGE_COLOR && index == 0)
  1635     else if (usage == MOJOSHADER_USAGE_COLOR && index == 0)
  1636         spv_output_location(ctx, id, 0);
  1636         spv_output_location(ctx, id, 0);
  1637     else
  1637     else
  1638         spv_output_attrib_location(ctx, id, usage, index);
  1638         spv_output_attrib_location(ctx, id, usage, index);
  1639 } // spv_link_vs_attributes
  1639 } // spv_link_vs_attributes