}
void panfrost_sampler_desc_init_bifrost(const struct pipe_sampler_state *cso,
- uint32_t *_hw)
+ struct mali_bifrost_sampler_packed *hw)
{
- struct bifrost_sampler_descriptor *hw = (struct bifrost_sampler_descriptor *) _hw;
- *hw = (struct bifrost_sampler_descriptor) {
- .unk1 = 0x1,
- .wrap_s = translate_tex_wrap(cso->wrap_s),
- .wrap_t = translate_tex_wrap(cso->wrap_t),
- .wrap_r = translate_tex_wrap(cso->wrap_r),
- .unk8 = 0x8,
- .min_filter = cso->min_img_filter == PIPE_TEX_FILTER_NEAREST,
- .norm_coords = cso->normalized_coords,
- .mip_filter = cso->min_mip_filter == PIPE_TEX_MIPFILTER_LINEAR,
- .mag_filter = cso->mag_img_filter == PIPE_TEX_FILTER_LINEAR,
- .min_lod = FIXED_16(cso->min_lod, false), /* clamp at 0 */
- .max_lod = FIXED_16(cso->max_lod, false),
- };
+ pan_pack(hw, BIFROST_SAMPLER, cfg) {
+ cfg.magnify_linear = cso->mag_img_filter == PIPE_TEX_FILTER_LINEAR;
+ cfg.minify_linear = cso->min_img_filter == PIPE_TEX_FILTER_LINEAR;
+ cfg.mipmap_mode = pan_pipe_to_mipmode(cso->min_mip_filter);
+ cfg.normalized_coordinates = cso->normalized_coords;
- /* If necessary, we disable mipmapping in the sampler descriptor by
- * clamping the LOD as tight as possible (from 0 to epsilon,
- * essentially -- remember these are fixed point numbers, so
- * epsilon=1/256) */
+ cfg.lod_bias = FIXED_16(cso->lod_bias, true);
+ cfg.minimum_lod = FIXED_16(cso->min_lod, false);
+ cfg.maximum_lod = FIXED_16(cso->max_lod, false);
- if (cso->min_mip_filter == PIPE_TEX_MIPFILTER_NONE)
- hw->max_lod = hw->min_lod + 1;
+ cfg.wrap_mode_s = translate_tex_wrap(cso->wrap_s);
+ cfg.wrap_mode_t = translate_tex_wrap(cso->wrap_t);
+ cfg.wrap_mode_r = translate_tex_wrap(cso->wrap_r);
+
+ cfg.compare_function = panfrost_sampler_compare_func(cso);
+ cfg.seamless_cube_map = cso->seamless_cube_map;
+ }
}
static void
if (!ctx->sampler_count[stage])
return;
- size_t desc_size = sizeof(struct bifrost_sampler_descriptor);
- assert(sizeof(struct bifrost_sampler_descriptor) == MALI_MIDGARD_SAMPLER_LENGTH);
+ size_t desc_size = MALI_BIFROST_SAMPLER_LENGTH;
+ assert(MALI_BIFROST_SAMPLER_LENGTH == MALI_MIDGARD_SAMPLER_LENGTH);
size_t sz = desc_size * ctx->sampler_count[stage];
struct panfrost_transfer T = panfrost_pool_alloc(&batch->pool, sz);
#include "pan_job.h"
void panfrost_sampler_desc_init(const struct pipe_sampler_state *cso, struct mali_midgard_sampler_packed *hw);
-void panfrost_sampler_desc_init_bifrost(const struct pipe_sampler_state *cso, uint32_t *hw);
+void panfrost_sampler_desc_init_bifrost(const struct pipe_sampler_state *cso, struct mali_bifrost_sampler_packed *hw);
void
panfrost_vt_init(struct panfrost_context *ctx,
so->base = *cso;
if (device->quirks & IS_BIFROST)
- panfrost_sampler_desc_init_bifrost(cso, (uint32_t *) &so->hw);
+ panfrost_sampler_desc_init_bifrost(cso, (struct mali_bifrost_sampler_packed *) &so->hw);
else
panfrost_sampler_desc_init(cso, &so->hw);
return (int) (x * 256.0);
}
-/* Bifrost sampler descriptors look pretty similar */
-
-#define BIFROST_SAMP_MIN_NEAREST (1)
-#define BIFROST_SAMP_MAG_LINEAR (1)
-
-struct bifrost_sampler_descriptor {
- uint8_t unk1;
-
- enum mali_wrap_mode wrap_r : 4;
- enum mali_wrap_mode wrap_t : 4;
- enum mali_wrap_mode wrap_s : 4;
- uint8_t unk8 : 4;
-
- uint8_t unk2 : 1;
- uint8_t norm_coords : 1;
- uint8_t unk3 : 1;
- uint8_t min_filter : 1;
- uint8_t zero1 : 1;
- uint8_t mag_filter : 1;
- uint8_t mip_filter : 1;
-
- int16_t min_lod;
- int16_t max_lod;
-
- uint64_t zero2;
- uint64_t zero3;
- uint64_t zero4;
-} __attribute__((packed));
-
/* From presentations, 16x16 tiles externally. Use shift for fast computation
* of tile numbers. */
static void
pandecode_samplers(mali_ptr samplers, unsigned sampler_count, int job_no, bool is_bifrost)
{
- struct pandecode_mapped_memory *smem = pandecode_find_mapped_gpu_mem_containing(samplers);
-
- if (!smem)
- return;
-
- if (is_bifrost) {
- struct bifrost_sampler_descriptor *s;
-
- for (int i = 0; i < sampler_count; ++i) {
- s = pandecode_fetch_gpu_mem(smem, samplers + sizeof(*s) * i, sizeof(*s));
-
- pandecode_log("struct bifrost_sampler_descriptor sampler_descriptor_%"PRIx64"_%d_%d = {\n", samplers + sizeof(*s) * i, job_no, i);
- pandecode_indent++;
-
- if (s->unk1 != 1) {
- pandecode_msg("XXX: unk1 tripped\n");
- pandecode_prop("unk1 = 0x%x", s->unk1);
- }
-
- pandecode_prop("wrap_s = %s", mali_wrap_mode_as_str(s->wrap_s));
- pandecode_prop("wrap_t = %s", mali_wrap_mode_as_str(s->wrap_t));
- pandecode_prop("wrap_r = %s", mali_wrap_mode_as_str(s->wrap_r));
-
- if (s->unk8 != 0x8) {
- pandecode_msg("XXX: unk8 tripped\n");
- pandecode_prop("unk8 = 0x%x", s->unk8);
- }
-
- pandecode_prop("unk2 = 0x%x", s->unk2);
- pandecode_prop("unk3 = 0x%x", s->unk3);
- pandecode_prop("min_filter = %s", s->min_filter ? "nearest" : "linear");
- pandecode_prop("norm_coords = 0x%x", s->norm_coords & 0x1);
- pandecode_prop("zero1 = 0x%x", s->zero1 & 0x1);
- pandecode_prop("mip_filter = %s", s->mip_filter ? "linear" : "nearest");
- pandecode_prop("mag_filter = %s", s->mag_filter ? "linear" : "nearest");
-
- pandecode_prop("min_lod = FIXED_16(%f)", DECODE_FIXED_16(s->min_lod));
- pandecode_prop("max_lod = FIXED_16(%f)", DECODE_FIXED_16(s->max_lod));
-
- if (s->zero1 || s->zero2 || s->zero3 || s->zero4) {
- pandecode_msg("XXX: sampler zero tripped\n");
- pandecode_prop("zero = 0x%" PRIx8 ", 0x%" PRIx64 ", 0x%" PRIx64 ", 0x%" PRIx64 "\n", s->zero1, s->zero2, s->zero3, s->zero4);
- }
-
- pandecode_indent--;
- pandecode_log("};\n");
- }
- } else {
- for (int i = 0; i < sampler_count; ++i)
+ for (int i = 0; i < sampler_count; ++i) {
+ if (is_bifrost) {
+ DUMP_ADDR("Sampler", BIFROST_SAMPLER, samplers + (MALI_BIFROST_SAMPLER_LENGTH * i), 1);
+ } else {
DUMP_ADDR("Sampler", MIDGARD_SAMPLER, samplers + (MALI_MIDGARD_SAMPLER_LENGTH * i), 1);
+ }
}
}
<field name="Border Color A" size="32" start="7:0" type="float" default="0.0"/>
</struct>
+ <struct name="Bifrost Sampler" size="8">
+ <field name="Type" size="4" start="0:0" type="uint" default="1"/>
+ <field name="Wrap Mode R" size="4" start="0:8" type="Wrap Mode" default="Clamp to Edge"/>
+ <field name="Wrap Mode T" size="4" start="0:12" type="Wrap Mode" default="Clamp to Edge"/>
+ <field name="Wrap Mode S" size="4" start="0:16" type="Wrap Mode" default="Clamp to Edge"/>
+ <field name="Seamless Cube Map" size="1" start="0:23" type="bool" default="true"/>
+ <field name="Normalized Coordinates" size="1" start="0:25" type="bool" default="true"/>
+ <field name="Minify Linear" size="1" start="0:27" type="bool" default="false"/>
+ <field name="Magnify Linear" size="1" start="0:28" type="bool" default="false"/>
+ <field name="Mipmap Mode" size="2" start="0:30" type="Mipmap Mode" default="Nearest"/>
+ <field name="Minimum LOD" size="13" start="1:0" type="uint" default="0"/>
+ <field name="Compare Function" size="3" start="1:13" type="Func" default="Never"/>
+ <field name="Maximum LOD" size="13" start="1:16" type="uint" default="0"/>
+ <field name="LOD bias" size="16" start="2:0" type="uint" default="0"/>
+ </struct>
+
<struct name="Stencil">
<field name="Reference Value" size="8" start="0" type="uint"/>
<field name="Mask" size="8" start="8" type="uint" default="0xFF"/>