mesa: pass select result buffer offset as attribute/varying
Will be used by geometry shader to store hit result. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Signed-off-by: Qiang Yu <yuq825@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15765>
This commit is contained in:
parent
c41ac0682e
commit
19f3737262
|
@ -272,6 +272,9 @@ const char *gl_vert_attrib_name(gl_vert_attrib attrib);
|
|||
#define VERT_BIT_MAT(i) VERT_BIT(VERT_ATTRIB_MAT(i))
|
||||
#define VERT_BIT_MAT_ALL \
|
||||
BITFIELD_RANGE(VERT_ATTRIB_MAT(0), VERT_ATTRIB_MAT_MAX)
|
||||
|
||||
#define VERT_ATTRIB_SELECT_RESULT_OFFSET VERT_ATTRIB_GENERIC(3)
|
||||
#define VERT_BIT_SELECT_RESULT_OFFSET VERT_BIT_GENERIC(3)
|
||||
/*@}*/
|
||||
|
||||
#define MAX_VARYING 32 /**< number of float[4] vectors */
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "main/mtypes.h"
|
||||
#include "main/macros.h"
|
||||
#include "main/enums.h"
|
||||
#include "main/context.h"
|
||||
#include "main/ffvertex_prog.h"
|
||||
#include "program/program.h"
|
||||
#include "program/prog_cache.h"
|
||||
|
@ -157,6 +158,16 @@ static void make_state_key( struct gl_context *ctx, struct state_key *key )
|
|||
|
||||
memset(key, 0, sizeof(struct state_key));
|
||||
|
||||
if (_mesa_hw_select_enabled(ctx)) {
|
||||
/* GL_SELECT mode only need position calculation.
|
||||
* glBegin/End use VERT_BIT_SELECT_RESULT_OFFSET for multi name stack in one draw.
|
||||
* glDrawArrays may also be called without user shader, fallback to FF one.
|
||||
*/
|
||||
key->varying_vp_inputs = ctx->VertexProgram._VaryingInputs &
|
||||
(VERT_BIT_POS | VERT_BIT_SELECT_RESULT_OFFSET);
|
||||
return;
|
||||
}
|
||||
|
||||
/* This now relies on texenvprogram.c being active:
|
||||
*/
|
||||
assert(fp);
|
||||
|
@ -1668,6 +1679,9 @@ static void build_tnl_program( struct tnl_program *p )
|
|||
else if (p->state->varying_vp_inputs & VERT_BIT_POINT_SIZE)
|
||||
build_array_pointsize(p);
|
||||
|
||||
if (p->state->varying_vp_inputs & VERT_BIT_SELECT_RESULT_OFFSET)
|
||||
emit_passthrough(p, VERT_ATTRIB_SELECT_RESULT_OFFSET, VARYING_SLOT_VAR0);
|
||||
|
||||
/* Finish up:
|
||||
*/
|
||||
emit_op1(p, OPCODE_END, undef, 0, undef);
|
||||
|
|
|
@ -96,6 +96,9 @@ enum vbo_attrib {
|
|||
VBO_ATTRIB_MAT_FRONT_INDEXES,
|
||||
VBO_ATTRIB_MAT_BACK_INDEXES,
|
||||
|
||||
/* Offset into HW GL_SELECT result buffer. */
|
||||
VBO_ATTRIB_SELECT_RESULT_OFFSET,
|
||||
|
||||
VBO_ATTRIB_MAX
|
||||
};
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ _vbo_attribute_alias_map[VP_MODE_MAX][VERT_ATTRIB_MAX] = {
|
|||
VBO_ATTRIB_GENERIC0, /* VERT_ATTRIB_GENERIC0 */
|
||||
VBO_ATTRIB_GENERIC1, /* VERT_ATTRIB_GENERIC1 */
|
||||
VBO_ATTRIB_GENERIC2, /* VERT_ATTRIB_GENERIC2 */
|
||||
VBO_ATTRIB_GENERIC3, /* VERT_ATTRIB_GENERIC3 */
|
||||
VBO_ATTRIB_SELECT_RESULT_OFFSET,/* VERT_ATTRIB_GENERIC3 */
|
||||
VBO_ATTRIB_MAT_FRONT_AMBIENT, /* VERT_ATTRIB_GENERIC4 */
|
||||
VBO_ATTRIB_MAT_BACK_AMBIENT, /* VERT_ATTRIB_GENERIC5 */
|
||||
VBO_ATTRIB_MAT_FRONT_DIFFUSE, /* VERT_ATTRIB_GENERIC6 */
|
||||
|
|
|
@ -180,6 +180,10 @@ vbo_exec_copy_to_current(struct vbo_exec_context *exec)
|
|||
|
||||
assert(exec->vtx.attr[i].size);
|
||||
|
||||
/* VBO_ATTRIB_SELECT_RESULT_INDEX has no current */
|
||||
if (!current)
|
||||
continue;
|
||||
|
||||
if (exec->vtx.attr[i].type == GL_DOUBLE ||
|
||||
exec->vtx.attr[i].type == GL_UNSIGNED_INT64_ARB) {
|
||||
memset(tmp, 0, sizeof(tmp));
|
||||
|
@ -557,7 +561,6 @@ do { \
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#undef ERROR
|
||||
#define ERROR(err) _mesa_error(ctx, err, __func__)
|
||||
#define TAG(x) _mesa_##x
|
||||
|
@ -1231,7 +1234,8 @@ _es_Materialf(GLenum face, GLenum pname, GLfloat param)
|
|||
#define ATTR_UNION(A, N, T, C, V0, V1, V2, V3) \
|
||||
do { \
|
||||
if ((A) == 0) { \
|
||||
/* TODO: insert name stack attr. */ \
|
||||
ATTR_UNION_BASE(VBO_ATTRIB_SELECT_RESULT_OFFSET, 1, GL_UNSIGNED_INT, uint32_t, \
|
||||
ctx->Select.ResultOffset, 0, 0, 0); \
|
||||
} \
|
||||
ATTR_UNION_BASE(A, N, T, C, V0, V1, V2, V3); \
|
||||
} while (0)
|
||||
|
|
|
@ -101,8 +101,14 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
|
|||
|
||||
const gl_vertex_processing_mode mode = ctx->VertexProgram._VPMode;
|
||||
|
||||
/* Compute the bitmasks of vao_enabled arrays */
|
||||
GLbitfield vao_enabled = _vbo_get_vao_enabled_from_vbo(mode, exec->vtx.enabled);
|
||||
GLbitfield vao_enabled, vao_filter;
|
||||
if (_mesa_hw_select_enabled(ctx)) {
|
||||
/* HW GL_SELECT has fixed input */
|
||||
vao_enabled = vao_filter = VERT_BIT_POS | VERT_BIT_SELECT_RESULT_OFFSET;
|
||||
} else {
|
||||
vao_enabled = _vbo_get_vao_enabled_from_vbo(mode, exec->vtx.enabled);
|
||||
vao_filter = _vbo_get_vao_filter(mode);
|
||||
}
|
||||
|
||||
/* At first disable arrays no longer needed */
|
||||
_mesa_disable_vertex_array_attribs(ctx, vao, VERT_BIT_ALL & ~vao_enabled);
|
||||
|
@ -141,7 +147,7 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
|
|||
assert(!exec->vtx.bufferobj ||
|
||||
(vao_enabled & ~vao->VertexAttribBufferMask) == 0);
|
||||
|
||||
_mesa_set_draw_vao(ctx, vao, _vbo_get_vao_filter(mode));
|
||||
_mesa_set_draw_vao(ctx, vao, vao_filter);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue