Mesa (gallium-stream-out): gallium: make draw auto work and add relevant caps and docs
Zack Rusin
zack at kemper.freedesktop.org
Tue Jun 1 16:43:06 UTC 2010
Module: Mesa
Branch: gallium-stream-out
Commit: 4175952645d06331e5b1d1529f44f3cf834a12ae
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4175952645d06331e5b1d1529f44f3cf834a12ae
Author: Zack Rusin <zack at kde.org>
Date: Tue Jun 1 12:47:23 2010 -0400
gallium: make draw auto work and add relevant caps and docs
---
src/gallium/auxiliary/draw/draw_pt_so_emit.c | 2 ++
src/gallium/auxiliary/draw/draw_vbuf.h | 8 ++++++++
src/gallium/docs/d3d11ddi.txt | 9 +++------
src/gallium/docs/source/context.rst | 17 +++++++++++++++++
src/gallium/drivers/softpipe/sp_prim_vbuf.c | 10 ++++++++++
src/gallium/drivers/softpipe/sp_screen.c | 2 ++
src/gallium/include/pipe/p_defines.h | 1 +
7 files changed, 43 insertions(+), 6 deletions(-)
diff --git a/src/gallium/auxiliary/draw/draw_pt_so_emit.c b/src/gallium/auxiliary/draw/draw_pt_so_emit.c
index b982e4c..8a065a3 100644
--- a/src/gallium/auxiliary/draw/draw_pt_so_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_so_emit.c
@@ -163,6 +163,8 @@ void draw_pt_so_emit( struct pt_so_emit *emit,
stride, ~0);
translate->run(translate, 0, vertex_count,
draw->instance_id, so_buffer);
+
+ render->set_stream_output_info(render, 0, vertex_count);
}
diff --git a/src/gallium/auxiliary/draw/draw_vbuf.h b/src/gallium/auxiliary/draw/draw_vbuf.h
index 83ae26a..8d97682 100644
--- a/src/gallium/auxiliary/draw/draw_vbuf.h
+++ b/src/gallium/auxiliary/draw/draw_vbuf.h
@@ -117,6 +117,14 @@ struct vbuf_render {
void (*release_vertices)( struct vbuf_render * );
void (*destroy)( struct vbuf_render * );
+
+
+ /**
+ * Called after writing data to the stream out buffers
+ */
+ void (*set_stream_output_info)( struct vbuf_render *vbufr,
+ unsigned buffer_index,
+ unsigned vertices_count );
};
diff --git a/src/gallium/docs/d3d11ddi.txt b/src/gallium/docs/d3d11ddi.txt
index d9c2b44..4100c6e 100644
--- a/src/gallium/docs/d3d11ddi.txt
+++ b/src/gallium/docs/d3d11ddi.txt
@@ -177,7 +177,7 @@ CreateElementLayout -> create_vertex_elements_state
! D3D11 has an extra flag (InputSlotClass) that is the same as instance_divisor == 0
CreateGeometryShader -> create_gs_state
-CreateGeometryShaderWithStreamOutput -> create_gs_state
+CreateGeometryShaderWithStreamOutput -> create_gs_state + create_stream_output_state
CreatePixelShader -> create_fs_state
CreateVertexShader -> create_vs_state
> bytecode is different (see D3d10tokenizedprogramformat.hpp)
@@ -220,7 +220,6 @@ CreateResource -> texture_create or buffer_create
# Note that hardware often has the implicit rule, so the D3D11 interface seems to make little sense
# Also, the D3D11 API does not allow the user to specify mipmap sizes, so this really seems a dubious decision on Microsoft's part
- D3D11 supports specifying initial data to write in the resource
- - Gallium lacks support for stream output buffer usage
- Gallium does not support unordered access buffers
! D3D11 specifies mapping flags (i.e. read/write/discard);:it's unclear what they are used for here
- D3D11 supports odd things in the D3D10_DDI_RESOURCE_MISC_FLAG enum (D3D10_DDI_RESOURCE_MISC_DISCARD_ON_PRESENT, D3D11_DDI_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS, D3D11_DDI_RESOURCE_MISC_BUFFER_STRUCTURED)
@@ -275,8 +274,7 @@ DispatchIndirect (D3D11 only)
Draw -> draw_arrays
! D3D11 sets primitive modes separately with IaSetTopology: it's not obvious which is better
-DrawAuto
- - Gallium lacks stream out and DrawAuto
+DrawAuto -> draw_auto
DrawIndexed -> draw_elements
! D3D11 sets primitive modes separately with IaSetTopology: it's not obvious which is better
@@ -468,8 +466,7 @@ SetViewports
ShaderResourceViewReadAfterWriteHazard -> flush(PIPE_FLUSH_RENDER_CACHE)
- Gallium does not support specifying this per-render-target/view
-SoSetTargets
- - Gallium does not support stream out
+SoSetTargets -> set_stream_output_buffers
VsSetConstantBuffers -> for(i = StartBuffer; i < NumBuffers; ++i) set_constant_buffer(PIPE_SHADER_VERTEX, i, phBuffers[i])
* may want to split into fragment/vertex-specific versions
diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst
index 89c02b1..9f739e2 100644
--- a/src/gallium/docs/source/context.rst
+++ b/src/gallium/docs/source/context.rst
@@ -282,6 +282,23 @@ for a driver to batch multiple blits with the same source and
destination.
+Stream Output
+^^^^^^^^^^^^^
+
+Stream output, also known as transform feedback allows writing the results of the
+vertex pipeline (after the geometry shader or vertex shader if no geometry shader
+is present) to be written to a buffer created with a ``PIPE_BIND_STREAM_OUTPUT``
+flag.
+
+First a stream output state needs to be created with the
+``create_stream_output_state`` call. It specific the details of what's being written,
+to which buffer and with what kind of a writemask.
+
+Then target buffers needs to be set with the call to ``set_stream_output_buffers``
+which sets the buffers and the offsets from the start of those buffer to where
+the data will be written to.
+
+
Transfers
^^^^^^^^^
diff --git a/src/gallium/drivers/softpipe/sp_prim_vbuf.c b/src/gallium/drivers/softpipe/sp_prim_vbuf.c
index db0d175..06691e8 100644
--- a/src/gallium/drivers/softpipe/sp_prim_vbuf.c
+++ b/src/gallium/drivers/softpipe/sp_prim_vbuf.c
@@ -542,6 +542,15 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr)
}
}
+static void
+sp_vbuf_so_info(struct vbuf_render *vbr, uint buffer, uint vertices)
+{
+ struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
+ struct softpipe_context *softpipe = cvbr->softpipe;
+
+ softpipe->so_target.so_count[buffer] += vertices;
+}
+
static void
sp_vbuf_destroy(struct vbuf_render *vbr)
@@ -575,6 +584,7 @@ sp_create_vbuf_backend(struct softpipe_context *sp)
cvbr->base.draw_elements = sp_vbuf_draw_elements;
cvbr->base.draw_arrays = sp_vbuf_draw_arrays;
cvbr->base.release_vertices = sp_vbuf_release_vertices;
+ cvbr->base.set_stream_output_info = sp_vbuf_so_info;
cvbr->base.destroy = sp_vbuf_destroy;
cvbr->softpipe = sp;
diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
index 73987c9..7280741 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -113,6 +113,8 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
return 1;
+ case PIPE_CAP_STREAM_OUTPUT:
+ return 1;
case PIPE_CAP_MAX_VS_INSTRUCTIONS:
case PIPE_CAP_MAX_FS_INSTRUCTIONS:
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index bed3f32..7ce8a46 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -445,6 +445,7 @@ enum pipe_cap {
PIPE_CAP_TGSI_CONT_SUPPORTED,
PIPE_CAP_BLEND_EQUATION_SEPARATE,
PIPE_CAP_SM3, /*< Shader Model, supported */
+ PIPE_CAP_STREAM_OUTPUT,
PIPE_CAP_MAX_PREDICATE_REGISTERS,
/** Maximum texture image units accessible from vertex and fragment shaders
* combined */
More information about the mesa-commit
mailing list