nir_store_var(b, c_out, nir_channel(b, &tex->dest.ssa, 0), 0xFF);
midgard_compile_shader_nir(shader, program, false, 0, gpu_id, false, true);
+ ralloc_free(shader);
}
/* Compile and upload all possible blit shaders ahead-of-time to reduce draw
unsigned width = u_minify(image->width0, image->first_level);
unsigned height = u_minify(image->height0, image->first_level);
- struct mali_viewport viewport = {
- .clip_minx = -INFINITY,
- .clip_miny = -INFINITY,
- .clip_maxx = INFINITY,
- .clip_maxy = INFINITY,
- .clip_minz = 0.0,
- .clip_maxz = 1.0,
+ struct panfrost_transfer viewport = panfrost_pool_alloc(pool, MALI_VIEWPORT_LENGTH);
+ struct panfrost_transfer sampler = panfrost_pool_alloc(pool, MALI_MIDGARD_SAMPLER_LENGTH);
+ struct panfrost_transfer varying = panfrost_pool_alloc(pool, MALI_ATTRIBUTE_LENGTH);
+ struct panfrost_transfer varying_buffer = panfrost_pool_alloc(pool, MALI_ATTRIBUTE_BUFFER_LENGTH);
- .viewport0 = { 0, 0 },
- .viewport1 = { MALI_POSITIVE(width), MALI_POSITIVE(height) }
- };
+ pan_pack(viewport.cpu, VIEWPORT, cfg) {
+ cfg.scissor_maximum_x = width - 1; /* Inclusive */
+ cfg.scissor_maximum_y = height - 1;
+ }
- union mali_attr varying = {
- .elements = coordinates | MALI_ATTR_LINEAR,
- .stride = 4 * sizeof(float),
- .size = 4 * sizeof(float) * vertex_count,
- };
-
- struct mali_attr_meta varying_meta = {
- .index = 0,
- .unknown1 = 2,
- .swizzle = (MALI_CHANNEL_RED << 0) | (MALI_CHANNEL_GREEN << 3),
- .format = MALI_RGBA32F
- };
+ pan_pack(varying_buffer.cpu, ATTRIBUTE_BUFFER, cfg) {
+ cfg.pointer = coordinates;
+ cfg.stride = 4 * sizeof(float);
+ cfg.size = cfg.stride * vertex_count;
+ }
- struct mali_stencil_test stencil = {
- .mask = 0xFF,
- .func = MALI_FUNC_ALWAYS,
- .sfail = MALI_STENCIL_REPLACE,
- .dpfail = MALI_STENCIL_REPLACE,
- .dppass = MALI_STENCIL_REPLACE,
+ pan_pack(varying.cpu, ATTRIBUTE, cfg) {
+ cfg.buffer_index = 0;
+ cfg.format = (MALI_CHANNEL_R << 0) | (MALI_CHANNEL_G << 3) | (MALI_RGBA32F << 12);
+ }
+
+ struct mali_stencil_packed stencil;
+ pan_pack(&stencil, STENCIL, cfg) {
+ cfg.compare_function = MALI_FUNC_ALWAYS;
+ cfg.stencil_fail = MALI_STENCIL_OP_REPLACE;
+ cfg.depth_fail = MALI_STENCIL_OP_REPLACE;
+ cfg.depth_pass = MALI_STENCIL_OP_REPLACE;
};
union midgard_blend replace = {
.flags_lo = 0x20,
.work_count = 4,
},
- .coverage_mask = 0xF,
+ .coverage_mask = ~0,
.unknown2_3 = MALI_DEPTH_FUNC(MALI_FUNC_ALWAYS) | 0x10,
.unknown2_4 = 0x4e0,
.stencil_mask_front = ~0,
* textures, removing the need to separately key the blit shaders for
* 2D and 3D variants */
- struct panfrost_transfer texture_t = panfrost_pool_alloc(pool, sizeof(struct mali_texture_descriptor) + sizeof(mali_ptr) * 2 * MAX2(image->nr_samples, 1));
+ struct panfrost_transfer texture_t = panfrost_pool_alloc(pool, MALI_MIDGARD_TEXTURE_LENGTH + sizeof(mali_ptr) * 2 * MAX2(image->nr_samples, 1));
panfrost_new_texture(texture_t.cpu,
image->width0, image->height0,
MAX2(image->nr_samples, 1), 1,
- image->format, MALI_TEX_2D,
+ image->format, MALI_TEXTURE_DIMENSION_2D,
image->modifier,
image->first_level, image->last_level,
0, 0,
image->nr_samples,
0,
- (MALI_CHANNEL_RED << 0) | (MALI_CHANNEL_GREEN << 3) | (MALI_CHANNEL_BLUE << 6) | (MALI_CHANNEL_ALPHA << 9),
+ (MALI_CHANNEL_R << 0) | (MALI_CHANNEL_G << 3) | (MALI_CHANNEL_B << 6) | (MALI_CHANNEL_A << 9),
image->bo->gpu + image->first_layer *
panfrost_get_layer_stride(image->slices,
- image->type == MALI_TEX_3D,
+ image->dim == MALI_TEXTURE_DIMENSION_3D,
image->cubemap_stride, image->first_level),
image->slices);
- struct mali_sampler_descriptor sampler = {
- .filter_mode = MALI_SAMP_MAG_NEAREST | MALI_SAMP_MIN_NEAREST,
- .wrap_s = MALI_WRAP_CLAMP_TO_EDGE,
- .wrap_t = MALI_WRAP_CLAMP_TO_EDGE,
- .wrap_r = MALI_WRAP_CLAMP_TO_EDGE,
- };
+ pan_pack(sampler.cpu, MIDGARD_SAMPLER, cfg)
+ cfg.normalized_coordinates = false;
struct panfrost_transfer shader_meta_t = panfrost_pool_alloc(pool, sizeof(shader_meta) + 8 * sizeof(struct midgard_blend_rt));
memcpy(shader_meta_t.cpu, &shader_meta, sizeof(shader_meta));
struct midgard_payload_vertex_tiler payload = {
.prefix = {
- .draw_mode = MALI_TRIANGLES,
+ .draw_mode = MALI_DRAW_MODE_TRIANGLES,
.unknown_draw = 0x3000,
.index_count = MALI_POSITIVE(vertex_count)
},
.gl_enables = 0x7,
.position_varying = coordinates,
.textures = panfrost_pool_upload(pool, &texture_t.gpu, sizeof(texture_t.gpu)),
- .sampler_descriptor = panfrost_pool_upload(pool, &sampler, sizeof(sampler)),
+ .sampler_descriptor = sampler.gpu,
.shader = shader_meta_t.gpu,
- .varyings = panfrost_pool_upload(pool, &varying, sizeof(varying)),
- .varying_meta = panfrost_pool_upload(pool, &varying_meta, sizeof(varying_meta)),
- .viewport = panfrost_pool_upload(pool, &viewport, sizeof(viewport)),
+ .varyings = varying_buffer.gpu,
+ .varying_meta = varying.gpu,
+ .viewport = viewport.gpu,
.shared_memory = fbd
}
};