Commit 64f023d7 authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜

Depersistentify varyings descriptor

parent ac8d0d26
......@@ -34,6 +34,23 @@
/* TODO: What does this actually have to be? */
#define ALIGNMENT 128
/* Allocate a mapped chunk directly from a heap */
struct panfrost_transfer
panfrost_allocate_chunk(struct panfrost_context *ctx, size_t size, unsigned heap_id)
{
struct pb_slab_entry *entry = pb_slab_alloc(&ctx->slabs, size, heap_id);
struct panfrost_memory_entry *p_entry = (struct panfrost_memory_entry *) entry;
struct panfrost_memory *backing = (struct panfrost_memory *) entry->slab;
struct panfrost_transfer transfer = {
.cpu = backing->cpu + p_entry->offset,
.gpu = backing->gpu + p_entry->offset
};
return transfer;
}
/* Transient command stream pooling: command stream uploads try to simply copy
* into whereever we left off. If there isn't space, we allocate a new entry
* into the pool and copy there */
......
......@@ -140,28 +140,28 @@ panfrost_shader_compile(struct panfrost_context *ctx, struct mali_shader_meta *m
/* Setup gl_Position and its weirdo analogue */
unsigned default_vec4_swizzle = panfrost_get_default_swizzle(4);
struct mali_attr_meta position_meta = {
.index = 1,
.format = MALI_VARYING_POS,
struct mali_attr_meta position_metas[2] = {
{
.index = 1,
.format = MALI_VARYING_POS,
.swizzle = default_vec4_swizzle,
.unknown1 = 0x2,
};
struct mali_attr_meta position_meta_prime = {
.index = 1,
.format = MALI_RGBA16F,
.swizzle = default_vec4_swizzle,
.unknown1 = 0x2,
},
{
.index = 1,
.format = MALI_RGBA16F,
/* TODO: Wat? yyyy swizzle? */
.swizzle = 0x249,
.unknown1 = 0x0,
/* TODO: Wat? yyyy swizzle? */
.swizzle = 0x249,
.unknown1 = 0x0,
}
};
varyings->vertex_only_varyings[0] = position_meta;
varyings->vertex_only_varyings[1] = position_meta_prime;
/* Setup actual varyings. XXX: Don't assume vec4 */
struct mali_attr_meta mali_varyings[PIPE_MAX_ATTRIBS];
for (int i = 0; i < varying_count; ++i) {
struct mali_attr_meta vec4_varying_meta = {
.index = 0,
......@@ -174,15 +174,37 @@ panfrost_shader_compile(struct panfrost_context *ctx, struct mali_shader_meta *m
.src_offset = 8 * i,
};
varyings->varyings[i] = vec4_varying_meta;
mali_varyings[i] = vec4_varying_meta;
}
/* In this context, position_meta represents the implicit
* gl_FragCoord varying */
varyings->fragment_only_varyings[0] = position_meta;
varyings->fragment_only_varying_count = 1;
/* XXX: Where did this off-by-one come from again? :P
* (gl_Position probably) */
varyings->varying_count = varying_count - 1;
/* In this context, position_meta represents the implicit
* gl_FragCoord varying. So, upload all the varyings */
unsigned varyings_size = sizeof(struct mali_attr_meta) * varyings->varying_count;
unsigned vertex_size = sizeof(position_metas) + varyings_size;
unsigned fragment_size = varyings_size + sizeof(struct mali_attr_meta);
struct panfrost_transfer transfer = panfrost_allocate_chunk(ctx, vertex_size + fragment_size, HEAP_DESCRIPTOR);
/* Copy varyings in the follow order:
* - Position 1, 2
* - Varyings 1, 2, ..., n
* - Varyings 1, 2, ..., n (duplicate)
* - Position 1
*/
memcpy(transfer.cpu, position_metas, sizeof(position_metas));
memcpy(transfer.cpu + sizeof(position_metas), mali_varyings, varyings_size);
memcpy(transfer.cpu + vertex_size, mali_varyings, varyings_size);
memcpy(transfer.cpu + vertex_size + varyings_size, &position_metas[0], sizeof(struct mali_attr_meta));
/* Point to the descriptor */
varyings->varyings_buffer_cpu = transfer.cpu;
varyings->varyings_descriptor = transfer.gpu;
varyings->varyings_descriptor_fragment = transfer.gpu + vertex_size;
}
}
......@@ -48,21 +48,6 @@
#include "pan_blend_shaders.h"
#include "pan_wallpaper.h"
static struct panfrost_transfer
panfrost_allocate_chunk(struct panfrost_context *ctx, size_t size, unsigned heap_id)
{
struct pb_slab_entry *entry = pb_slab_alloc(&ctx->slabs, size, heap_id);
struct panfrost_memory_entry *p_entry = (struct panfrost_memory_entry *) entry;
struct panfrost_memory *backing = (struct panfrost_memory *) entry->slab;
struct panfrost_transfer transfer = {
.cpu = backing->cpu + p_entry->offset,
.gpu = backing->gpu + p_entry->offset
};
return transfer;
}
static void
panfrost_flush(
struct pipe_context *pipe,
......@@ -93,29 +78,6 @@ static bool USE_TRANSACTION_ELIMINATION = false;
* can force it regardless of gallium saying we don't have it */
static bool FORCE_MSAA = true;
/* Descriptor is generated along with the shader compiler */
static void
panfrost_upload_varyings_descriptor(struct panfrost_context *ctx)
{
struct panfrost_varyings *varyings = &ctx->vs->variants[ctx->vs->active_variant].varyings;
/* First, upload gl_Position varyings */
mali_ptr gl_Position = panfrost_upload(&ctx->cmdstream_persistent, varyings->vertex_only_varyings, sizeof(varyings->vertex_only_varyings), true);
/* Then, upload normal varyings for vertex shaders */
panfrost_upload_sequential(&ctx->cmdstream_persistent, varyings->varyings, sizeof(varyings->varyings[0]) * varyings->varying_count);
/* Then, upload normal varyings for fragment shaders (duplicating) */
mali_ptr varyings_fragment = panfrost_upload_sequential(&ctx->cmdstream_persistent, varyings->varyings, sizeof(varyings->varyings[0]) * varyings->varying_count);
/* Finally, upload gl_FragCoord varying */
panfrost_upload_sequential(&ctx->cmdstream_persistent, varyings->fragment_only_varyings, sizeof(varyings->fragment_only_varyings[0]) * varyings->fragment_only_varying_count);
ctx->payload_vertex.postfix.varying_meta = gl_Position;
ctx->payload_tiler.postfix.varying_meta = varyings_fragment;
}
/* TODO: Sample size, etc */
static void
......@@ -1105,7 +1067,10 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
* fragment shader, I suppose, but it's generated with the
* vertex shader so */
panfrost_upload_varyings_descriptor(ctx);
struct panfrost_varyings *varyings = &ctx->vs->variants[ctx->vs->active_variant].varyings;
ctx->payload_vertex.postfix.varying_meta = varyings->varyings_descriptor;
ctx->payload_tiler.postfix.varying_meta = varyings->varyings_descriptor_fragment;
}
if (ctx->dirty & PAN_DIRTY_FS) {
......
......@@ -253,10 +253,10 @@ struct panfrost_varyings {
unsigned varying_count;
unsigned varying_buffer_count;
struct mali_attr_meta vertex_only_varyings[2];
struct mali_attr_meta varyings[PIPE_MAX_ATTRIBS];
struct mali_attr_meta fragment_only_varyings[1];
int fragment_only_varying_count;
/* Map of the actual varyings buffer */
uint8_t *varyings_buffer_cpu;
mali_ptr varyings_descriptor;
mali_ptr varyings_descriptor_fragment;
};
/* Variants bundle together to form the backing CSO, bundling multiple
......
......@@ -127,6 +127,9 @@ panfrost_reserve(struct panfrost_memory *mem, size_t sz)
return mem->gpu + (mem->stack_bottom - sz);
}
struct panfrost_transfer
panfrost_allocate_chunk(struct panfrost_context *ctx, size_t size, unsigned heap_id);
#include <math.h>
#define inff INFINITY
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment