From 78370e879fb8853e67a71e289b9a35fad338a737 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 10 Mar 2015 15:55:00 +1000 Subject: [PATCH] renderer: add initial texture_query_lod support --- src/vrend_renderer.c | 3 +++ src/vrend_shader.c | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 7d5727f..9ab9cfd 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -5153,11 +5153,14 @@ void vrend_renderer_fill_caps(uint32_t set, uint32_t version, if (gl_ver >= 40) { caps->v1.bset.indep_blend_func = 1; caps->v1.bset.cube_map_array = 1; + caps->v1.bset.texture_query_lod = 1; } else { if (glewIsSupported("GL_ARB_draw_buffers_blend")) caps->v1.bset.indep_blend_func = 1; if (glewIsSupported("GL_ARB_texture_cube_map_array")) caps->v1.bset.cube_map_array = 1; + if (glewIsSupported("GL_ARB_texture_query_lod")) + caps->v1.bset.texture_query_lod = 1; } if (gl_ver >= 42) { diff --git a/src/vrend_shader.c b/src/vrend_shader.c index d997c0c..fd32428 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -109,6 +109,7 @@ struct dump_ctx { bool uses_sampler_ms; bool uses_sampler_buf; bool uses_sampler_rect; + bool uses_lodq; /* create a shader with lower left if upper left is primary variant or vice versa */ uint32_t shadow_samp_mask; @@ -881,6 +882,9 @@ static int translate_tex(struct dump_ctx *ctx, sampler_index = 1; + if (inst->Instruction.Opcode == TGSI_OPCODE_LODQ) + ctx->uses_lodq = true; + if (inst->Instruction.Opcode == TGSI_OPCODE_TXQ) { /* no lod parameter for txq for these */ if (inst->Texture.Texture != TGSI_TEXTURE_RECT && @@ -1002,7 +1006,9 @@ static int translate_tex(struct dump_ctx *ctx, else bias[0] = 0; - if (inst->Instruction.Opcode == TGSI_OPCODE_TXP) { + if (inst->Instruction.Opcode == TGSI_OPCODE_LODQ) { + tex_ext = "QueryLOD"; + } else if (inst->Instruction.Opcode == TGSI_OPCODE_TXP) { if (inst->Texture.Texture == TGSI_TEXTURE_CUBE || inst->Texture.Texture == TGSI_TEXTURE_2D_ARRAY || inst->Texture.Texture == TGSI_TEXTURE_1D_ARRAY) tex_ext = ""; else if (inst->Texture.NumOffsets == 1) @@ -1585,6 +1591,7 @@ iter_instruction(struct tgsi_iterate_context *iter, case TGSI_OPCODE_TXF: case TGSI_OPCODE_TXP: case TGSI_OPCODE_TXQ: + case TGSI_OPCODE_LODQ: ret = translate_tex(ctx, inst, sreg_index, srcs, dsts, writemask, dstconv, dtypeprefix); if (ret) return FALSE; @@ -1785,6 +1792,8 @@ static char *emit_header(struct dump_ctx *ctx, char *glsl_hdr) STRCAT_WITH_RET(glsl_hdr, "#extension GL_ARB_draw_instanced : require\n"); if (ctx->num_ubo) STRCAT_WITH_RET(glsl_hdr, "#extension GL_ARB_uniform_buffer_object : require\n"); + if (ctx->uses_lodq) + STRCAT_WITH_RET(glsl_hdr, "#extension GL_ARB_texture_query_lod : require\n"); return glsl_hdr; }