From f60737c039f9834810a7916a980e306c45f648ac Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 31 Jul 2018 08:02:20 +1000 Subject: [PATCH] add support for shader clock. This was pretty trivial. Reviewed-by: Erik Faye-Lund --- src/gallium/auxiliary/tgsi/tgsi_info.c | 4 +++- src/gallium/include/pipe/p_shader_tokens.h | 3 ++- src/virgl_hw.h | 1 + src/vrend_renderer.c | 4 ++++ src/vrend_shader.c | 7 +++++++ 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c index 2162f84..e2e3875 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_info.c +++ b/src/gallium/auxiliary/tgsi/tgsi_info.c @@ -262,7 +262,8 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] = { 1, 1, 0, 0, 0, 0, COMP, "DFLR", TGSI_OPCODE_DFLR }, { 1, 1, 0, 0, 0, 0, COMP, "DROUND", TGSI_OPCODE_DROUND }, { 1, 1, 0, 0, 0, 0, COMP, "DSSG", TGSI_OPCODE_DSSG }, - { 1, 2, 0, 0, 0, 0, COMP, "DDIV", TGSI_OPCODE_DDIV } + { 1, 2, 0, 0, 0, 0, COMP, "DDIV", TGSI_OPCODE_DDIV }, + { 1, 0, 0, 0, 0, 0, OTHR, "CLOCK", TGSI_OPCODE_CLOCK } }; const struct tgsi_opcode_info * @@ -354,6 +355,7 @@ tgsi_opcode_infer_type( uint opcode ) case TGSI_OPCODE_LSB: case TGSI_OPCODE_UMSB: case TGSI_OPCODE_D2U: + case TGSI_OPCODE_CLOCK: return TGSI_TYPE_UNSIGNED; case TGSI_OPCODE_ARL: case TGSI_OPCODE_ARR: diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h index ad99116..94fb929 100644 --- a/src/gallium/include/pipe/p_shader_tokens.h +++ b/src/gallium/include/pipe/p_shader_tokens.h @@ -569,7 +569,8 @@ struct tgsi_property_data { #define TGSI_OPCODE_DROUND 221 /* nvc0 */ #define TGSI_OPCODE_DSSG 222 #define TGSI_OPCODE_DDIV 223 -#define TGSI_OPCODE_LAST 224 +#define TGSI_OPCODE_CLOCK 224 +#define TGSI_OPCODE_LAST 225 /** * Opcode is the operation code to execute. A given operation defines the diff --git a/src/virgl_hw.h b/src/virgl_hw.h index 70b0b24..1df9d0e 100644 --- a/src/virgl_hw.h +++ b/src/virgl_hw.h @@ -228,6 +228,7 @@ enum virgl_formats { #define VIRGL_CAP_FB_NO_ATTACH (1 << 8) #define VIRGL_CAP_ROBUST_BUFFER_ACCESS (1 << 9) #define VIRGL_CAP_TGSI_FBFETCH (1 << 10) +#define VIRGL_CAP_SHADER_CLOCK (1 << 11) /* virgl bind flags - these are compatible with mesa 10.5 gallium. * but are fixed, no other should be passed to virgl either. diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 4ff74aa..2d20a33 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -122,6 +122,7 @@ enum features_id feat_sample_mask, feat_sample_shading, feat_samplers, + feat_shader_clock, feat_ssbo, feat_ssbo_barrier, feat_stencil_texturing, @@ -185,6 +186,7 @@ static const struct { [feat_sample_mask] = { 32, 31, { "GL_ARB_texture_multisample" } }, [feat_sample_shading] = { 40, UNAVAIL, { "GL_ARB_sample_shading" } }, [feat_samplers] = { 33, 30, { "GL_ARB_sampler_objects" } }, + [feat_shader_clock] = { UNAVAIL, UNAVAIL, { "GL_ARB_shader_clock" } }, [feat_ssbo] = { 43, 31, { "GL_ARB_shader_storage_buffer_object" } }, [feat_ssbo_barrier] = { 43, 31, {} }, [feat_stencil_texturing] = { 43, 31, { "GL_ARB_stencil_texturing" } }, @@ -8161,6 +8163,8 @@ static void vrend_renderer_fill_caps_v2(int gl_ver, int gles_ver, union virgl_c if (has_feature(feat_framebuffer_fetch)) caps->v2.capability_bits |= VIRGL_CAP_TGSI_FBFETCH; + if (has_feature(feat_shader_clock)) + caps->v2.capability_bits |= VIRGL_CAP_SHADER_CLOCK; } void vrend_renderer_fill_caps(uint32_t set, UNUSED uint32_t version, diff --git a/src/vrend_shader.c b/src/vrend_shader.c index dbe8e2a..363f4e2 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -61,6 +61,7 @@ extern int vrend_dump_shaders; #define SHADER_REQ_IMAGE_SIZE (1 << 17) #define SHADER_REQ_TXQS (1 << 18) #define SHADER_REQ_FBFETCH (1 << 19) +#define SHADER_REQ_SHADER_CLOCK (1 << 20) struct vrend_shader_io { unsigned name; @@ -237,6 +238,7 @@ static const struct vrend_shader_table shader_req_table[] = { { SHADER_REQ_IMAGE_SIZE, "GL_ARB_shader_image_size" }, { SHADER_REQ_TXQS, "GL_ARB_shader_texture_image_samples" }, { SHADER_REQ_FBFETCH, "GL_EXT_shader_framebuffer_fetch" }, + { SHADER_REQ_SHADER_CLOCK, "GL_ARB_shader_clock" }, }; enum vrend_type_qualifier { @@ -3894,6 +3896,11 @@ iter_instruction(struct tgsi_iterate_context *iter, if (ret) return FALSE; break; + case TGSI_OPCODE_CLOCK: + ctx->shader_req_bits |= SHADER_REQ_SHADER_CLOCK; + snprintf(buf, 255, "%s = uintBitsToFloat(clock2x32ARB());\n", dsts[0]); + EMIT_BUF_WITH_RET(ctx, buf); + break; default: fprintf(stderr,"failed to convert opcode %d\n", inst->Instruction.Opcode); break;