mesa/st: refactor program translation into one file.

This moves the notify callback into the file where it's all called
from.

Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14700>
This commit is contained in:
Dave Airlie 2022-01-25 13:39:02 +10:00 committed by Marge Bot
parent 8dfe3c83b6
commit 9b961b9d1d
13 changed files with 51 additions and 170 deletions

View file

@ -43,7 +43,7 @@
#include "program/prog_print.h"
#include "api_exec_decl.h"
#include "state_tracker/st_cb_program.h"
#include "state_tracker/st_program.h"
static void
flush_vertices_for_program_constants(struct gl_context *ctx, GLenum target)

View file

@ -34,7 +34,7 @@
#include "util/u_memory.h"
#include "api_exec_decl.h"
#include "state_tracker/st_cb_program.h"
#include "state_tracker/st_program.h"
#define MESA_DEBUG_ATI_FS 0

View file

@ -47,7 +47,7 @@
#include "program/prog_statevars.h"
#include "util/bitscan.h"
#include "state_tracker/st_cb_program.h"
#include "state_tracker/st_program.h"
/** Max of number of lights and texture coord units */
#define NUM_UNITS MAX2(MAX_TEXTURE_COORD_UNITS, MAX_LIGHTS)

View file

@ -34,8 +34,6 @@
#include "util/u_atomic.h"
#include "api_exec_decl.h"
#include "state_tracker/st_cb_program.h"
void
_mesa_spirv_module_reference(struct gl_spirv_module **dest,
struct gl_spirv_module *src)

View file

@ -30,7 +30,6 @@
#include "hint.h"
#include "mtypes.h"
#include "state_tracker/st_cb_program.h"
#include "api_exec_decl.h"
#include "pipe/p_screen.h"

View file

@ -67,7 +67,6 @@
#include "util/u_string.h"
#include "api_exec_decl.h"
#include "state_tracker/st_cb_program.h"
#include "state_tracker/st_context.h"
#include "state_tracker/st_program.h"

View file

@ -338,8 +338,6 @@ files_libmesa = files(
'state_tracker/st_cb_feedback.h',
'state_tracker/st_cb_flush.c',
'state_tracker/st_cb_flush.h',
'state_tracker/st_cb_program.c',
'state_tracker/st_cb_program.h',
'state_tracker/st_cb_rasterpos.c',
'state_tracker/st_cb_rasterpos.h',
'state_tracker/st_cb_readpixels.c',

View file

@ -1,97 +0,0 @@
/**************************************************************************
*
* Copyright 2003 VMware, Inc.
* All Rights Reserved.
*
* 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, sub license, 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 NON-INFRINGEMENT.
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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.
*
**************************************************************************/
/*
* Authors:
* Keith Whitwell <keithw@vmware.com>
*/
#include "main/glheader.h"
#include "main/macros.h"
#include "main/enums.h"
#include "main/shaderapi.h"
#include "program/prog_instruction.h"
#include "program/program.h"
#include "cso_cache/cso_context.h"
#include "draw/draw_context.h"
#include "st_context.h"
#include "st_debug.h"
#include "st_program.h"
#include "st_cb_program.h"
#include "st_glsl_to_ir.h"
#include "st_atifs_to_nir.h"
#include "st_util.h"
/**
* Called when the program's text/code is changed. We have to free
* all shader variants and corresponding gallium shaders when this happens.
*/
GLboolean
st_program_string_notify( struct gl_context *ctx,
GLenum target,
struct gl_program *prog )
{
struct st_context *st = st_context(ctx);
/* GLSL-to-NIR should not end up here. */
assert(!prog->shader_program);
st_release_variants(st, prog);
if (target == GL_FRAGMENT_PROGRAM_ARB ||
target == GL_FRAGMENT_SHADER_ATI) {
if (target == GL_FRAGMENT_SHADER_ATI) {
assert(prog->ati_fs);
assert(prog->ati_fs->Program == prog);
st_init_atifs_prog(ctx, prog);
}
if (!st_translate_fragment_program(st, prog))
return false;
} else if (target == GL_VERTEX_PROGRAM_ARB) {
if (!st_translate_vertex_program(st, prog))
return false;
} else {
if (!st_translate_common_program(st, prog))
return false;
}
st_finalize_program(st, prog);
return GL_TRUE;
}
/**
* Plug in the program and shader-related device driver functions.
*/
void
st_init_program_functions(struct dd_function_table *functions)
{
functions->NewProgram = _mesa_new_program;
}

View file

@ -1,46 +0,0 @@
/**************************************************************************
*
* Copyright 2008 VMware, Inc.
* All Rights Reserved.
*
* 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, sub license, 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 NON-INFRINGEMENT.
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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.
*
**************************************************************************/
#ifndef ST_CB_PROGRAM_H
#define ST_CB_PROGRAM_H
#ifdef __cplusplus
extern "C" {
#endif
struct dd_function_table;
extern void
st_init_program_functions(struct dd_function_table *functions);
GLboolean st_program_string_notify(struct gl_context *ctx,
GLenum target,
struct gl_program *prog);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -47,7 +47,6 @@
#include "st_cb_drawtex.h"
#include "st_cb_eglimage.h"
#include "st_cb_feedback.h"
#include "st_cb_program.h"
#include "st_cb_flush.h"
#include "st_atom.h"
#include "st_draw.h"
@ -812,7 +811,7 @@ st_init_driver_functions(struct pipe_screen *screen,
st_init_eglimage_functions(functions, has_egl_image_validate);
st_init_program_functions(functions);
functions->NewProgram = _mesa_new_program;
st_init_flush_functions(screen, functions);
/* GL_ARB_get_program_binary */

View file

@ -31,7 +31,7 @@
*/
#include "st_glsl_to_tgsi.h"
#include "st_cb_program.h"
#include "st_program.h"
#include "compiler/glsl/glsl_parser_extras.h"
#include "compiler/glsl/ir_optimization.h"

View file

@ -577,7 +577,7 @@ st_create_nir_shader(struct st_context *st, struct pipe_shader_state *state)
/**
* Translate a vertex program.
*/
bool
static bool
st_translate_vertex_program(struct st_context *st,
struct gl_program *prog)
{
@ -994,7 +994,7 @@ st_get_common_variant(struct st_context *st,
/**
* Translate a Mesa fragment shader into a TGSI shader.
*/
bool
static bool
st_translate_fragment_program(struct st_context *st,
struct gl_program *fp)
{
@ -1685,7 +1685,7 @@ st_get_fp_variant(struct st_context *st,
* Translate a program. This is common code for geometry and tessellation
* shaders.
*/
bool
static bool
st_translate_common_program(struct st_context *st,
struct gl_program *prog)
{
@ -2052,3 +2052,42 @@ st_finalize_program(struct st_context *st, struct gl_program *prog)
/* Always create the default variant of the program. */
st_precompile_shader_variant(st, prog);
}
/**
* Called when the program's text/code is changed. We have to free
* all shader variants and corresponding gallium shaders when this happens.
*/
GLboolean
st_program_string_notify( struct gl_context *ctx,
GLenum target,
struct gl_program *prog )
{
struct st_context *st = st_context(ctx);
/* GLSL-to-NIR should not end up here. */
assert(!prog->shader_program);
st_release_variants(st, prog);
if (target == GL_FRAGMENT_PROGRAM_ARB ||
target == GL_FRAGMENT_SHADER_ATI) {
if (target == GL_FRAGMENT_SHADER_ATI) {
assert(prog->ati_fs);
assert(prog->ati_fs->Program == prog);
st_init_atifs_prog(ctx, prog);
}
if (!st_translate_fragment_program(st, prog))
return false;
} else if (target == GL_VERTEX_PROGRAM_ARB) {
if (!st_translate_vertex_program(st, prog))
return false;
} else {
if (!st_translate_common_program(st, prog))
return false;
}
st_finalize_program(st, prog);
return GL_TRUE;
}

View file

@ -301,18 +301,6 @@ st_prepare_vertex_program(struct gl_program *stvp, uint8_t *attrib_to_index);
extern void
st_translate_stream_output_info(struct gl_program *prog);
extern bool
st_translate_vertex_program(struct st_context *st,
struct gl_program *stvp);
extern bool
st_translate_fragment_program(struct st_context *st,
struct gl_program *stfp);
extern bool
st_translate_common_program(struct st_context *st,
struct gl_program *stp);
extern void
st_serialize_nir(struct gl_program *stp);
@ -322,6 +310,10 @@ st_finalize_program(struct st_context *st, struct gl_program *prog);
struct pipe_shader_state *
st_create_nir_shader(struct st_context *st, struct pipe_shader_state *state);
GLboolean st_program_string_notify(struct gl_context *ctx,
GLenum target,
struct gl_program *prog);
#ifdef __cplusplus
}
#endif