diff options
author | Marek Olšák <maraeo@gmail.com> | 2011-12-15 18:42:21 +0100 |
---|---|---|
committer | Christoph Bumiller <e0425955@student.tuwien.ac.at> | 2011-12-15 18:51:48 +0100 |
commit | 861a029ddb31e91bb4d8e18ab708d0d172f63aad (patch) | |
tree | a938450d80ee5dbda670f7fe37bb51b10c1982c4 /src/gallium/include/pipe/p_state.h | |
parent | 4f4a1be2009863ea34a69b22f58aa1ca08cd710f (diff) | |
download | external_mesa3d-861a029ddb31e91bb4d8e18ab708d0d172f63aad.zip external_mesa3d-861a029ddb31e91bb4d8e18ab708d0d172f63aad.tar.gz external_mesa3d-861a029ddb31e91bb4d8e18ab708d0d172f63aad.tar.bz2 |
gallium: interface changes necessary to implement transform feedback (v5)
Namely:
- EXT_transform_feedback
- ARB_transform_feedback2
- ARB_transform_feedback_instanced
The old interface was not useful for OpenGL and had to be reworked.
This interface was originally designed for OpenGL, but additional
changes have been made in order to make st/d3d1x support easier.
The most notable change is the stream-out info must be linked
with a vertex or geometry shader and cannot be set independently.
This is due to limitations of existing hardware (special shader
instructions must be used to write into stream-out buffers),
and it's also how OpenGL works (stream outputs must be specified
prior to linking shaders).
Other than that, each stream output buffer has a "view" into it that
internally maintains the number of bytes which have been written
into it. (one buffer can be bound in several different transform
feedback objects in OpenGL, so we must be able to have several views
around) The set_stream_output_targets function contains a parameter
saying whether new data should be appended or not.
Also, the view can optionally be used to provide the vertex
count for draw_vbo. Note that the count is supposed to be stored
in device memory and the CPU never gets to know its value.
OpenGL way | Gallium way
------------------------------------
BeginTF = set_so_targets(append_bitmask = 0)
PauseTF = set_so_targets(num_targets = 0)
ResumeTF = set_so_targets(append_bitmask = ~0)
EndTF = set_so_targets(num_targets = 0)
DrawTF = use pipe_draw_info::count_from_stream_output
v2: * removed the reset_stream_output_targets function
* added a parameter append_bitmask to set_stream_output_targets,
each bit specifies whether new data should be appended to each
buffer or not.
v3: * added PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME for ARB_tfb2,
note that the draw-auto subset is always required (for d3d10),
only the pause/resume functionality is limited if the CAP is not
advertised
v4: * update gallium/docs
v5: * compactified struct pipe_stream_output_info, updated dump/trace
Diffstat (limited to 'src/gallium/include/pipe/p_state.h')
-rw-r--r-- | src/gallium/include/pipe/p_state.h | 85 |
1 files changed, 67 insertions, 18 deletions
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 37e0679..f943ca5 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -121,6 +121,12 @@ struct pipe_rasterizer_state */ unsigned gl_rasterization_rules:1; + /** + * When true, rasterization is disabled and no pixels are written. + * This only makes sense with the Stream Out functionality. + */ + unsigned rasterizer_discard:1; + unsigned line_stipple_factor:8; /**< [1..256] actually */ unsigned line_stipple_pattern:16; @@ -164,9 +170,30 @@ struct pipe_clip_state }; +/** + * Stream output for vertex transform feedback. + */ +struct pipe_stream_output_info +{ + unsigned num_outputs; + /** stride for an entire vertex, only used if all output_buffers are 0 */ + unsigned stride; + /** + * Array of stream outputs, in the order they are to be written in. + * Selected components are tightly packed into the output buffer. + */ + struct { + unsigned register_index:8; /**< 0 to PIPE_MAX_SHADER_OUTPUTS */ + unsigned register_mask:4; /**< TGSI_WRITEMASK_x */ + unsigned output_buffer:4; /**< 0 to PIPE_MAX_SO_BUFFERS */ + } output[PIPE_MAX_SHADER_OUTPUTS]; +}; + + struct pipe_shader_state { const struct tgsi_token *tokens; + struct pipe_stream_output_info stream_output; }; @@ -375,24 +402,6 @@ struct pipe_resource /** - * Stream output for vertex transform feedback. - */ -struct pipe_stream_output_state -{ - /** number of the output buffer to insert each element into */ - int output_buffer[PIPE_MAX_SHADER_OUTPUTS]; - /** which register to grab each output from */ - int register_index[PIPE_MAX_SHADER_OUTPUTS]; - /** TGSI_WRITEMASK signifying which components to output */ - ubyte register_mask[PIPE_MAX_SHADER_OUTPUTS]; - /** number of outputs */ - int num_outputs; - /** stride for an entire vertex, only used if all output_buffers are 0 */ - unsigned stride; -}; - - -/** * Transfer object. For data transfer to/from a resource. */ struct pipe_transfer @@ -422,6 +431,30 @@ struct pipe_vertex_buffer /** + * A stream output target. The structure specifies the range vertices can + * be written to. + * + * In addition to that, the structure should internally maintain the offset + * into the buffer, which should be incremented everytime something is written + * (appended) to it. The internal offset is buffer_offset + how many bytes + * have been written. The internal offset can be stored on the device + * and the CPU actually doesn't have to query it. + * + * Use PIPE_QUERY_SO_STATISTICS to know how many primitives have + * actually been written. + */ +struct pipe_stream_output_target +{ + struct pipe_reference reference; + struct pipe_resource *buffer; /**< buffer into which this is a target view */ + struct pipe_context *context; /**< context this view belongs to */ + + unsigned buffer_offset; /**< offset where data should be written, in bytes */ + unsigned buffer_size; /**< how much data is allowed to be written */ +}; + + +/** * Information to describe a vertex attribute (position, color, etc) */ struct pipe_vertex_element @@ -481,6 +514,22 @@ struct pipe_draw_info */ boolean primitive_restart; unsigned restart_index; + + /** + * Stream output target. If not NULL, it's used to provide the 'count' + * parameter based on the number vertices captured by the stream output + * stage. (or generally, based on the number of bytes captured) + * + * Only 'mode', 'start_instance', and 'instance_count' are taken into + * account, all the other variables from pipe_draw_info are ignored. + * + * 'start' is implicitly 0 and 'count' is set as discussed above. + * The draw command is non-indexed. + * + * Note that this only provides the count. The vertex buffers must + * be set via set_vertex_buffers manually. + */ + struct pipe_stream_output_target *count_from_stream_output; }; |