MALI_WRAP_MIRRORED_REPEAT = 0xC
};
+/* Shared across both command stream and Midgard, and even with Bifrost */
+
+enum mali_texture_type {
+ MALI_TEX_CUBE = 0x0,
+ MALI_TEX_1D = 0x1,
+ MALI_TEX_2D = 0x2,
+ MALI_TEX_3D = 0x3
+};
+
/* 8192x8192 */
#define MAX_MIP_LEVELS (13)
/* Cubemap bloats everything up */
-#define MAX_FACES (6)
+#define MAX_CUBE_FACES (6)
/* For each pointer, there is an address and optionally also a stride */
#define MAX_ELEMENTS (2)
/* Corresponds to the type passed to glTexImage2D and so forth */
-/* For usage1 */
-#define MALI_TEX_3D (0x04)
-
/* Flags for usage2 */
#define MALI_TEX_MANUAL_STRIDE (0x20)
unsigned swizzle : 12;
enum mali_format format : 8;
- unsigned usage1 : 3;
- unsigned is_not_cubemap : 1;
+ unsigned srgb : 1;
+ unsigned unknown1 : 1;
+
+ enum mali_texture_type type : 2;
+
unsigned usage2 : 8;
} __attribute__((packed));
uint32_t unknown6;
uint32_t unknown7;
- mali_ptr payload[MAX_MIP_LEVELS * MAX_FACES * MAX_ELEMENTS];
+ mali_ptr payload[MAX_MIP_LEVELS * MAX_CUBE_FACES * MAX_ELEMENTS];
} __attribute__((packed));
/* Used as part of filter_mode */
printf(".");
switch (format) {
- DEFINE_CASE(TEXTURE_2D, "2d");
- DEFINE_CASE(TEXTURE_3D, "3d");
- DEFINE_CASE(TEXTURE_CUBE, "cube");
+ DEFINE_CASE(MALI_TEX_1D, "1d");
+ DEFINE_CASE(MALI_TEX_2D, "2d");
+ DEFINE_CASE(MALI_TEX_3D, "3d");
+ DEFINE_CASE(MALI_TEX_CUBE, "cube");
default:
- printf("fmt_%d", format);
- break;
+ unreachable("Bad format");
}
}
/* Specific format in question */
print_texture_format(texture->format);
+ assert(texture->zero == 0);
+
/* Instruction "modifiers" parallel the ALU instructions. */
if (texture->shadow)
#include <stdint.h>
#include <stdbool.h>
+#include "panfrost-job.h"
#define MIDGARD_DBG_MSGS 0x0001
#define MIDGARD_DBG_SHADERS 0x0002
#define TEXTURE_OP_LOD 0x12 /* textureLod */
#define TEXTURE_OP_TEXEL_FETCH 0x14 /* texelFetch */
-/* Texture format types, found in format */
-#define TEXTURE_CUBE 0x00
-#define TEXTURE_2D 0x02
-#define TEXTURE_3D 0x03
-
typedef struct
__attribute__((__packed__))
{
unsigned cont : 1;
unsigned last : 1;
- unsigned format : 4;
+ enum mali_texture_type format : 2;
+ unsigned zero : 2;
/* Is a register used to specify the
* LOD/bias/offset? If set, use the `bias` field as
midgard_tex_format(enum glsl_sampler_dim dim)
{
switch (dim) {
+ case GLSL_SAMPLER_DIM_1D:
+ case GLSL_SAMPLER_DIM_BUF:
+ return MALI_TEX_1D;
+
case GLSL_SAMPLER_DIM_2D:
case GLSL_SAMPLER_DIM_EXTERNAL:
- return TEXTURE_2D;
+ return MALI_TEX_2D;
case GLSL_SAMPLER_DIM_3D:
- return TEXTURE_3D;
+ return MALI_TEX_3D;
case GLSL_SAMPLER_DIM_CUBE:
- return TEXTURE_CUBE;
+ return MALI_TEX_CUBE;
default:
DBG("Unknown sampler dim type\n");
ctx->dirty |= PAN_DIRTY_FS;
}
+static enum mali_texture_type
+panfrost_translate_texture_type(enum pipe_texture_target t)
+{
+ switch (t) {
+ case PIPE_BUFFER:
+ case PIPE_TEXTURE_1D:
+ case PIPE_TEXTURE_1D_ARRAY:
+ return MALI_TEX_1D;
+
+ case PIPE_TEXTURE_2D:
+ case PIPE_TEXTURE_2D_ARRAY:
+ case PIPE_TEXTURE_RECT:
+ return MALI_TEX_2D;
+
+ case PIPE_TEXTURE_3D:
+ return MALI_TEX_3D;
+
+ case PIPE_TEXTURE_CUBE:
+ case PIPE_TEXTURE_CUBE_ARRAY:
+ return MALI_TEX_CUBE;
+
+ default:
+ unreachable("Unknown target");
+ }
+}
+
static struct pipe_sampler_view *
panfrost_create_sampler_view(
struct pipe_context *pctx,
.swizzle = panfrost_translate_swizzle_4(desc->swizzle),
.format = format,
- .usage1 = (texture->target == PIPE_TEXTURE_3D) ? MALI_TEX_3D : 0,
- .is_not_cubemap = texture->target != PIPE_TEXTURE_CUBE,
+ .srgb = false,
+ .type = panfrost_translate_texture_type(texture->target),
.usage2 = usage2_layout
},
}
#undef DEFINE_CASE
+#define DEFINE_CASE(name) case MALI_TEX_## name: return "MALI_TEX_" #name
+static char *
+pandecode_texture_type(enum mali_texture_type type)
+{
+ switch (type) {
+ DEFINE_CASE(1D);
+ DEFINE_CASE(2D);
+ DEFINE_CASE(3D);
+ DEFINE_CASE(CUBE);
+
+ default:
+ unreachable("Unknown case");
+ }
+}
+#undef DEFINE_CASE
+
static inline char *
pandecode_decode_fbd_type(enum mali_fbd_type type)
{
pandecode_replay_swizzle(f.swizzle);
pandecode_prop("format = %s", pandecode_format_name(f.format));
-
- pandecode_prop("usage1 = 0x%" PRIx32, f.usage1);
- pandecode_prop("is_not_cubemap = %" PRId32, f.is_not_cubemap);
+ pandecode_prop("type = %s", pandecode_texture_type(f.type));
+ pandecode_prop("srgb = %" PRId32, f.srgb);
+ pandecode_prop("unknown1 = %" PRId32, f.unknown1);
pandecode_prop("usage2 = 0x%" PRIx32, f.usage2);
pandecode_indent--;
bool manual_stride = f.usage2 & MALI_TEX_MANUAL_STRIDE;
/* Miptree for each face */
- if (!f.is_not_cubemap)
+ if (f.type == MALI_TEX_CUBE)
bitmap_count *= 6;
/* Array of textures */