Commit 9200682c authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜

Cleanup emit_vertex_data

parent 31b5564c
......@@ -25,9 +25,6 @@
#include <stdio.h>
#include "texture-swizzle.h"
#define ALIGN(x, y) (((x) + ((y) - 1)) & ~((y) - 1))
/* Space a group of 4-bits out. For instance, 0x7 -- that is, 0b111 -- would
* become 0b10101 */
......
......@@ -71,5 +71,6 @@ panfrost_reserve(struct panfrost_memory *mem, size_t sz)
#define inff INFINITY
#define R(...) #__VA_ARGS__
#define ALIGN(x, y) (((x) + ((y) - 1)) & ~((y) - 1))
#endif /* __PANDEV_H__ */
......@@ -16,6 +16,7 @@
#define __TEXSWZ_H__
#include <stdint.h>
#include "pandev.h"
void
trans_generate_space_filler_indices(void);
......
......@@ -793,51 +793,39 @@ trans_fragment_job(struct panfrost_context *ctx)
static void
trans_emit_vertex_data(struct panfrost_context *ctx)
{
{
/* TODO: Only update the dirtied buffers */
struct mali_attr attrs[PIPE_MAX_ATTRIBS];
for (int i = 0; i < ctx->vertex_buffer_count; ++i) {
struct pipe_vertex_buffer *buf = &ctx->vertex_buffers[i];
struct panfrost_resource *rsrc = (struct panfrost_resource *) (buf->buffer.resource);
/* Offset vertex count by draw_start to make sure we upload enough */
attrs[i].stride = buf->stride;
attrs[i].size = buf->stride * (ctx->payload_vertex.draw_start + ctx->vertex_count);
attrs[i].elements = panfrost_upload(&ctx->cmdstream, rsrc->cpu[0] + buf->buffer_offset /* + ctx->vertex->pipe[i].src_offset */, attrs[i].size, false) | 1;
}
ctx->payload_vertex.attributes = panfrost_upload(&ctx->cmdstream, attrs, ctx->vertex_buffer_count * sizeof(struct mali_attr), false);
/* TODO: Only update the dirtied buffers */
struct mali_attr attrs[PIPE_MAX_ATTRIBS];
struct mali_attr varyings[PIPE_MAX_ATTRIBS];
for (int i = 0; i < ctx->vertex_buffer_count; ++i) {
struct pipe_vertex_buffer *buf = &ctx->vertex_buffers[i];
struct panfrost_resource *rsrc = (struct panfrost_resource *) (buf->buffer.resource);
/* Offset vertex count by draw_start to make sure we upload enough */
attrs[i].stride = buf->stride;
attrs[i].size = buf->stride * (ctx->payload_vertex.draw_start + ctx->vertex_count);
attrs[i].elements = panfrost_upload(&ctx->cmdstream, rsrc->cpu[0] + buf->buffer_offset, attrs[i].size, false) | 1;
}
{
struct mali_attr varyings[PIPE_MAX_ATTRIBS];
/* height of the gl_Position varying, which is always(?) last */
int position_height = 0;
for (int i = 0; i < ctx->varying_count; ++i) {
int size = ctx->varyings_stride[i] * ctx->vertex_count;
varyings[i].elements = (ctx->varying_mem.gpu + ctx->varying_height) | 1;
varyings[i].size = size;
varyings[i].stride = ctx->varyings_stride[i];
/* Varyings appear to need 64-byte alignment */
size += 64 - (size & 63);
for (int i = 0; i < ctx->varying_count; ++i) {
varyings[i].elements = (ctx->varying_mem.gpu + ctx->varying_height) | 1;
varyings[i].size = ctx->varyings_stride[i] * ctx->vertex_count;
varyings[i].stride = ctx->varyings_stride[i];
if ((i + 1) == ctx->varying_count)
position_height = ctx->varying_height;
/* gl_Position varying is always last by convention */
if ((i + 1) == ctx->varying_count)
ctx->payload_tiler.position_varying = ctx->varying_mem.gpu + ctx->varying_height;
ctx->varying_height += size;
}
mali_ptr varyings_p = panfrost_upload(&ctx->cmdstream, &varyings, ctx->varying_count * sizeof(struct mali_attr), false);
ctx->payload_vertex.varyings = varyings_p;
ctx->payload_tiler.varyings = varyings_p;
ctx->payload_tiler.position_varying = ctx->varying_mem.gpu + position_height;
/* Varyings appear to need 64-byte alignment */
ctx->varying_height += ALIGN(varyings[i].size, 64);
}
ctx->payload_vertex.attributes = panfrost_upload(&ctx->cmdstream, attrs, ctx->vertex_buffer_count * sizeof(struct mali_attr), false);
mali_ptr varyings_p = panfrost_upload(&ctx->cmdstream, &varyings, ctx->varying_count * sizeof(struct mali_attr), false);
ctx->payload_vertex.varyings = varyings_p;
ctx->payload_tiler.varyings = varyings_p;
}
/* Go through dirty flags and actualise them in the cmdstream. */
......
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