gallium,glsl: Delete PIPE_CAP_VERTEXID_NOBASE and lower_vertex_id.

Every driver uses the nir_lower_system_values path now.

Reviewed-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18327>
This commit is contained in:
Emma Anholt
2022-08-30 12:14:01 -07:00
committed by Marge Bot
parent 4bdd226ab6
commit 5f66a927ec
14 changed files with 1 additions and 183 deletions

View File

@@ -276,13 +276,6 @@ The integer capabilities:
* ``PIPE_CAP_CLIP_HALFZ``: Whether the driver supports the
pipe_rasterizer_state::clip_halfz being set to true. This is required
for enabling ARB_clip_control.
* ``PIPE_CAP_VERTEXID_NOBASE``: If true, the driver only supports
TGSI_SEMANTIC_VERTEXID_NOBASE (and not TGSI_SEMANTIC_VERTEXID). This means
gallium frontends for APIs whose vertexIDs are offset by basevertex (such as GL)
will need to lower TGSI_SEMANTIC_VERTEXID to TGSI_SEMANTIC_VERTEXID_NOBASE
and TGSI_SEMANTIC_BASEVERTEX, so drivers setting this must handle both these
semantics. Only relevant if geometry shaders are supported.
(BASEVERTEX could be exposed separately too via ``PIPE_CAP_DRAW_PARAMETERS``).
* ``PIPE_CAP_POLYGON_OFFSET_CLAMP``: If true, the driver implements support
for ``pipe_rasterizer_state::offset_clamp``.
* ``PIPE_CAP_MULTISAMPLE_Z_RESOLVE``: Whether the driver supports blitting

View File

@@ -122,7 +122,6 @@ void optimize_dead_builtin_variables(exec_list *instructions,
enum ir_variable_mode other);
bool lower_tess_level(gl_linked_shader *shader);
bool lower_vertex_id(gl_linked_shader *shader);
bool lower_cs_derived(gl_linked_shader *shader);
bool lower_blend_equation_advanced(gl_linked_shader *shader, bool coherent);

View File

@@ -2544,9 +2544,6 @@ link_intrastage_shaders(void *mem_ctx,
}
}
if (ctx->Const.VertexID_is_zero_based)
lower_vertex_id(linked);
if (ctx->Const.LowerCsDerivedVariables)
lower_cs_derived(linked);

View File

@@ -1,146 +0,0 @@
/*
* Copyright © 2014 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.
*/
/**
* \file lower_vertex_id.cpp
*
* There exists hardware, such as i965, that does not implement the OpenGL
* semantic for gl_VertexID. Instead, that hardware does not include the
* value of basevertex in the gl_VertexID value. To implement the OpenGL
* semantic, we'll have to convert gl_Vertex_ID to
* gl_VertexIDMESA+gl_BaseVertexMESA.
*/
#include "glsl_symbol_table.h"
#include "ir_hierarchical_visitor.h"
#include "ir.h"
#include "ir_builder.h"
#include "linker.h"
#include "program/prog_statevars.h"
#include "builtin_functions.h"
#include "main/shader_types.h"
namespace {
class lower_vertex_id_visitor : public ir_hierarchical_visitor {
public:
explicit lower_vertex_id_visitor(ir_function_signature *main_sig,
exec_list *ir_list)
: progress(false), VertexID(NULL), gl_VertexID(NULL),
gl_BaseVertex(NULL), main_sig(main_sig), ir_list(ir_list)
{
foreach_in_list(ir_instruction, ir, ir_list) {
ir_variable *const var = ir->as_variable();
if (var != NULL && var->data.mode == ir_var_system_value &&
var->data.location == SYSTEM_VALUE_BASE_VERTEX) {
gl_BaseVertex = var;
break;
}
}
}
virtual ir_visitor_status visit(ir_dereference_variable *);
bool progress;
private:
ir_variable *VertexID;
ir_variable *gl_VertexID;
ir_variable *gl_BaseVertex;
ir_function_signature *main_sig;
exec_list *ir_list;
};
} /* anonymous namespace */
ir_visitor_status
lower_vertex_id_visitor::visit(ir_dereference_variable *ir)
{
if (ir->var->data.mode != ir_var_system_value ||
ir->var->data.location != SYSTEM_VALUE_VERTEX_ID)
return visit_continue;
if (VertexID == NULL) {
const glsl_type *const int_t = glsl_type::int_type;
void *const mem_ctx = ralloc_parent(ir);
VertexID = new(mem_ctx) ir_variable(int_t, "__VertexID",
ir_var_temporary);
ir_list->push_head(VertexID);
gl_VertexID = new(mem_ctx) ir_variable(int_t, "gl_VertexIDMESA",
ir_var_system_value);
gl_VertexID->data.how_declared = ir_var_declared_implicitly;
gl_VertexID->data.read_only = true;
gl_VertexID->data.location = SYSTEM_VALUE_VERTEX_ID_ZERO_BASE;
gl_VertexID->data.explicit_location = true;
gl_VertexID->data.explicit_index = 0;
ir_list->push_head(gl_VertexID);
if (gl_BaseVertex == NULL) {
gl_BaseVertex = new(mem_ctx) ir_variable(int_t, "gl_BaseVertex",
ir_var_system_value);
gl_BaseVertex->data.how_declared = ir_var_hidden;
gl_BaseVertex->data.read_only = true;
gl_BaseVertex->data.location = SYSTEM_VALUE_BASE_VERTEX;
gl_BaseVertex->data.explicit_location = true;
gl_BaseVertex->data.explicit_index = 0;
ir_list->push_head(gl_BaseVertex);
}
ir_instruction *const inst =
ir_builder::assign(VertexID,
ir_builder::add(gl_VertexID, gl_BaseVertex));
main_sig->body.push_head(inst);
}
ir->var = VertexID;
progress = true;
return visit_continue;
}
bool
lower_vertex_id(gl_linked_shader *shader)
{
/* gl_VertexID only exists in the vertex shader.
*/
if (shader->Stage != MESA_SHADER_VERTEX)
return false;
ir_function_signature *const main_sig =
_mesa_get_main_function_signature(shader->symbols);
if (main_sig == NULL) {
assert(main_sig != NULL);
return false;
}
lower_vertex_id_visitor v(main_sig, shader->ir);
v.run(shader->ir);
return v.progress;
}

View File

@@ -173,7 +173,6 @@ files_libglsl = files(
'lower_vec_index_to_swizzle.cpp',
'lower_vector_derefs.cpp',
'lower_vector_insert.cpp',
'lower_vertex_id.cpp',
'lower_output_reads.cpp',
'opt_algebraic.cpp',
'opt_array_splitting.cpp',

View File

@@ -226,7 +226,6 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen,
case PIPE_CAP_SAMPLER_VIEW_TARGET:
case PIPE_CAP_CLIP_HALFZ:
case PIPE_CAP_VERTEXID_NOBASE:
case PIPE_CAP_POLYGON_OFFSET_CLAMP:
case PIPE_CAP_MULTISAMPLE_Z_RESOLVE:
case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:

View File

@@ -180,7 +180,6 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
case PIPE_CAP_SAMPLER_VIEW_TARGET:
case PIPE_CAP_CLIP_HALFZ:
case PIPE_CAP_VERTEXID_NOBASE:
case PIPE_CAP_POLYGON_OFFSET_CLAMP:
case PIPE_CAP_MULTISAMPLE_Z_RESOLVE:
case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:

View File

@@ -315,7 +315,6 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_DRAW_INDIRECT:
case PIPE_CAP_MULTI_DRAW_INDIRECT:
case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS:
case PIPE_CAP_VERTEXID_NOBASE:
case PIPE_CAP_MULTISAMPLE_Z_RESOLVE: /* potentially supported on some hw */
case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
case PIPE_CAP_RESOURCE_FROM_USER_MEMORY_COMPUTE_ONLY:

View File

@@ -371,7 +371,6 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_VERTEX_ATTRIB_ELEMENT_ALIGNED_ONLY:
case PIPE_CAP_FAKE_SW_MSAA:
case PIPE_CAP_VS_WINDOW_SPACE_POSITION:
case PIPE_CAP_VERTEXID_NOBASE:
case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
case PIPE_CAP_FS_POSITION_IS_SYSVAL:
case PIPE_CAP_FS_POINT_IS_SYSVAL:

View File

@@ -830,7 +830,6 @@ enum pipe_cap
PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE,
PIPE_CAP_SAMPLER_VIEW_TARGET,
PIPE_CAP_CLIP_HALFZ,
PIPE_CAP_VERTEXID_NOBASE,
PIPE_CAP_POLYGON_OFFSET_CLAMP,
PIPE_CAP_MULTISAMPLE_Z_RESOLVE,
PIPE_CAP_RESOURCE_FROM_USER_MEMORY,

View File

@@ -549,7 +549,7 @@ vec4_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr)
break;
case nir_intrinsic_load_vertex_id:
unreachable("should be lowered by lower_vertex_id()");
unreachable("should be lowered by vertex_id_zero_based");
case nir_intrinsic_load_vertex_id_zero_base:
case nir_intrinsic_load_base_vertex:

View File

@@ -697,15 +697,6 @@ struct gl_constants
*/
GLboolean NativeIntegers;
/**
* Does VertexID count from zero or from base vertex?
*
* \note
* If desktop GLSL 1.30 or GLSL ES 3.00 are not supported, this field is
* ignored and need not be set.
*/
bool VertexID_is_zero_based;
/**
* If the driver supports real 32-bit integers, what integer value should be
* used for boolean true in uniform uploads? (Usually 1 or ~0.)

View File

@@ -481,12 +481,6 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api)
consts->GLSLLowerConstArrays = true;
/* Assume that if GLSL 1.30+ (or GLSL ES 3.00+) is supported that
* gl_VertexID is implemented using a native hardware register with OpenGL
* semantics.
*/
consts->VertexID_is_zero_based = false;
/* GL_ARB_draw_buffers */
consts->MaxDrawBuffers = MAX_DRAW_BUFFERS;

View File

@@ -1210,10 +1210,6 @@ void st_init_extensions(struct pipe_screen *screen,
if (drv_clip_planes > 1)
consts->MaxClipPlanes = drv_clip_planes;
if (screen->get_param(screen, PIPE_CAP_VERTEXID_NOBASE)) {
consts->VertexID_is_zero_based = GL_TRUE;
}
/* Extensions that either depend on GLSL 1.30 or are a subset thereof. */
extensions->ARB_conservative_depth = GL_TRUE;
extensions->ARB_shading_language_packing = GL_TRUE;