gallium: utility helper functions for stream output
This commit is contained in:
parent
861a029ddb
commit
8a9a37cebe
|
@ -1590,14 +1590,19 @@ const struct tgsi_token *ureg_finalize( struct ureg_program *ureg )
|
||||||
|
|
||||||
|
|
||||||
void *ureg_create_shader( struct ureg_program *ureg,
|
void *ureg_create_shader( struct ureg_program *ureg,
|
||||||
struct pipe_context *pipe )
|
struct pipe_context *pipe,
|
||||||
|
const struct pipe_stream_output_info *so )
|
||||||
{
|
{
|
||||||
struct pipe_shader_state state;
|
struct pipe_shader_state state;
|
||||||
|
|
||||||
state.tokens = ureg_finalize(ureg);
|
state.tokens = ureg_finalize(ureg);
|
||||||
if(!state.tokens)
|
if(!state.tokens)
|
||||||
return NULL;
|
return NULL;
|
||||||
memset(&state.stream_output, 0, sizeof(state.stream_output));
|
|
||||||
|
if (so)
|
||||||
|
state.stream_output = *so;
|
||||||
|
else
|
||||||
|
memset(&state.stream_output, 0, sizeof(state.stream_output));
|
||||||
|
|
||||||
if (ureg->processor == TGSI_PROCESSOR_VERTEX)
|
if (ureg->processor == TGSI_PROCESSOR_VERTEX)
|
||||||
return pipe->create_vs_state( pipe, &state );
|
return pipe->create_vs_state( pipe, &state );
|
||||||
|
|
|
@ -37,6 +37,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct ureg_program;
|
struct ureg_program;
|
||||||
|
struct pipe_stream_output_info;
|
||||||
|
|
||||||
/* Almost a tgsi_src_register, but we need to pull in the Absolute
|
/* Almost a tgsi_src_register, but we need to pull in the Absolute
|
||||||
* flag from the _ext token. Indirect flag always implies ADDR[0].
|
* flag from the _ext token. Indirect flag always implies ADDR[0].
|
||||||
|
@ -97,7 +98,8 @@ ureg_finalize( struct ureg_program * );
|
||||||
*/
|
*/
|
||||||
void *
|
void *
|
||||||
ureg_create_shader( struct ureg_program *,
|
ureg_create_shader( struct ureg_program *,
|
||||||
struct pipe_context *pipe );
|
struct pipe_context *pipe,
|
||||||
|
const struct pipe_stream_output_info *so );
|
||||||
|
|
||||||
|
|
||||||
/* Alternately, return the built token stream and hand ownership of
|
/* Alternately, return the built token stream and hand ownership of
|
||||||
|
@ -119,13 +121,21 @@ ureg_destroy( struct ureg_program * );
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Convenience routine:
|
* Convenience routine:
|
||||||
*/
|
*/
|
||||||
|
static INLINE void *
|
||||||
|
ureg_create_shader_with_so_and_destroy( struct ureg_program *p,
|
||||||
|
struct pipe_context *pipe,
|
||||||
|
const struct pipe_stream_output_info *so )
|
||||||
|
{
|
||||||
|
void *result = ureg_create_shader( p, pipe, so );
|
||||||
|
ureg_destroy( p );
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static INLINE void *
|
static INLINE void *
|
||||||
ureg_create_shader_and_destroy( struct ureg_program *p,
|
ureg_create_shader_and_destroy( struct ureg_program *p,
|
||||||
struct pipe_context *pipe )
|
struct pipe_context *pipe )
|
||||||
{
|
{
|
||||||
void *result = ureg_create_shader( p, pipe );
|
return ureg_create_shader_with_so_and_destroy(p, pipe, NULL);
|
||||||
ureg_destroy( p );
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -79,3 +79,13 @@ debug_describe_sampler_view(char* buf, const struct pipe_sampler_view *ptr)
|
||||||
debug_describe_resource(res, ptr->texture);
|
debug_describe_resource(res, ptr->texture);
|
||||||
util_sprintf(buf, "pipe_sampler_view<%s,%s>", res, util_format_short_name(ptr->format));
|
util_sprintf(buf, "pipe_sampler_view<%s,%s>", res, util_format_short_name(ptr->format));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
debug_describe_so_target(char* buf,
|
||||||
|
const struct pipe_stream_output_target *ptr)
|
||||||
|
{
|
||||||
|
char res[128];
|
||||||
|
debug_describe_resource(res, ptr->buffer);
|
||||||
|
util_sprintf(buf, "pipe_stream_output_target<%s,%u,%u>", res,
|
||||||
|
ptr->buffer_offset, ptr->buffer_size);
|
||||||
|
}
|
||||||
|
|
|
@ -41,6 +41,8 @@ void debug_describe_reference(char* buf, const struct pipe_reference*ptr);
|
||||||
void debug_describe_resource(char* buf, const struct pipe_resource *ptr);
|
void debug_describe_resource(char* buf, const struct pipe_resource *ptr);
|
||||||
void debug_describe_surface(char* buf, const struct pipe_surface *ptr);
|
void debug_describe_surface(char* buf, const struct pipe_surface *ptr);
|
||||||
void debug_describe_sampler_view(char* buf, const struct pipe_sampler_view *ptr);
|
void debug_describe_sampler_view(char* buf, const struct pipe_sampler_view *ptr);
|
||||||
|
void debug_describe_so_target(char* buf,
|
||||||
|
const struct pipe_stream_output_target *ptr);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,6 +135,18 @@ pipe_sampler_view_reference(struct pipe_sampler_view **ptr, struct pipe_sampler_
|
||||||
*ptr = view;
|
*ptr = view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static INLINE void
|
||||||
|
pipe_so_target_reference(struct pipe_stream_output_target **ptr,
|
||||||
|
struct pipe_stream_output_target *target)
|
||||||
|
{
|
||||||
|
struct pipe_stream_output_target *old = *ptr;
|
||||||
|
|
||||||
|
if (pipe_reference_described(&(*ptr)->reference, &target->reference,
|
||||||
|
(debug_reference_descriptor)debug_describe_so_target))
|
||||||
|
old->context->stream_output_target_destroy(old->context, old);
|
||||||
|
*ptr = target;
|
||||||
|
}
|
||||||
|
|
||||||
static INLINE void
|
static INLINE void
|
||||||
pipe_surface_reset(struct pipe_context *ctx, struct pipe_surface* ps,
|
pipe_surface_reset(struct pipe_context *ctx, struct pipe_surface* ps,
|
||||||
struct pipe_resource *pt, unsigned level, unsigned layer,
|
struct pipe_resource *pt, unsigned level, unsigned layer,
|
||||||
|
|
|
@ -55,6 +55,18 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe,
|
||||||
uint num_attribs,
|
uint num_attribs,
|
||||||
const uint *semantic_names,
|
const uint *semantic_names,
|
||||||
const uint *semantic_indexes)
|
const uint *semantic_indexes)
|
||||||
|
{
|
||||||
|
return util_make_vertex_passthrough_shader_with_so(pipe, num_attribs,
|
||||||
|
semantic_names,
|
||||||
|
semantic_indexes, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
util_make_vertex_passthrough_shader_with_so(struct pipe_context *pipe,
|
||||||
|
uint num_attribs,
|
||||||
|
const uint *semantic_names,
|
||||||
|
const uint *semantic_indexes,
|
||||||
|
const struct pipe_stream_output_info *so)
|
||||||
{
|
{
|
||||||
struct ureg_program *ureg;
|
struct ureg_program *ureg;
|
||||||
uint i;
|
uint i;
|
||||||
|
@ -78,7 +90,7 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe,
|
||||||
|
|
||||||
ureg_END( ureg );
|
ureg_END( ureg );
|
||||||
|
|
||||||
return ureg_create_shader_and_destroy( ureg, pipe );
|
return ureg_create_shader_with_so_and_destroy( ureg, pipe, so );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
struct pipe_context;
|
struct pipe_context;
|
||||||
struct pipe_shader_state;
|
struct pipe_shader_state;
|
||||||
|
struct pipe_stream_output_info;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -48,6 +49,13 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe,
|
||||||
const uint *semantic_names,
|
const uint *semantic_names,
|
||||||
const uint *semantic_indexes);
|
const uint *semantic_indexes);
|
||||||
|
|
||||||
|
extern void *
|
||||||
|
util_make_vertex_passthrough_shader_with_so(struct pipe_context *pipe,
|
||||||
|
uint num_attribs,
|
||||||
|
const uint *semantic_names,
|
||||||
|
const uint *semantic_indexes,
|
||||||
|
const struct pipe_stream_output_info *so);
|
||||||
|
|
||||||
|
|
||||||
extern void *
|
extern void *
|
||||||
util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
|
util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
|
||||||
|
|
Loading…
Reference in New Issue