74
74
struct gl_spirv_module *module;
75
75
struct gl_shader_spirv_data *spirv_data;
77
/* From OpenGL 4.6 Core spec, "7.2 Shader Binaries" :
79
* "An INVALID_VALUE error is generated if the data pointed to by binary
80
* does not match the specified binaryformat."
82
* However, the ARB_gl_spirv spec, under issue #16 says:
84
* "ShaderBinary is expected to form an association between the SPIR-V
85
* module and likely would not parse the module as would be required to
86
* detect unsupported capabilities or other validation failures."
88
* Which specifies little to no validation requirements. Nevertheless, the
89
* two small checks below seem reasonable.
91
if (!binary || (length % 4) != 0) {
92
_mesa_error(ctx, GL_INVALID_VALUE, "glShaderBinary");
77
96
module = malloc(sizeof(*module) + length);
79
98
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glShaderBinary");
384
402
spec_entries[i].defined_on_module = false;
388
gl_spirv_validation((uint32_t *)&spirv_data->SpirVModule->Binary[0],
389
spirv_data->SpirVModule->Length / 4,
390
spec_entries, numSpecializationConstants,
391
sh->Stage, pEntryPoint);
393
/* See previous spec comment */
394
if (!has_entry_point) {
395
_mesa_error(ctx, GL_INVALID_VALUE,
396
"glSpecializeShaderARB(\"%s\" is not a valid entry point"
397
" for shader)", pEntryPoint);
401
for (unsigned i = 0; i < numSpecializationConstants; ++i) {
402
if (spec_entries[i].defined_on_module == false) {
403
_mesa_error(ctx, GL_INVALID_VALUE,
404
"glSpecializeShaderARB(constant \"%i\" does not exist "
405
"in shader)", spec_entries[i].id);
405
enum spirv_verify_result r = spirv_verify_gl_specialization_constants(
406
(uint32_t *)&spirv_data->SpirVModule->Binary[0],
407
spirv_data->SpirVModule->Length / 4,
408
spec_entries, numSpecializationConstants,
409
sh->Stage, pEntryPoint);
412
case SPIRV_VERIFY_OK:
414
case SPIRV_VERIFY_PARSER_ERROR:
415
_mesa_error(ctx, GL_INVALID_VALUE,
416
"glSpecializeShaderARB(failed to parse entry point \"%s\""
417
" for shader)", pEntryPoint);
419
case SPIRV_VERIFY_ENTRY_POINT_NOT_FOUND:
420
_mesa_error(ctx, GL_INVALID_VALUE,
421
"glSpecializeShaderARB(could not find entry point \"%s\""
422
" for shader)", pEntryPoint);
424
case SPIRV_VERIFY_UNKNOWN_SPEC_INDEX:
425
for (unsigned i = 0; i < numSpecializationConstants; ++i) {
426
if (spec_entries[i].defined_on_module == false) {
427
_mesa_error(ctx, GL_INVALID_VALUE,
428
"glSpecializeShaderARB(constant \"%i\" does not exist "
429
"in shader)", spec_entries[i].id);
410
436
spirv_data->SpirVEntryPoint = ralloc_strdup(spirv_data, pEntryPoint);