r600: restructure r600_create_vertex_fetch_shader() to remove memcpy()
Cc: mesa-stable
Signed-off-by: Patrick Lerda <patrick9876@free.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32184>
(cherry picked from commit 275535774c
)
This commit is contained in:

committed by
Dylan Baker

parent
617591e708
commit
f563ce8c7e
@@ -594,7 +594,7 @@
|
||||
"description": "r600: restructure r600_create_vertex_fetch_shader() to remove memcpy()",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null,
|
||||
"notes": null
|
||||
|
@@ -354,10 +354,14 @@ void *r600_create_vertex_fetch_shader(struct pipe_context *ctx,
|
||||
int i, j, r, fs_size;
|
||||
uint32_t buffer_mask = 0;
|
||||
struct r600_fetch_shader *shader;
|
||||
unsigned strides[PIPE_MAX_ATTRIBS];
|
||||
|
||||
assert(count < 32);
|
||||
|
||||
/* Allocate the CSO. */
|
||||
shader = CALLOC_STRUCT(r600_fetch_shader);
|
||||
if (unlikely(!shader))
|
||||
return NULL;
|
||||
|
||||
memset(&bc, 0, sizeof(bc));
|
||||
r600_bytecode_init(&bc, rctx->b.gfx_level, rctx->b.family,
|
||||
rctx->screen->has_compressed_msaa_texturing);
|
||||
@@ -379,10 +383,8 @@ void *r600_create_vertex_fetch_shader(struct pipe_context *ctx,
|
||||
alu.dst.chan = j;
|
||||
alu.dst.write = j == 3;
|
||||
alu.last = j == 3;
|
||||
if ((r = r600_bytecode_add_alu(&bc, &alu))) {
|
||||
r600_bytecode_clear(&bc);
|
||||
return NULL;
|
||||
}
|
||||
if (unlikely(r = r600_bytecode_add_alu(&bc, &alu)))
|
||||
goto fail;
|
||||
}
|
||||
} else {
|
||||
struct r600_bytecode_alu alu;
|
||||
@@ -396,13 +398,11 @@ void *r600_create_vertex_fetch_shader(struct pipe_context *ctx,
|
||||
alu.dst.chan = 3;
|
||||
alu.dst.write = 1;
|
||||
alu.last = 1;
|
||||
if ((r = r600_bytecode_add_alu(&bc, &alu))) {
|
||||
r600_bytecode_clear(&bc);
|
||||
return NULL;
|
||||
}
|
||||
if (unlikely(r = r600_bytecode_add_alu(&bc, &alu)))
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
strides[elements[i].vertex_buffer_index] = elements[i].src_stride;
|
||||
shader->strides[elements[i].vertex_buffer_index] = elements[i].src_stride;
|
||||
buffer_mask |= BITFIELD_BIT(elements[i].vertex_buffer_index);
|
||||
}
|
||||
|
||||
@@ -412,10 +412,9 @@ void *r600_create_vertex_fetch_shader(struct pipe_context *ctx,
|
||||
|
||||
desc = util_format_description(elements[i].src_format);
|
||||
|
||||
if (elements[i].src_offset > 65535) {
|
||||
r600_bytecode_clear(&bc);
|
||||
if (unlikely(elements[i].src_offset > 65535)) {
|
||||
R600_ERR("too big src_offset: %u\n", elements[i].src_offset);
|
||||
return NULL;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
memset(&vtx, 0, sizeof(vtx));
|
||||
@@ -435,18 +434,14 @@ void *r600_create_vertex_fetch_shader(struct pipe_context *ctx,
|
||||
vtx.offset = elements[i].src_offset;
|
||||
vtx.endian = endian;
|
||||
|
||||
if ((r = r600_bytecode_add_vtx(&bc, &vtx))) {
|
||||
r600_bytecode_clear(&bc);
|
||||
return NULL;
|
||||
}
|
||||
if (unlikely(r = r600_bytecode_add_vtx(&bc, &vtx)))
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r600_bytecode_add_cfinst(&bc, CF_OP_RET);
|
||||
|
||||
if ((r = r600_bytecode_build(&bc))) {
|
||||
r600_bytecode_clear(&bc);
|
||||
return NULL;
|
||||
}
|
||||
if (unlikely(r = r600_bytecode_build(&bc)))
|
||||
goto fail;
|
||||
|
||||
if (rctx->screen->b.debug_flags & DBG_FS) {
|
||||
fprintf(stderr, "--------------------------------------------------------------\n");
|
||||
@@ -462,23 +457,13 @@ void *r600_create_vertex_fetch_shader(struct pipe_context *ctx,
|
||||
|
||||
fs_size = bc.ndw*4;
|
||||
|
||||
/* Allocate the CSO. */
|
||||
shader = CALLOC_STRUCT(r600_fetch_shader);
|
||||
if (!shader) {
|
||||
r600_bytecode_clear(&bc);
|
||||
return NULL;
|
||||
}
|
||||
memcpy(shader->strides, strides, sizeof(strides));
|
||||
shader->buffer_mask = buffer_mask;
|
||||
|
||||
u_suballocator_alloc(&rctx->allocator_fetch_shader, fs_size, 256,
|
||||
&shader->offset,
|
||||
(struct pipe_resource**)&shader->buffer);
|
||||
if (!shader->buffer) {
|
||||
r600_bytecode_clear(&bc);
|
||||
FREE(shader);
|
||||
return NULL;
|
||||
}
|
||||
if (unlikely(!shader->buffer))
|
||||
goto fail;
|
||||
|
||||
bytecode = r600_buffer_map_sync_with_rings
|
||||
(&rctx->b, shader->buffer,
|
||||
@@ -496,6 +481,12 @@ void *r600_create_vertex_fetch_shader(struct pipe_context *ctx,
|
||||
|
||||
r600_bytecode_clear(&bc);
|
||||
return shader;
|
||||
|
||||
fail:
|
||||
r600_bytecode_clear(&bc);
|
||||
FREE(shader);
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
int eg_get_interpolator_index(unsigned interpolate, unsigned location)
|
||||
|
Reference in New Issue
Block a user