[virglrenderer-devel] [PATCH 9/9] renderer: bind objects in single loop
Dave Airlie
airlied at gmail.com
Thu Jun 14 02:01:52 UTC 2018
From: Dave Airlie <airlied at redhat.com>
This refactors the code to bind the samplers/ubo/const objects
in a single shader loop.
---
src/vrend_renderer.c | 47 ++++++++++++-----------------------------------
1 file changed, 12 insertions(+), 35 deletions(-)
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index dae35f3..8385272 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -3016,24 +3016,6 @@ static void vrend_draw_bind_samplers_shader(struct vrend_context *ctx,
}
}
-static void vrend_draw_bind_samplers(struct vrend_context *ctx)
-{
- int sampler_id;
- int shader_type;
-
- sampler_id = 0;
- for (shader_type = PIPE_SHADER_VERTEX; shader_type <= ctx->sub->last_shader_idx; shader_type++) {
- vrend_draw_bind_samplers_shader(ctx, shader_type, &sampler_id);
- }
-
- if (vrend_state.use_core_profile && ctx->sub->prog->fs_stipple_loc != -1) {
- glActiveTexture(GL_TEXTURE0 + sampler_id);
- glBindTexture(GL_TEXTURE_2D, ctx->pstipple_tex_id);
- glUniform1i(ctx->sub->prog->fs_stipple_loc, sampler_id);
- }
- ctx->sub->sampler_state_dirty = false;
-}
-
static void vrend_draw_bind_ubo_shader(struct vrend_context *ctx,
int shader_type, int *ubo_id)
{
@@ -3076,17 +3058,6 @@ static void vrend_draw_bind_ubo_shader(struct vrend_context *ctx,
}
}
-static void vrend_draw_bind_ubo(struct vrend_context *ctx)
-{
- int ubo_id;
- int shader_type;
-
- ubo_id = 0;
- for (shader_type = PIPE_SHADER_VERTEX; shader_type <= ctx->sub->last_shader_idx; shader_type++) {
- vrend_draw_bind_ubo_shader(ctx, shader_type, &ubo_id);
- }
-}
-
static void vrend_draw_bind_const_shader(struct vrend_context *ctx,
int shader_type, bool new_program)
{
@@ -3101,11 +3072,21 @@ static void vrend_draw_bind_const_shader(struct vrend_context *ctx,
}
}
-static void vrend_draw_bind_const(struct vrend_context *ctx, bool new_program)
+static void vrend_draw_bind_objects(struct vrend_context *ctx, bool new_program)
{
+ int ubo_id = 0, sampler_id = 0;
for (int shader_type = PIPE_SHADER_VERTEX; shader_type <= ctx->sub->last_shader_idx; shader_type++) {
+ vrend_draw_bind_ubo_shader(ctx, shader_type, &ubo_id);
vrend_draw_bind_const_shader(ctx, shader_type, new_program);
+ vrend_draw_bind_samplers_shader(ctx, shader_type, &sampler_id);
}
+
+ if (vrend_state.use_core_profile && ctx->sub->prog->fs_stipple_loc != -1) {
+ glActiveTexture(GL_TEXTURE0 + sampler_id);
+ glBindTexture(GL_TEXTURE_2D, ctx->pstipple_tex_id);
+ glUniform1i(ctx->sub->prog->fs_stipple_loc, sampler_id);
+ }
+ ctx->sub->sampler_state_dirty = false;
}
void vrend_draw_vbo(struct vrend_context *ctx,
@@ -3232,11 +3213,7 @@ void vrend_draw_vbo(struct vrend_context *ctx,
vrend_use_program(ctx, ctx->sub->prog->id);
- vrend_draw_bind_const(ctx, new_program);
-
- vrend_draw_bind_samplers(ctx);
-
- vrend_draw_bind_ubo(ctx);
+ vrend_draw_bind_objects(ctx, new_program);
if (!ctx->sub->ve) {
fprintf(stderr,"illegal VE setup - skipping renderering\n");
--
2.14.3
More information about the virglrenderer-devel
mailing list