glthread: use GLenum16 for enums, but clamp it to 0xffff to get correct errors
0xffff is an invalid enum. This was initially implemented without clamping and then reverted because of the concern that we would randomly get correct enums and not report errors if we just dropped the high bits. This packs calls better in glthread_batch. Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18828>
This commit is contained in:
@@ -127,6 +127,8 @@ class PrintCode(gl_XML.gl_print_base):
|
|||||||
if p.count:
|
if p.count:
|
||||||
out('memcpy(cmd->{0}, {0}, {1});'.format(
|
out('memcpy(cmd->{0}, {0}, {1});'.format(
|
||||||
p.name, p.size_string()))
|
p.name, p.size_string()))
|
||||||
|
elif p.type_string() == 'GLenum':
|
||||||
|
out('cmd->{0} = MIN2({0}, 0xffff); /* clamped to 0xffff (invalid enum) */'.format(p.name))
|
||||||
else:
|
else:
|
||||||
out('cmd->{0} = {0};'.format(p.name))
|
out('cmd->{0} = {0};'.format(p.name))
|
||||||
if variable_params:
|
if variable_params:
|
||||||
@@ -164,10 +166,10 @@ class PrintCode(gl_XML.gl_print_base):
|
|||||||
'GLboolean': 1,
|
'GLboolean': 1,
|
||||||
'GLbyte': 1,
|
'GLbyte': 1,
|
||||||
'GLubyte': 1,
|
'GLubyte': 1,
|
||||||
|
'GLenum': 2, # uses GLenum16, clamped to 0xffff (invalid enum)
|
||||||
'GLshort': 2,
|
'GLshort': 2,
|
||||||
'GLushort': 2,
|
'GLushort': 2,
|
||||||
'GLhalfNV': 2,
|
'GLhalfNV': 2,
|
||||||
'GLenum': 4,
|
|
||||||
'GLint': 4,
|
'GLint': 4,
|
||||||
'GLuint': 4,
|
'GLuint': 4,
|
||||||
'GLbitfield': 4,
|
'GLbitfield': 4,
|
||||||
@@ -212,7 +214,10 @@ class PrintCode(gl_XML.gl_print_base):
|
|||||||
out('{0} {1}[{2}];'.format(
|
out('{0} {1}[{2}];'.format(
|
||||||
p.get_base_type_string(), p.name, p.count))
|
p.get_base_type_string(), p.name, p.count))
|
||||||
else:
|
else:
|
||||||
out('{0} {1};'.format(p.type_string(), p.name))
|
type = p.type_string()
|
||||||
|
if type == 'GLenum':
|
||||||
|
type = 'GLenum16'
|
||||||
|
out('{0} {1};'.format(type, p.name))
|
||||||
|
|
||||||
for p in variable_params:
|
for p in variable_params:
|
||||||
if p.img_null_flag:
|
if p.img_null_flag:
|
||||||
|
@@ -52,6 +52,7 @@
|
|||||||
#include "GL/gl.h"
|
#include "GL/gl.h"
|
||||||
#include "compiler/shader_enums.h"
|
#include "compiler/shader_enums.h"
|
||||||
#include "main/config.h"
|
#include "main/config.h"
|
||||||
|
#include "glheader.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -128,7 +129,7 @@ struct glthread_client_attrib {
|
|||||||
struct glthread_attrib_node {
|
struct glthread_attrib_node {
|
||||||
GLbitfield Mask;
|
GLbitfield Mask;
|
||||||
int ActiveTexture;
|
int ActiveTexture;
|
||||||
GLenum MatrixMode;
|
GLenum16 MatrixMode;
|
||||||
bool CullFace;
|
bool CullFace;
|
||||||
bool DepthTest;
|
bool DepthTest;
|
||||||
};
|
};
|
||||||
@@ -157,7 +158,7 @@ struct glthread_state
|
|||||||
bool inside_begin_end;
|
bool inside_begin_end;
|
||||||
|
|
||||||
/** Display lists. */
|
/** Display lists. */
|
||||||
GLenum ListMode; /**< Zero if not inside display list, else list mode. */
|
GLenum16 ListMode; /**< Zero if not inside display list, else list mode. */
|
||||||
unsigned ListBase;
|
unsigned ListBase;
|
||||||
unsigned ListCallDepth;
|
unsigned ListCallDepth;
|
||||||
|
|
||||||
@@ -226,7 +227,7 @@ struct glthread_state
|
|||||||
|
|
||||||
/** Basic matrix state tracking. */
|
/** Basic matrix state tracking. */
|
||||||
int ActiveTexture;
|
int ActiveTexture;
|
||||||
GLenum MatrixMode;
|
GLenum16 MatrixMode;
|
||||||
gl_matrix_index MatrixIndex;
|
gl_matrix_index MatrixIndex;
|
||||||
struct glthread_attrib_node AttribStack[MAX_ATTRIB_STACK_DEPTH];
|
struct glthread_attrib_node AttribStack[MAX_ATTRIB_STACK_DEPTH];
|
||||||
int AttribStackDepth;
|
int AttribStackDepth;
|
||||||
|
@@ -568,8 +568,8 @@ sync:
|
|||||||
struct marshal_cmd_DrawElementsInstancedARB
|
struct marshal_cmd_DrawElementsInstancedARB
|
||||||
{
|
{
|
||||||
struct marshal_cmd_base cmd_base;
|
struct marshal_cmd_base cmd_base;
|
||||||
GLenum mode;
|
GLenum16 mode;
|
||||||
GLenum type;
|
GLenum16 type;
|
||||||
GLsizei count;
|
GLsizei count;
|
||||||
GLsizei instance_count;
|
GLsizei instance_count;
|
||||||
GLint basevertex;
|
GLint basevertex;
|
||||||
@@ -606,8 +606,8 @@ _mesa_unmarshal_DrawElementsInstancedARB(struct gl_context *ctx,
|
|||||||
struct marshal_cmd_DrawRangeElementsBaseVertex
|
struct marshal_cmd_DrawRangeElementsBaseVertex
|
||||||
{
|
{
|
||||||
struct marshal_cmd_base cmd_base;
|
struct marshal_cmd_base cmd_base;
|
||||||
GLenum mode;
|
GLenum16 mode;
|
||||||
GLenum type;
|
GLenum16 type;
|
||||||
GLsizei count;
|
GLsizei count;
|
||||||
GLint basevertex;
|
GLint basevertex;
|
||||||
GLuint min_index;
|
GLuint min_index;
|
||||||
@@ -645,9 +645,9 @@ draw_elements_async(struct gl_context *ctx, GLenum mode, GLsizei count,
|
|||||||
struct marshal_cmd_DrawRangeElementsBaseVertex *cmd =
|
struct marshal_cmd_DrawRangeElementsBaseVertex *cmd =
|
||||||
_mesa_glthread_allocate_command(ctx, DISPATCH_CMD_DrawRangeElementsBaseVertex, cmd_size);
|
_mesa_glthread_allocate_command(ctx, DISPATCH_CMD_DrawRangeElementsBaseVertex, cmd_size);
|
||||||
|
|
||||||
cmd->mode = mode;
|
cmd->mode = MIN2(mode, 0xffff);
|
||||||
|
cmd->type = MIN2(type, 0xffff);
|
||||||
cmd->count = count;
|
cmd->count = count;
|
||||||
cmd->type = type;
|
|
||||||
cmd->indices = indices;
|
cmd->indices = indices;
|
||||||
cmd->basevertex = basevertex;
|
cmd->basevertex = basevertex;
|
||||||
cmd->min_index = min_index;
|
cmd->min_index = min_index;
|
||||||
@@ -657,9 +657,9 @@ draw_elements_async(struct gl_context *ctx, GLenum mode, GLsizei count,
|
|||||||
struct marshal_cmd_DrawElementsInstancedARB *cmd =
|
struct marshal_cmd_DrawElementsInstancedARB *cmd =
|
||||||
_mesa_glthread_allocate_command(ctx, DISPATCH_CMD_DrawElementsInstancedARB, cmd_size);
|
_mesa_glthread_allocate_command(ctx, DISPATCH_CMD_DrawElementsInstancedARB, cmd_size);
|
||||||
|
|
||||||
cmd->mode = mode;
|
cmd->mode = MIN2(mode, 0xffff);
|
||||||
|
cmd->type = MIN2(type, 0xffff);
|
||||||
cmd->count = count;
|
cmd->count = count;
|
||||||
cmd->type = type;
|
|
||||||
cmd->indices = indices;
|
cmd->indices = indices;
|
||||||
cmd->instance_count = instance_count;
|
cmd->instance_count = instance_count;
|
||||||
cmd->basevertex = basevertex;
|
cmd->basevertex = basevertex;
|
||||||
@@ -671,8 +671,8 @@ struct marshal_cmd_DrawElementsInstancedBaseVertexBaseInstance
|
|||||||
{
|
{
|
||||||
struct marshal_cmd_base cmd_base;
|
struct marshal_cmd_base cmd_base;
|
||||||
bool index_bounds_valid;
|
bool index_bounds_valid;
|
||||||
GLenum mode;
|
GLenum16 mode;
|
||||||
GLenum type;
|
GLenum16 type;
|
||||||
GLsizei count;
|
GLsizei count;
|
||||||
GLsizei instance_count;
|
GLsizei instance_count;
|
||||||
GLint basevertex;
|
GLint basevertex;
|
||||||
@@ -756,9 +756,9 @@ draw_elements_async_user(struct gl_context *ctx, GLenum mode, GLsizei count,
|
|||||||
struct marshal_cmd_DrawElementsInstancedBaseVertexBaseInstance *cmd;
|
struct marshal_cmd_DrawElementsInstancedBaseVertexBaseInstance *cmd;
|
||||||
|
|
||||||
cmd = _mesa_glthread_allocate_command(ctx, DISPATCH_CMD_DrawElementsInstancedBaseVertexBaseInstance, cmd_size);
|
cmd = _mesa_glthread_allocate_command(ctx, DISPATCH_CMD_DrawElementsInstancedBaseVertexBaseInstance, cmd_size);
|
||||||
cmd->mode = mode;
|
cmd->mode = MIN2(mode, 0xffff);
|
||||||
|
cmd->type = MIN2(type, 0xffff);
|
||||||
cmd->count = count;
|
cmd->count = count;
|
||||||
cmd->type = type;
|
|
||||||
cmd->indices = indices;
|
cmd->indices = indices;
|
||||||
cmd->instance_count = instance_count;
|
cmd->instance_count = instance_count;
|
||||||
cmd->basevertex = basevertex;
|
cmd->basevertex = basevertex;
|
||||||
@@ -887,8 +887,8 @@ struct marshal_cmd_MultiDrawElementsBaseVertex
|
|||||||
{
|
{
|
||||||
struct marshal_cmd_base cmd_base;
|
struct marshal_cmd_base cmd_base;
|
||||||
bool has_base_vertex;
|
bool has_base_vertex;
|
||||||
GLenum mode;
|
GLenum16 mode;
|
||||||
GLenum type;
|
GLenum16 type;
|
||||||
GLsizei draw_count;
|
GLsizei draw_count;
|
||||||
GLuint user_buffer_mask;
|
GLuint user_buffer_mask;
|
||||||
struct gl_buffer_object *index_buffer;
|
struct gl_buffer_object *index_buffer;
|
||||||
@@ -972,8 +972,8 @@ multi_draw_elements_async(struct gl_context *ctx, GLenum mode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd = _mesa_glthread_allocate_command(ctx, DISPATCH_CMD_MultiDrawElementsBaseVertex, cmd_size);
|
cmd = _mesa_glthread_allocate_command(ctx, DISPATCH_CMD_MultiDrawElementsBaseVertex, cmd_size);
|
||||||
cmd->mode = mode;
|
cmd->mode = MIN2(mode, 0xffff);
|
||||||
cmd->type = type;
|
cmd->type = MIN2(type, 0xffff);
|
||||||
cmd->draw_count = draw_count;
|
cmd->draw_count = draw_count;
|
||||||
cmd->user_buffer_mask = user_buffer_mask;
|
cmd->user_buffer_mask = user_buffer_mask;
|
||||||
cmd->index_buffer = index_buffer;
|
cmd->index_buffer = index_buffer;
|
||||||
|
@@ -613,7 +613,7 @@ _mesa_glthread_MatrixMode(struct gl_context *ctx, GLenum mode)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ctx->GLThread.MatrixIndex = _mesa_get_matrix_index(ctx, mode);
|
ctx->GLThread.MatrixIndex = _mesa_get_matrix_index(ctx, mode);
|
||||||
ctx->GLThread.MatrixMode = mode;
|
ctx->GLThread.MatrixMode = MIN2(mode, 0xffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
@@ -756,10 +756,10 @@ _mesa_glthread_CallLists(struct gl_context *ctx, GLsizei n, GLenum type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
_mesa_glthread_NewList(struct gl_context *ctx, GLuint list, GLuint mode)
|
_mesa_glthread_NewList(struct gl_context *ctx, GLuint list, GLenum mode)
|
||||||
{
|
{
|
||||||
if (!ctx->GLThread.ListMode)
|
if (!ctx->GLThread.ListMode)
|
||||||
ctx->GLThread.ListMode = mode;
|
ctx->GLThread.ListMode = MIN2(mode, 0xffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
Reference in New Issue
Block a user