diff options
author | Arno Messiaen <[email protected]> | 2019-09-17 23:40:03 +0200 |
---|---|---|
committer | Vasily Khoruzhick <[email protected]> | 2019-10-31 06:29:31 +0000 |
commit | a9391a1a01dea4867d3c950687bc63dedbe853c8 (patch) | |
tree | 9f839e1c9397b5bb7fdda440fe7a856236d44a47 /src/gallium | |
parent | 9890590fba9d7a7c0d70c9f234b49338d0af2cf3 (diff) |
lima: add cubemap support
Signed-off-by: Arno Messiaen <[email protected]>
Reviewed-by: Vasily Khoruzhick <[email protected]>
Reviewed-by: Erico Nunes <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/lima/ir/pp/codegen.c | 27 | ||||
-rw-r--r-- | src/gallium/drivers/lima/ir/pp/nir.c | 1 | ||||
-rw-r--r-- | src/gallium/drivers/lima/lima_draw.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/lima/lima_screen.c | 1 | ||||
-rw-r--r-- | src/gallium/drivers/lima/lima_texture.c | 13 | ||||
-rw-r--r-- | src/gallium/drivers/lima/lima_texture.h | 9 |
6 files changed, 45 insertions, 8 deletions
diff --git a/src/gallium/drivers/lima/ir/pp/codegen.c b/src/gallium/drivers/lima/ir/pp/codegen.c index b2947f300f2..14c2617e3e8 100644 --- a/src/gallium/drivers/lima/ir/pp/codegen.c +++ b/src/gallium/drivers/lima/ir/pp/codegen.c @@ -90,6 +90,10 @@ static void ppir_codegen_encode_varying(ppir_node *node, void *code) f->imm.source_type = 3; f->imm.perspective = 1; break; + case ppir_op_load_coords: + /* num_components == 3 implies cubemap as we don't support 3D textures */ + f->imm.source_type = num_components == 3 ? 2 : 0; + break; default: break; } @@ -99,7 +103,13 @@ static void ppir_codegen_encode_varying(ppir_node *node, void *code) f->reg.mask = dest->write_mask << (index & 0x3); if (load->num_src) { - f->reg.source_type = 1; + /* num_components == 3 implies cubemap as we don't support 3D textures */ + if (num_components == 3) { + f->reg.source_type = 2; + f->reg.perspective = 1; + } else { + f->reg.source_type = 1; + } ppir_src *src = &load->src; index = ppir_target_get_src_reg_index(src); f->reg.source = index >> 2; @@ -117,7 +127,20 @@ static void ppir_codegen_encode_texld(ppir_node *node, void *code) f->index = ldtex->sampler; f->lod_bias_en = 0; - f->type = ppir_codegen_sampler_type_2d; + + switch (ldtex->sampler_dim) { + case GLSL_SAMPLER_DIM_2D: + case GLSL_SAMPLER_DIM_RECT: + case GLSL_SAMPLER_DIM_EXTERNAL: + f->type = ppir_codegen_sampler_type_2d; + break; + case GLSL_SAMPLER_DIM_CUBE: + f->type = ppir_codegen_sampler_type_cube; + break; + default: + break; + } + f->offset_en = 0; f->unknown_2 = 0x39001; } diff --git a/src/gallium/drivers/lima/ir/pp/nir.c b/src/gallium/drivers/lima/ir/pp/nir.c index 6baf4ec93bf..62e0808c1c7 100644 --- a/src/gallium/drivers/lima/ir/pp/nir.c +++ b/src/gallium/drivers/lima/ir/pp/nir.c @@ -461,6 +461,7 @@ static ppir_node *ppir_emit_tex(ppir_block *block, nir_instr *ni) switch (instr->sampler_dim) { case GLSL_SAMPLER_DIM_2D: + case GLSL_SAMPLER_DIM_CUBE: case GLSL_SAMPLER_DIM_RECT: case GLSL_SAMPLER_DIM_EXTERNAL: break; diff --git a/src/gallium/drivers/lima/lima_draw.c b/src/gallium/drivers/lima/lima_draw.c index 7706ee112aa..9753343409e 100644 --- a/src/gallium/drivers/lima/lima_draw.c +++ b/src/gallium/drivers/lima/lima_draw.c @@ -290,7 +290,7 @@ lima_pack_reload_plbu_cmd(struct lima_context *ctx) memset(td, 0, lima_min_tex_desc_size); lima_texture_desc_set_res(ctx, td, fb->base.cbufs[0]->texture, 0, 0); td->unnorm_coords = 1; - td->texture_2d = 1; + td->texture_type = LIMA_TEXTURE_TYPE_2D; td->min_img_filter_nearest = 1; td->mag_img_filter_nearest = 1; td->wrap_s_clamp_to_edge = 1; diff --git a/src/gallium/drivers/lima/lima_screen.c b/src/gallium/drivers/lima/lima_screen.c index cd9122672b6..30b199e777f 100644 --- a/src/gallium/drivers/lima/lima_screen.c +++ b/src/gallium/drivers/lima/lima_screen.c @@ -273,6 +273,7 @@ lima_screen_is_format_supported(struct pipe_screen *pscreen, case PIPE_TEXTURE_1D: case PIPE_TEXTURE_2D: case PIPE_TEXTURE_RECT: + case PIPE_TEXTURE_CUBE: break; default: return false; diff --git a/src/gallium/drivers/lima/lima_texture.c b/src/gallium/drivers/lima/lima_texture.c index b25d84ec20f..39433c05801 100644 --- a/src/gallium/drivers/lima/lima_texture.c +++ b/src/gallium/drivers/lima/lima_texture.c @@ -124,8 +124,17 @@ lima_update_tex_desc(struct lima_context *ctx, struct lima_sampler_state *sample memset(desc, 0, desc_size); - /* 2D texture */ - desc->texture_2d = 1; + switch (texture->base.target) { + case PIPE_TEXTURE_2D: + case PIPE_TEXTURE_RECT: + desc->texture_type = LIMA_TEXTURE_TYPE_2D; + break; + case PIPE_TEXTURE_CUBE: + desc->texture_type = LIMA_TEXTURE_TYPE_CUBE; + break; + default: + break; + } if (!sampler->base.normalized_coords) desc->unnorm_coords = 1; diff --git a/src/gallium/drivers/lima/lima_texture.h b/src/gallium/drivers/lima/lima_texture.h index e9b896763ea..7f4b9ee5330 100644 --- a/src/gallium/drivers/lima/lima_texture.h +++ b/src/gallium/drivers/lima/lima_texture.h @@ -27,6 +27,9 @@ #define lima_min_tex_desc_size 64 +#define LIMA_TEXTURE_TYPE_2D 2 +#define LIMA_TEXTURE_TYPE_CUBE 5 + typedef struct __attribute__((__packed__)) { /* Word 0 */ uint32_t format : 6; @@ -39,9 +42,9 @@ typedef struct __attribute__((__packed__)) { /* Word 1-3 */ uint32_t unknown_1_1: 7; uint32_t unnorm_coords: 1; - uint32_t unknown_1_2: 2; - uint32_t texture_2d: 1; - uint32_t unknown_1_3: 13; + uint32_t unknown_1_2: 1; + uint32_t texture_type: 3; + uint32_t unknown_1_3: 12; uint32_t miplevels: 4; uint32_t min_mipfilter_1: 9; /* 0x0 for linear, 0x1ff for nearest */ uint32_t unknown_2_1: 3; |