gallium: add pipe_context::set_inlinable_constants
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6955>
This commit is contained in:
@@ -49,6 +49,22 @@ buffers, surfaces) are bound to the driver.
|
||||
multiple ones to be set, and binding a specific one later, though drivers
|
||||
are mostly restricted to the first one right now).
|
||||
|
||||
* ``set_inlinable_constants`` sets inlinable constants for constant buffer 0.
|
||||
|
||||
These are constants that the driver would like to inline in the IR
|
||||
of the current shader and recompile it. Drivers can determine which
|
||||
constants they prefer to inline in finalize_nir and store that
|
||||
information in shader_info::*inlinable_uniform*. When the state tracker
|
||||
or frontend uploads constants to a constant buffer, it can pass
|
||||
inlinable constants separately via this call.
|
||||
|
||||
Any ``set_constant_buffer`` call invalidates inlinable constants, so
|
||||
``set_inlinable_constants`` must be called after it. Binding a shader also
|
||||
invalidates this state.
|
||||
|
||||
There is no ``PIPE_CAP`` for this. Drivers shouldn't set the shader_info
|
||||
fields if they don't implement ``set_inlinable_constants``.
|
||||
|
||||
* ``set_framebuffer_state``
|
||||
|
||||
* ``set_vertex_buffers``
|
||||
|
@@ -166,6 +166,12 @@ static void noop_set_constant_buffer(struct pipe_context *ctx,
|
||||
{
|
||||
}
|
||||
|
||||
static void noop_set_inlinable_constants(struct pipe_context *ctx,
|
||||
enum pipe_shader_type shader,
|
||||
uint num_values, uint32_t *values)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void noop_sampler_view_destroy(struct pipe_context *ctx,
|
||||
struct pipe_sampler_view *state)
|
||||
@@ -296,6 +302,7 @@ void noop_init_state_functions(struct pipe_context *ctx)
|
||||
ctx->set_blend_color = noop_set_blend_color;
|
||||
ctx->set_clip_state = noop_set_clip_state;
|
||||
ctx->set_constant_buffer = noop_set_constant_buffer;
|
||||
ctx->set_inlinable_constants = noop_set_inlinable_constants;
|
||||
ctx->set_sampler_views = noop_set_sampler_views;
|
||||
ctx->set_framebuffer_state = noop_set_framebuffer_state;
|
||||
ctx->set_polygon_stipple = noop_set_polygon_stipple;
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#include "util/u_inlines.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_upload_mgr.h"
|
||||
#include "compiler/shader_info.h"
|
||||
|
||||
/* 0 = disabled, 1 = assertions, 2 = printfs */
|
||||
#define TC_DEBUG 0
|
||||
@@ -705,6 +706,34 @@ tc_set_constant_buffer(struct pipe_context *_pipe,
|
||||
}
|
||||
}
|
||||
|
||||
struct tc_inlinable_constants {
|
||||
ubyte shader;
|
||||
ubyte num_values;
|
||||
uint32_t values[MAX_INLINABLE_UNIFORMS];
|
||||
};
|
||||
|
||||
static void
|
||||
tc_call_set_inlinable_constants(struct pipe_context *pipe, union tc_payload *payload)
|
||||
{
|
||||
struct tc_inlinable_constants *p = (struct tc_inlinable_constants *)payload;
|
||||
|
||||
pipe->set_inlinable_constants(pipe, p->shader, p->num_values, p->values);
|
||||
}
|
||||
|
||||
static void
|
||||
tc_set_inlinable_constants(struct pipe_context *_pipe,
|
||||
enum pipe_shader_type shader,
|
||||
uint num_values, uint32_t *values)
|
||||
{
|
||||
struct threaded_context *tc = threaded_context(_pipe);
|
||||
struct tc_inlinable_constants *p =
|
||||
tc_add_struct_typed_call(tc, TC_CALL_set_inlinable_constants,
|
||||
tc_inlinable_constants);
|
||||
p->shader = shader;
|
||||
p->num_values = num_values;
|
||||
memcpy(p->values, values, num_values * 4);
|
||||
}
|
||||
|
||||
struct tc_scissors {
|
||||
ubyte start, count;
|
||||
struct pipe_scissor_state slot[0]; /* more will be allocated if needed */
|
||||
@@ -2750,6 +2779,7 @@ threaded_context_create(struct pipe_context *pipe,
|
||||
CTX_INIT(set_min_samples);
|
||||
CTX_INIT(set_clip_state);
|
||||
CTX_INIT(set_constant_buffer);
|
||||
CTX_INIT(set_inlinable_constants);
|
||||
CTX_INIT(set_framebuffer_state);
|
||||
CTX_INIT(set_polygon_stipple);
|
||||
CTX_INIT(set_scissor_states);
|
||||
|
@@ -11,6 +11,7 @@ CALL(bind_sampler_states)
|
||||
CALL(set_framebuffer_state)
|
||||
CALL(set_tess_state)
|
||||
CALL(set_constant_buffer)
|
||||
CALL(set_inlinable_constants)
|
||||
CALL(set_scissor_states)
|
||||
CALL(set_viewport_states)
|
||||
CALL(set_window_rectangles)
|
||||
|
@@ -320,6 +320,26 @@ struct pipe_context {
|
||||
enum pipe_shader_type shader, uint index,
|
||||
const struct pipe_constant_buffer *buf );
|
||||
|
||||
/**
|
||||
* Set inlinable constants for constant buffer 0.
|
||||
*
|
||||
* These are constants that the driver would like to inline in the IR
|
||||
* of the current shader and recompile it. Drivers can determine which
|
||||
* constants they prefer to inline in finalize_nir and store that
|
||||
* information in shader_info::*inlinable_uniform*. When the state tracker
|
||||
* or frontend uploads constants to a constant buffer, it can pass
|
||||
* inlinable constants separately via this call.
|
||||
*
|
||||
* Any set_constant_buffer call invalidates this state, so this function
|
||||
* must be called after it. Binding a shader also invalidates this state.
|
||||
*
|
||||
* There is no PIPE_CAP for this. Drivers shouldn't set the shader_info
|
||||
* fields if they don't want this or if they don't implement this.
|
||||
*/
|
||||
void (*set_inlinable_constants)( struct pipe_context *,
|
||||
enum pipe_shader_type shader,
|
||||
uint num_values, uint32_t *values );
|
||||
|
||||
void (*set_framebuffer_state)( struct pipe_context *,
|
||||
const struct pipe_framebuffer_state * );
|
||||
|
||||
|
Reference in New Issue
Block a user