diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-05-16 13:47:15 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-05-16 17:58:32 +0300 |
commit | a25856f2a802dae4e2c4c01e9b74d8c8a1769933 (patch) | |
tree | 1ae725b9d04c36f4847c5bc08fb55f4a0f7a8aab /source/blender/gpu/GPU_shader.h | |
parent | a3f4c72ec9d431f65bf9f50b7849e22e2f213ad0 (diff) |
GPUShader/DRW: Add Transform Feedback support.
This is a usefull feature that can be used to do a lot of precomputation on
the GPU instead of the CPU.
Implementation is simple and only covers the most usefull case.
How to use:
- Create shader with transform feedback.
- Create a pass with DRW_STATE_TRANS_FEEDBACK.
- Create a target Gwn_VertBuf (make sure it's big enough).
- Create a shading group with DRW_shgroup_transform_feedback_create().
- Add your draw calls to the shading group.
- Render your pass normaly.
Current limitation:
- Only one output buffer.
- Cannot pause/resume tfb rendering to interleave with normal drawcalls.
- Cannot get the number of verts drawn.
Diffstat (limited to 'source/blender/gpu/GPU_shader.h')
-rw-r--r-- | source/blender/gpu/GPU_shader.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h index 2a672873d86..baaa23c2398 100644 --- a/source/blender/gpu/GPU_shader.h +++ b/source/blender/gpu/GPU_shader.h @@ -50,6 +50,13 @@ enum { GPU_SHADER_FLAGS_NEW_SHADING = (1 << 1), }; +typedef enum GPUShaderTFBType { + GPU_SHADER_TFB_NONE = 0, /* Transform feedback unsupported. */ + GPU_SHADER_TFB_POINTS = 1, + GPU_SHADER_TFB_LINES = 2, + GPU_SHADER_TFB_TRIANGLES = 3, +} GPUShaderTFBType; + GPUShader *GPU_shader_create( const char *vertexcode, const char *fragcode, @@ -62,12 +69,19 @@ GPUShader *GPU_shader_create_ex( const char *geocode, const char *libcode, const char *defines, - const int flags); + const int flags, + const GPUShaderTFBType tf_type, + const char **tf_names, + const int tf_count); void GPU_shader_free(GPUShader *shader); void GPU_shader_bind(GPUShader *shader); void GPU_shader_unbind(void); +/* Returns true if transform feedback was succesfully enabled. */ +bool GPU_shader_transform_feedback_enable(GPUShader *shader, unsigned int vbo_id); +void GPU_shader_transform_feedback_disable(GPUShader *shader); + int GPU_shader_get_program(GPUShader *shader); void *GPU_shader_get_interface(GPUShader *shader); |