2011-07-07 14:01:40 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2011 Intel Corporation
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
* Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* This file declares stripped-down versions of functions that
|
|
|
|
|
* normally exist outside of the glsl folder, so that they can be used
|
|
|
|
|
* when running the GLSL compiler standalone (for unit testing or
|
|
|
|
|
* compiling builtins).
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "standalone_scaffolding.h"
|
|
|
|
|
|
|
|
|
|
#include <assert.h>
|
2015-03-04 19:17:57 -07:00
|
|
|
#include <stdio.h>
|
2011-07-07 14:01:40 -07:00
|
|
|
#include <string.h>
|
2014-02-24 23:39:14 -08:00
|
|
|
#include "util/ralloc.h"
|
2015-07-03 09:46:01 +02:00
|
|
|
#include "util/strtod.h"
|
2018-04-08 13:13:08 -04:00
|
|
|
#include "main/mtypes.h"
|
2023-02-28 15:37:14 -08:00
|
|
|
#include "string_to_uint_map.h"
|
2011-07-07 14:01:40 -07:00
|
|
|
|
2013-01-16 12:56:34 -08:00
|
|
|
void
|
|
|
|
|
_mesa_warning(struct gl_context *ctx, const char *fmt, ...)
|
|
|
|
|
{
|
|
|
|
|
va_list vargs;
|
|
|
|
|
(void) ctx;
|
|
|
|
|
|
|
|
|
|
va_start(vargs, fmt);
|
|
|
|
|
|
|
|
|
|
/* This output is not thread-safe, but that's good enough for the
|
|
|
|
|
* standalone compiler.
|
|
|
|
|
*/
|
|
|
|
|
fprintf(stderr, "Mesa warning: ");
|
|
|
|
|
vfprintf(stderr, fmt, vargs);
|
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
|
|
|
|
|
|
va_end(vargs);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-03 10:00:14 -06:00
|
|
|
void
|
2023-02-27 15:24:36 +00:00
|
|
|
_mesa_problem(const struct gl_context *ctx, const char *fmt, ...)
|
2019-03-03 10:00:14 -06:00
|
|
|
{
|
|
|
|
|
va_list vargs;
|
|
|
|
|
(void) ctx;
|
|
|
|
|
|
|
|
|
|
va_start(vargs, fmt);
|
|
|
|
|
|
|
|
|
|
/* This output is not thread-safe, but that's good enough for the
|
|
|
|
|
* standalone compiler.
|
|
|
|
|
*/
|
|
|
|
|
fprintf(stderr, "Mesa problem: ");
|
|
|
|
|
vfprintf(stderr, fmt, vargs);
|
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
|
|
|
|
|
|
va_end(vargs);
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-20 21:37:25 +11:00
|
|
|
void
|
2023-02-08 16:48:43 +01:00
|
|
|
_mesa_reference_shader_program_data(struct gl_shader_program_data **ptr,
|
2016-12-20 21:37:25 +11:00
|
|
|
struct gl_shader_program_data *data)
|
|
|
|
|
{
|
|
|
|
|
*ptr = data;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-07 14:01:40 -07:00
|
|
|
void
|
|
|
|
|
_mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr,
|
|
|
|
|
struct gl_shader *sh)
|
|
|
|
|
{
|
2011-08-29 14:56:29 -07:00
|
|
|
(void) ctx;
|
2011-07-07 14:01:40 -07:00
|
|
|
*ptr = sh;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-03 17:04:26 +11:00
|
|
|
void
|
|
|
|
|
_mesa_reference_program_(struct gl_context *ctx, struct gl_program **ptr,
|
|
|
|
|
struct gl_program *prog)
|
|
|
|
|
{
|
|
|
|
|
(void) ctx;
|
|
|
|
|
*ptr = prog;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-02 16:26:05 +00:00
|
|
|
void
|
2015-08-26 13:38:49 +01:00
|
|
|
_mesa_shader_debug(struct gl_context *, GLenum, GLuint *,
|
2015-11-27 13:12:59 +00:00
|
|
|
const char *)
|
2012-04-02 16:26:05 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-07 14:01:40 -07:00
|
|
|
struct gl_shader *
|
2016-06-28 09:41:59 +10:00
|
|
|
_mesa_new_shader(GLuint name, gl_shader_stage stage)
|
2011-07-07 14:01:40 -07:00
|
|
|
{
|
|
|
|
|
struct gl_shader *shader;
|
|
|
|
|
|
2016-06-05 13:17:51 +10:00
|
|
|
assert(stage == MESA_SHADER_FRAGMENT || stage == MESA_SHADER_VERTEX);
|
2011-07-07 14:01:40 -07:00
|
|
|
shader = rzalloc(NULL, struct gl_shader);
|
|
|
|
|
if (shader) {
|
2016-06-05 13:17:51 +10:00
|
|
|
shader->Stage = stage;
|
2011-07-07 14:01:40 -07:00
|
|
|
shader->Name = name;
|
|
|
|
|
shader->RefCount = 1;
|
|
|
|
|
}
|
|
|
|
|
return shader;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-11 17:31:11 -07:00
|
|
|
GLbitfield
|
2017-11-16 04:29:35 +01:00
|
|
|
_mesa_program_state_flags(UNUSED const gl_state_index16 state[STATE_LENGTH])
|
2015-03-11 17:31:11 -07:00
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *
|
2017-11-16 04:29:35 +01:00
|
|
|
_mesa_program_state_string(UNUSED const gl_state_index16 state[STATE_LENGTH])
|
2015-03-11 17:31:11 -07:00
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-27 21:28:22 +02:00
|
|
|
void
|
2017-09-25 18:06:17 -07:00
|
|
|
_mesa_delete_shader(struct gl_context *, struct gl_shader *sh)
|
2015-09-27 21:28:22 +02:00
|
|
|
{
|
|
|
|
|
free((void *)sh->Source);
|
|
|
|
|
free(sh->Label);
|
|
|
|
|
ralloc_free(sh);
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-30 14:55:40 +10:00
|
|
|
void
|
2017-09-25 18:06:17 -07:00
|
|
|
_mesa_delete_linked_shader(struct gl_context *,
|
2016-06-30 14:55:40 +10:00
|
|
|
struct gl_linked_shader *sh)
|
|
|
|
|
{
|
2024-06-05 15:42:07 +10:00
|
|
|
ralloc_free(sh->Program->nir);
|
2020-12-04 15:17:51 -08:00
|
|
|
ralloc_free(sh->Program);
|
2016-06-30 14:55:40 +10:00
|
|
|
ralloc_free(sh);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-20 14:40:34 -07:00
|
|
|
void
|
2016-11-02 09:49:58 +11:00
|
|
|
_mesa_clear_shader_program_data(struct gl_context *ctx,
|
|
|
|
|
struct gl_shader_program *shProg)
|
2014-10-20 14:40:34 -07:00
|
|
|
{
|
2016-11-02 09:49:58 +11:00
|
|
|
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
|
|
|
|
|
if (shProg->_LinkedShaders[i] != NULL) {
|
|
|
|
|
_mesa_delete_linked_shader(ctx, shProg->_LinkedShaders[i]);
|
|
|
|
|
shProg->_LinkedShaders[i] = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-07 14:47:18 +11:00
|
|
|
shProg->data->NumUniformStorage = 0;
|
|
|
|
|
shProg->data->UniformStorage = NULL;
|
2014-10-20 14:40:34 -07:00
|
|
|
shProg->NumUniformRemapTable = 0;
|
|
|
|
|
shProg->UniformRemapTable = NULL;
|
|
|
|
|
|
2016-11-07 14:47:18 +11:00
|
|
|
ralloc_free(shProg->data->InfoLog);
|
|
|
|
|
shProg->data->InfoLog = ralloc_strdup(shProg->data, "");
|
2014-10-20 14:40:34 -07:00
|
|
|
|
2016-11-07 14:47:18 +11:00
|
|
|
ralloc_free(shProg->data->UniformBlocks);
|
|
|
|
|
shProg->data->UniformBlocks = NULL;
|
|
|
|
|
shProg->data->NumUniformBlocks = 0;
|
2015-10-01 10:17:30 +02:00
|
|
|
|
2016-11-07 14:47:18 +11:00
|
|
|
ralloc_free(shProg->data->ShaderStorageBlocks);
|
|
|
|
|
shProg->data->ShaderStorageBlocks = NULL;
|
|
|
|
|
shProg->data->NumShaderStorageBlocks = 0;
|
2015-10-01 10:17:30 +02:00
|
|
|
|
2016-11-07 14:47:18 +11:00
|
|
|
ralloc_free(shProg->data->AtomicBuffers);
|
|
|
|
|
shProg->data->AtomicBuffers = NULL;
|
|
|
|
|
shProg->data->NumAtomicBuffers = 0;
|
2014-10-20 14:40:34 -07:00
|
|
|
}
|
|
|
|
|
|
2023-02-28 16:12:33 -08:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
init_gl_program(struct gl_program *prog, bool is_arb_asm, gl_shader_stage stage)
|
|
|
|
|
{
|
|
|
|
|
prog->RefCount = 1;
|
|
|
|
|
prog->Format = GL_PROGRAM_FORMAT_ASCII_ARB;
|
|
|
|
|
prog->info.use_legacy_math_rules = is_arb_asm;
|
|
|
|
|
prog->info.stage = stage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct gl_program *
|
|
|
|
|
standalone_new_program(UNUSED struct gl_context *ctx, gl_shader_stage stage,
|
|
|
|
|
UNUSED GLuint id, bool is_arb_asm)
|
|
|
|
|
{
|
|
|
|
|
struct gl_program *prog = rzalloc(NULL, struct gl_program);
|
|
|
|
|
init_gl_program(prog, is_arb_asm, stage);
|
|
|
|
|
return prog;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-07 14:01:40 -07:00
|
|
|
void initialize_context_to_defaults(struct gl_context *ctx, gl_api api)
|
|
|
|
|
{
|
|
|
|
|
memset(ctx, 0, sizeof(*ctx));
|
|
|
|
|
|
|
|
|
|
ctx->API = api;
|
|
|
|
|
|
2011-08-24 13:01:18 -07:00
|
|
|
ctx->Extensions.dummy_true = true;
|
2014-01-06 09:09:07 -08:00
|
|
|
ctx->Extensions.ARB_compute_shader = true;
|
2016-09-07 18:05:52 +02:00
|
|
|
ctx->Extensions.ARB_compute_variable_group_size = true;
|
2013-09-11 18:08:23 -05:00
|
|
|
ctx->Extensions.ARB_conservative_depth = true;
|
2013-09-11 17:53:06 -05:00
|
|
|
ctx->Extensions.ARB_draw_instanced = true;
|
2011-07-07 14:01:40 -07:00
|
|
|
ctx->Extensions.ARB_ES2_compatibility = true;
|
2013-09-11 18:08:23 -05:00
|
|
|
ctx->Extensions.ARB_ES3_compatibility = true;
|
|
|
|
|
ctx->Extensions.ARB_explicit_attrib_location = true;
|
2011-07-07 14:01:40 -07:00
|
|
|
ctx->Extensions.ARB_fragment_coord_conventions = true;
|
2014-01-25 18:24:18 +13:00
|
|
|
ctx->Extensions.ARB_fragment_layer_viewport = true;
|
2013-09-11 17:53:06 -05:00
|
|
|
ctx->Extensions.ARB_gpu_shader5 = true;
|
2014-06-11 13:36:12 +10:00
|
|
|
ctx->Extensions.ARB_gpu_shader_fp64 = true;
|
2016-09-15 11:21:28 -07:00
|
|
|
ctx->Extensions.ARB_gpu_shader_int64 = true;
|
2013-08-30 12:34:36 -07:00
|
|
|
ctx->Extensions.ARB_sample_shading = true;
|
2012-04-30 13:19:01 +02:00
|
|
|
ctx->Extensions.ARB_shader_bit_encoding = true;
|
2015-12-10 12:07:43 -08:00
|
|
|
ctx->Extensions.ARB_shader_draw_parameters = true;
|
2013-09-11 18:08:23 -05:00
|
|
|
ctx->Extensions.ARB_shader_stencil_export = true;
|
|
|
|
|
ctx->Extensions.ARB_shader_texture_lod = true;
|
|
|
|
|
ctx->Extensions.ARB_shading_language_420pack = true;
|
2014-03-20 22:34:42 +01:00
|
|
|
ctx->Extensions.ARB_tessellation_shader = true;
|
2012-11-03 20:43:17 +10:00
|
|
|
ctx->Extensions.ARB_texture_cube_map_array = true;
|
2013-09-11 17:53:06 -05:00
|
|
|
ctx->Extensions.ARB_texture_gather = true;
|
2012-12-21 21:33:37 +13:00
|
|
|
ctx->Extensions.ARB_texture_multisample = true;
|
2013-09-26 19:37:30 +12:00
|
|
|
ctx->Extensions.ARB_texture_query_levels = true;
|
2012-09-23 19:50:41 +10:00
|
|
|
ctx->Extensions.ARB_texture_query_lod = true;
|
2013-09-11 18:08:23 -05:00
|
|
|
ctx->Extensions.ARB_uniform_buffer_object = true;
|
2014-01-08 08:32:03 -08:00
|
|
|
ctx->Extensions.ARB_viewport_array = true;
|
2016-05-08 22:44:06 +02:00
|
|
|
ctx->Extensions.ARB_cull_distance = true;
|
2017-03-21 12:42:47 +01:00
|
|
|
ctx->Extensions.ARB_bindless_texture = true;
|
2013-09-11 17:53:06 -05:00
|
|
|
|
|
|
|
|
ctx->Extensions.OES_EGL_image_external = true;
|
|
|
|
|
ctx->Extensions.OES_standard_derivatives = true;
|
2022-06-28 21:57:14 -07:00
|
|
|
ctx->Extensions.OES_texture_3D = true;
|
2013-09-11 17:53:06 -05:00
|
|
|
|
2013-07-18 21:44:58 +12:00
|
|
|
ctx->Extensions.EXT_gpu_shader4 = true;
|
2013-09-11 18:08:23 -05:00
|
|
|
ctx->Extensions.EXT_shader_integer_mix = true;
|
2019-11-14 12:37:01 -05:00
|
|
|
ctx->Extensions.EXT_shadow_samplers = true;
|
2013-09-11 17:53:06 -05:00
|
|
|
ctx->Extensions.EXT_texture_array = true;
|
|
|
|
|
|
2016-06-20 16:35:32 -07:00
|
|
|
ctx->Extensions.MESA_shader_integer_functions = true;
|
|
|
|
|
|
2013-09-11 17:53:06 -05:00
|
|
|
ctx->Extensions.NV_texture_rectangle = true;
|
2011-07-07 14:01:40 -07:00
|
|
|
|
|
|
|
|
ctx->Const.GLSLVersion = 120;
|
|
|
|
|
|
|
|
|
|
/* 1.20 minimums. */
|
|
|
|
|
ctx->Const.MaxLights = 8;
|
|
|
|
|
ctx->Const.MaxClipPlanes = 6;
|
|
|
|
|
ctx->Const.MaxTextureUnits = 2;
|
|
|
|
|
ctx->Const.MaxTextureCoordUnits = 2;
|
2014-01-08 10:00:28 -08:00
|
|
|
ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs = 16;
|
2011-07-07 14:01:40 -07:00
|
|
|
|
2014-01-08 10:00:28 -08:00
|
|
|
ctx->Const.Program[MESA_SHADER_VERTEX].MaxUniformComponents = 512;
|
|
|
|
|
ctx->Const.Program[MESA_SHADER_VERTEX].MaxOutputComponents = 32;
|
2011-07-07 14:01:40 -07:00
|
|
|
ctx->Const.MaxVarying = 8; /* == gl_MaxVaryingFloats / 4 */
|
2014-01-08 10:00:28 -08:00
|
|
|
ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits = 0;
|
2011-07-07 14:01:40 -07:00
|
|
|
ctx->Const.MaxCombinedTextureImageUnits = 2;
|
2014-01-08 10:00:28 -08:00
|
|
|
ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits = 2;
|
|
|
|
|
ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxUniformComponents = 64;
|
|
|
|
|
ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxInputComponents = 32;
|
2011-07-07 14:01:40 -07:00
|
|
|
|
|
|
|
|
ctx->Const.MaxDrawBuffers = 1;
|
2014-01-08 01:42:58 -08:00
|
|
|
ctx->Const.MaxComputeWorkGroupCount[0] = 65535;
|
|
|
|
|
ctx->Const.MaxComputeWorkGroupCount[1] = 65535;
|
|
|
|
|
ctx->Const.MaxComputeWorkGroupCount[2] = 65535;
|
2014-01-06 13:31:58 -08:00
|
|
|
ctx->Const.MaxComputeWorkGroupSize[0] = 1024;
|
|
|
|
|
ctx->Const.MaxComputeWorkGroupSize[1] = 1024;
|
|
|
|
|
ctx->Const.MaxComputeWorkGroupSize[2] = 64;
|
2014-01-06 15:11:40 -08:00
|
|
|
ctx->Const.MaxComputeWorkGroupInvocations = 1024;
|
2016-09-07 18:05:52 +02:00
|
|
|
ctx->Const.MaxComputeVariableGroupSize[0] = 512;
|
|
|
|
|
ctx->Const.MaxComputeVariableGroupSize[1] = 512;
|
|
|
|
|
ctx->Const.MaxComputeVariableGroupSize[2] = 64;
|
|
|
|
|
ctx->Const.MaxComputeVariableGroupInvocations = 512;
|
2014-01-06 20:06:05 -08:00
|
|
|
ctx->Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits = 16;
|
|
|
|
|
ctx->Const.Program[MESA_SHADER_COMPUTE].MaxUniformComponents = 1024;
|
|
|
|
|
ctx->Const.Program[MESA_SHADER_COMPUTE].MaxInputComponents = 0; /* not used */
|
|
|
|
|
ctx->Const.Program[MESA_SHADER_COMPUTE].MaxOutputComponents = 0; /* not used */
|
2013-04-17 17:30:21 -07:00
|
|
|
|
|
|
|
|
/* Set up default shader compiler options. */
|
|
|
|
|
struct gl_shader_compiler_options options;
|
|
|
|
|
memset(&options, 0, sizeof(options));
|
|
|
|
|
options.MaxIfDepth = UINT_MAX;
|
|
|
|
|
|
2014-01-07 10:11:39 -08:00
|
|
|
for (int sh = 0; sh < MESA_SHADER_STAGES; ++sh)
|
2014-08-03 04:31:56 +02:00
|
|
|
memcpy(&ctx->Const.ShaderCompilerOptions[sh], &options, sizeof(options));
|
2015-07-03 09:46:01 +02:00
|
|
|
|
2023-02-28 16:12:33 -08:00
|
|
|
ctx->Driver.NewProgram = standalone_new_program;
|
2011-07-07 14:01:40 -07:00
|
|
|
}
|
2023-02-28 15:37:14 -08:00
|
|
|
|
|
|
|
|
struct gl_shader_program *
|
|
|
|
|
standalone_create_shader_program(void)
|
|
|
|
|
{
|
|
|
|
|
struct gl_shader_program *whole_program;
|
|
|
|
|
|
|
|
|
|
whole_program = rzalloc (NULL, struct gl_shader_program);
|
|
|
|
|
assert(whole_program != NULL);
|
|
|
|
|
whole_program->data = rzalloc(whole_program, struct gl_shader_program_data);
|
|
|
|
|
assert(whole_program->data != NULL);
|
|
|
|
|
whole_program->data->InfoLog = ralloc_strdup(whole_program->data, "");
|
|
|
|
|
|
|
|
|
|
/* Created just to avoid segmentation faults */
|
|
|
|
|
whole_program->AttributeBindings = new string_to_uint_map;
|
|
|
|
|
whole_program->FragDataBindings = new string_to_uint_map;
|
|
|
|
|
whole_program->FragDataIndexBindings = new string_to_uint_map;
|
|
|
|
|
|
2024-07-04 13:22:41 +10:00
|
|
|
exec_list_make_empty(&whole_program->EmptyUniformLocations);
|
|
|
|
|
|
2023-02-28 15:37:14 -08:00
|
|
|
return whole_program;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
standalone_destroy_shader_program(struct gl_shader_program *whole_program)
|
|
|
|
|
{
|
2024-06-05 15:42:07 +10:00
|
|
|
for (unsigned i = 0; i < whole_program->NumShaders; i++) {
|
|
|
|
|
ralloc_free(whole_program->Shaders[i]->nir);
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-28 15:37:14 -08:00
|
|
|
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
|
2024-06-05 15:42:07 +10:00
|
|
|
if (whole_program->_LinkedShaders[i]) {
|
|
|
|
|
if (whole_program->_LinkedShaders[i]->Program->Parameters)
|
|
|
|
|
_mesa_free_parameter_list(whole_program->_LinkedShaders[i]->Program->Parameters);
|
2023-02-28 15:37:14 -08:00
|
|
|
_mesa_delete_linked_shader(NULL, whole_program->_LinkedShaders[i]);
|
2024-06-05 15:42:07 +10:00
|
|
|
}
|
2023-02-28 15:37:14 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete whole_program->AttributeBindings;
|
|
|
|
|
delete whole_program->FragDataBindings;
|
|
|
|
|
delete whole_program->FragDataIndexBindings;
|
|
|
|
|
|
|
|
|
|
ralloc_free(whole_program);
|
|
|
|
|
}
|
2023-02-28 16:04:56 -08:00
|
|
|
|
|
|
|
|
struct gl_shader *
|
|
|
|
|
standalone_add_shader_source(struct gl_context *ctx, struct gl_shader_program *whole_program, GLenum type, const char *source)
|
|
|
|
|
{
|
2024-09-17 10:01:56 +10:00
|
|
|
blake3_hash source_blake3;
|
|
|
|
|
_mesa_blake3_compute(source, strlen(source), source_blake3);
|
|
|
|
|
|
2023-02-28 16:04:56 -08:00
|
|
|
struct gl_shader *shader = rzalloc(whole_program, gl_shader);
|
|
|
|
|
shader->Type = type;
|
|
|
|
|
shader->Stage = _mesa_shader_enum_to_shader_stage(type);
|
|
|
|
|
shader->Source = source;
|
2024-09-17 10:01:56 +10:00
|
|
|
memcpy(shader->source_blake3, source_blake3, BLAKE3_OUT_LEN);
|
2023-02-28 16:04:56 -08:00
|
|
|
|
|
|
|
|
whole_program->Shaders = reralloc(whole_program, whole_program->Shaders,
|
|
|
|
|
struct gl_shader *, whole_program->NumShaders + 1);
|
|
|
|
|
assert(whole_program->Shaders != NULL);
|
|
|
|
|
|
|
|
|
|
whole_program->Shaders[whole_program->NumShaders] = shader;
|
|
|
|
|
whole_program->NumShaders++;
|
|
|
|
|
|
|
|
|
|
return shader;
|
|
|
|
|
}
|