panfrost: XMLify Bifrost samplers
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6195>
This commit is contained in:
parent
f74186baa5
commit
b10c3c869d
|
@ -427,30 +427,25 @@ void panfrost_sampler_desc_init(const struct pipe_sampler_state *cso,
|
||||||
}
|
}
|
||||||
|
|
||||||
void panfrost_sampler_desc_init_bifrost(const struct pipe_sampler_state *cso,
|
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;
|
pan_pack(hw, BIFROST_SAMPLER, cfg) {
|
||||||
*hw = (struct bifrost_sampler_descriptor) {
|
cfg.magnify_linear = cso->mag_img_filter == PIPE_TEX_FILTER_LINEAR;
|
||||||
.unk1 = 0x1,
|
cfg.minify_linear = cso->min_img_filter == PIPE_TEX_FILTER_LINEAR;
|
||||||
.wrap_s = translate_tex_wrap(cso->wrap_s),
|
cfg.mipmap_mode = pan_pipe_to_mipmode(cso->min_mip_filter);
|
||||||
.wrap_t = translate_tex_wrap(cso->wrap_t),
|
cfg.normalized_coordinates = cso->normalized_coords;
|
||||||
.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),
|
|
||||||
};
|
|
||||||
|
|
||||||
/* If necessary, we disable mipmapping in the sampler descriptor by
|
cfg.lod_bias = FIXED_16(cso->lod_bias, true);
|
||||||
* clamping the LOD as tight as possible (from 0 to epsilon,
|
cfg.minimum_lod = FIXED_16(cso->min_lod, false);
|
||||||
* essentially -- remember these are fixed point numbers, so
|
cfg.maximum_lod = FIXED_16(cso->max_lod, false);
|
||||||
* epsilon=1/256) */
|
|
||||||
|
|
||||||
if (cso->min_mip_filter == PIPE_TEX_MIPFILTER_NONE)
|
cfg.wrap_mode_s = translate_tex_wrap(cso->wrap_s);
|
||||||
hw->max_lod = hw->min_lod + 1;
|
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
|
static void
|
||||||
|
@ -1332,8 +1327,8 @@ panfrost_emit_sampler_descriptors(struct panfrost_batch *batch,
|
||||||
if (!ctx->sampler_count[stage])
|
if (!ctx->sampler_count[stage])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
size_t desc_size = sizeof(struct bifrost_sampler_descriptor);
|
size_t desc_size = MALI_BIFROST_SAMPLER_LENGTH;
|
||||||
assert(sizeof(struct bifrost_sampler_descriptor) == MALI_MIDGARD_SAMPLER_LENGTH);
|
assert(MALI_BIFROST_SAMPLER_LENGTH == MALI_MIDGARD_SAMPLER_LENGTH);
|
||||||
|
|
||||||
size_t sz = desc_size * ctx->sampler_count[stage];
|
size_t sz = desc_size * ctx->sampler_count[stage];
|
||||||
struct panfrost_transfer T = panfrost_pool_alloc(&batch->pool, sz);
|
struct panfrost_transfer T = panfrost_pool_alloc(&batch->pool, sz);
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#include "pan_job.h"
|
#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(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
|
void
|
||||||
panfrost_vt_init(struct panfrost_context *ctx,
|
panfrost_vt_init(struct panfrost_context *ctx,
|
||||||
|
|
|
@ -605,7 +605,7 @@ panfrost_create_sampler_state(
|
||||||
so->base = *cso;
|
so->base = *cso;
|
||||||
|
|
||||||
if (device->quirks & IS_BIFROST)
|
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
|
else
|
||||||
panfrost_sampler_desc_init(cso, &so->hw);
|
panfrost_sampler_desc_init(cso, &so->hw);
|
||||||
|
|
||||||
|
|
|
@ -1271,35 +1271,6 @@ FIXED_16(float x, bool allow_negative)
|
||||||
return (int) (x * 256.0);
|
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
|
/* From presentations, 16x16 tiles externally. Use shift for fast computation
|
||||||
* of tile numbers. */
|
* of tile numbers. */
|
||||||
|
|
||||||
|
|
|
@ -2422,56 +2422,12 @@ pandecode_textures(mali_ptr textures, unsigned texture_count, int job_no, bool i
|
||||||
static void
|
static void
|
||||||
pandecode_samplers(mali_ptr samplers, unsigned sampler_count, int job_no, bool is_bifrost)
|
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);
|
for (int i = 0; i < sampler_count; ++i) {
|
||||||
|
if (is_bifrost) {
|
||||||
if (!smem)
|
DUMP_ADDR("Sampler", BIFROST_SAMPLER, samplers + (MALI_BIFROST_SAMPLER_LENGTH * i), 1);
|
||||||
return;
|
} else {
|
||||||
|
|
||||||
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)
|
|
||||||
DUMP_ADDR("Sampler", MIDGARD_SAMPLER, samplers + (MALI_MIDGARD_SAMPLER_LENGTH * i), 1);
|
DUMP_ADDR("Sampler", MIDGARD_SAMPLER, samplers + (MALI_MIDGARD_SAMPLER_LENGTH * i), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,22 @@
|
||||||
<field name="Border Color A" size="32" start="7:0" type="float" default="0.0"/>
|
<field name="Border Color A" size="32" start="7:0" type="float" default="0.0"/>
|
||||||
</struct>
|
</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">
|
<struct name="Stencil">
|
||||||
<field name="Reference Value" size="8" start="0" type="uint"/>
|
<field name="Reference Value" size="8" start="0" type="uint"/>
|
||||||
<field name="Mask" size="8" start="8" type="uint" default="0xFF"/>
|
<field name="Mask" size="8" start="8" type="uint" default="0xFF"/>
|
||||||
|
|
Loading…
Reference in New Issue