[virglrenderer-devel] [PATCH 3/6] add ARB_derivative_control support
Dave Airlie
airlied at gmail.com
Mon May 21 06:09:34 UTC 2018
From: Dave Airlie <airlied at redhat.com>
adds the new TGSI opcodes for fine derivs
---
src/virgl_hw.h | 1 +
src/vrend_renderer.c | 3 +++
src/vrend_shader.c | 13 +++++++++++++
3 files changed, 17 insertions(+)
diff --git a/src/virgl_hw.h b/src/virgl_hw.h
index 6dc5791..a0c4874 100644
--- a/src/virgl_hw.h
+++ b/src/virgl_hw.h
@@ -239,6 +239,7 @@ struct virgl_caps_bool_set1 {
unsigned has_sample_shading:1;
unsigned has_cull:1;
unsigned conditional_render_inverted:1;
+ unsigned derivative_control:1;
};
/* endless expansion capabilites - current gallium has 252 formats */
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index 4ba9fed..10a1c0a 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -6958,11 +6958,14 @@ void vrend_renderer_fill_caps(uint32_t set, uint32_t version,
if (gl_ver >= 45) {
caps->v1.bset.has_cull = 1;
caps->v1.bset.conditional_render_inverted = 1;
+ caps->v1.bset.derivative_control = 1;
} else {
if (epoxy_has_gl_extension("GL_ARB_cull_distance"))
caps->v1.bset.has_cull = 1;
if (epoxy_has_gl_extension("GL_ARB_conditional_render_inverted"))
caps->v1.bset.conditional_render_inverted = 1;
+ if (epoxy_has_gl_extension("GL_ARB_derivative_control"))
+ caps->v1.bset.derivative_control = 1;
}
if (epoxy_has_gl_extension("GL_EXT_texture_mirror_clamp") ||
diff --git a/src/vrend_shader.c b/src/vrend_shader.c
index e852336..6b634f0 100644
--- a/src/vrend_shader.c
+++ b/src/vrend_shader.c
@@ -158,6 +158,7 @@ struct dump_ctx {
bool uses_sample_shading;
bool uses_gpu_shader5;
bool write_mul_temp;
+ bool derivative_control;
};
static inline const char *tgsi_proc_to_prefix(int shader_type)
@@ -2198,6 +2199,16 @@ iter_instruction(struct tgsi_iterate_context *iter,
emit_op1("dFdy");
EMIT_BUF_WITH_RET(ctx, buf);
break;
+ case TGSI_OPCODE_DDX_FINE:
+ ctx->derivative_control = true;
+ emit_op1("dFdxFine");
+ EMIT_BUF_WITH_RET(ctx, buf);
+ break;
+ case TGSI_OPCODE_DDY_FINE:
+ ctx->derivative_control = true;
+ emit_op1("dFdyFine");
+ EMIT_BUF_WITH_RET(ctx, buf);
+ break;
case TGSI_OPCODE_RCP:
snprintf(buf, 255, "%s = %s(1.0/(%s));\n", dsts[0], dstconv, srcs[0]);
EMIT_BUF_WITH_RET(ctx, buf);
@@ -2626,6 +2637,8 @@ static char *emit_header(struct dump_ctx *ctx, char *glsl_hdr)
STRCAT_WITH_RET(glsl_hdr, "#extension GL_ARB_gpu_shader5 : require\n");
if (ctx->num_cull_dist_prop || ctx->key->prev_stage_num_cull_out)
STRCAT_WITH_RET(glsl_hdr, "#extension GL_ARB_cull_distance : require\n");
+ if (ctx->derivative_control)
+ STRCAT_WITH_RET(glsl_hdr, "#extension GL_ARB_derivative_control : require\n");
}
return glsl_hdr;
}
--
2.14.3
More information about the virglrenderer-devel
mailing list