profiles/mojoshader_profile_spirv.c
changeset 1299 02d36217591b
parent 1278 be0f548f321f
child 1303 7a43f238f28a
equal deleted inserted replaced
1298:b70ccc2c7a51 1299:02d36217591b
  1943 
  1943 
  1944                     // TEX instruction have already been emitted that work with Private variable.
  1944                     // TEX instruction have already been emitted that work with Private variable.
  1945 
  1945 
  1946                     // Overwrite Private variable with Input variable, so emit_SPIRV_finalize outputs
  1946                     // Overwrite Private variable with Input variable, so emit_SPIRV_finalize outputs
  1947                     // OpEntryPoint with correct references to Input and Output variables.
  1947                     // OpEntryPoint with correct references to Input and Output variables.
       
  1948                     ctx->spirv.id_implicit_input[regnum] = id_input_var;
  1948                     r->spirv.iddecl = id_input_var;
  1949                     r->spirv.iddecl = id_input_var;
       
  1950                     spv_output_regname(ctx, id_input_var, regtype, regnum);
  1949                     return;
  1951                     return;
  1950                 } // if
  1952                 } // if
  1951                 tid = spv_get_type(ctx, STI_PTR_VEC4_P);
  1953                 tid = spv_get_type(ctx, STI_PTR_VEC4_P);
  1952             } // else if
  1954             } // else if
  1953             break;
  1955             break;
  2479         model = SpvExecutionModelFragment;
  2481         model = SpvExecutionModelFragment;
  2480 
  2482 
  2481     /* 3 is for opcode + exec. model + idmain */
  2483     /* 3 is for opcode + exec. model + idmain */
  2482     uint32 inoutcount = ctx->spirv.inoutcount;
  2484     uint32 inoutcount = ctx->spirv.inoutcount;
  2483 
  2485 
  2484     if (shader_is_pixel(ctx) && !shader_version_atleast(ctx, 2, 0))
  2486     uint32 implicit_input_count = sizeof(ctx->spirv.id_implicit_input) / sizeof(uint32);
  2485         inoutcount += 1;
  2487     if (shader_is_pixel(ctx))
       
  2488     {
       
  2489         if (!shader_version_atleast(ctx, 1, 4))
       
  2490         {
       
  2491             for (uint32 i = 0; i < implicit_input_count; i++)
       
  2492             {
       
  2493                 if (ctx->spirv.id_implicit_input[i])
       
  2494                     inoutcount += 1;
       
  2495             } // for
       
  2496         } // if
       
  2497 
       
  2498         if (!shader_version_atleast(ctx, 2, 0))
       
  2499             inoutcount += 1;
       
  2500     } // if
  2486 
  2501 
  2487     spv_emit_part(ctx, 3 + spv_strlen(ctx->mainfn) + inoutcount, 3, SpvOpEntryPoint,
  2502     spv_emit_part(ctx, 3 + spv_strlen(ctx->mainfn) + inoutcount, 3, SpvOpEntryPoint,
  2488         model, ctx->spirv.idmain
  2503         model, ctx->spirv.idmain
  2489     );
  2504     );
  2490     spv_emit_str(ctx, ctx->mainfn);
  2505     spv_emit_str(ctx, ctx->mainfn);
  2518     } // while
  2533     } // while
  2519 
  2534 
  2520     // only applies to pixel shaders
  2535     // only applies to pixel shaders
  2521     if (shader_is_pixel(ctx))
  2536     if (shader_is_pixel(ctx))
  2522     {
  2537     {
       
  2538         if (!shader_version_atleast(ctx, 1, 4))
       
  2539         {
       
  2540             for (uint32 i = 0; i < implicit_input_count; i++)
       
  2541             {
       
  2542                 uint32 id = ctx->spirv.id_implicit_input[i];
       
  2543                 if (id)
       
  2544                     spv_emit_word(ctx, id);
       
  2545             } // for
       
  2546         } // if
       
  2547 
  2523         if (!shader_version_atleast(ctx, 2, 0))
  2548         if (!shader_version_atleast(ctx, 2, 0))
  2524         {
  2549         {
  2525             // r0 is used as color output.
  2550             // r0 is used as color output.
  2526             r = spv_getreg(ctx, REG_TYPE_TEMP, 0);
  2551             r = spv_getreg(ctx, REG_TYPE_TEMP, 0);
  2527             spv_emit_word(ctx, r->spirv.iddecl);
  2552             spv_emit_word(ctx, r->spirv.iddecl);