if (v3d->uploader)
u_upload_destroy(v3d->uploader);
+ if (v3d->state_uploader)
+ u_upload_destroy(v3d->state_uploader);
slab_destroy_child(&v3d->transfer_pool);
v3d->uploader = u_upload_create_default(&v3d->base);
v3d->base.stream_uploader = v3d->uploader;
v3d->base.const_uploader = v3d->uploader;
+ v3d->state_uploader = u_upload_create(&v3d->base,
+ 4096,
+ PIPE_BIND_CONSTANT_BUFFER,
+ PIPE_USAGE_STREAM, 0);
v3d->blitter = util_blitter_create(pctx);
if (!v3d->blitter)
};
struct v3d_compiled_shader {
- struct v3d_bo *bo;
+ struct pipe_resource *resource;
+ uint32_t offset;
union {
struct v3d_prog_data *base;
/** Sync object that our RCL or TFU job will update as its out_sync. */
uint32_t out_sync;
+ /* Stream uploader used by gallium internals. This could also be used
+ * by driver internals, but we tend to use the v3d_cl.h interfaces
+ * instead.
+ */
struct u_upload_mgr *uploader;
+ /* State uploader used inside the driver. This is for packing bits of
+ * long-term state inside buffers.
+ */
+ struct u_upload_mgr *state_uploader;
/** @{ Current pipeline state objects */
struct pipe_scissor_state scissor;
#include "util/u_memory.h"
#include "util/ralloc.h"
#include "util/hash_table.h"
+#include "util/u_upload_mgr.h"
#include "tgsi/tgsi_dump.h"
#include "tgsi/tgsi_parse.h"
#include "compiler/nir/nir.h"
v3d_set_shader_uniform_dirty_flags(shader);
- shader->bo = v3d_bo_alloc(v3d->screen, shader_size, "shader");
- v3d_bo_map(shader->bo);
- memcpy(shader->bo->map, qpu_insts, shader_size);
+ u_upload_data(v3d->state_uploader, 0, shader_size, 8,
+ qpu_insts, &shader->offset, &shader->resource);
free(qpu_insts);
return shader;
}
+static void
+v3d_free_compiled_shader(struct v3d_compiled_shader *shader)
+{
+ pipe_resource_reference(&shader->resource, NULL);
+ ralloc_free(shader);
+}
+
static void
v3d_setup_shared_key(struct v3d_context *v3d, struct v3d_key *key,
struct v3d_texture_stateobj *texstate)
if (key->shader_state == so) {
struct v3d_compiled_shader *shader = entry->data;
_mesa_hash_table_remove(ht, entry);
- v3d_bo_unreference(&shader->bo);
if (shader == *last_compile)
*last_compile = NULL;
- ralloc_free(shader);
+ v3d_free_compiled_shader(shader);
}
}
hash_table_foreach(v3d->fs_cache, entry) {
struct v3d_compiled_shader *shader = entry->data;
- v3d_bo_unreference(&shader->bo);
- ralloc_free(shader);
+ v3d_free_compiled_shader(shader);
_mesa_hash_table_remove(v3d->fs_cache, entry);
}
hash_table_foreach(v3d->vs_cache, entry) {
struct v3d_compiled_shader *shader = entry->data;
- v3d_bo_unreference(&shader->bo);
- ralloc_free(shader);
+ v3d_free_compiled_shader(shader);
_mesa_hash_table_remove(v3d->vs_cache, entry);
}
shader.fragment_shader_propagate_nans = true;
shader.coordinate_shader_code_address =
- cl_address(v3d->prog.cs->bo, 0);
+ cl_address(v3d_resource(v3d->prog.cs->resource)->bo,
+ v3d->prog.cs->offset);
shader.vertex_shader_code_address =
- cl_address(v3d->prog.vs->bo, 0);
+ cl_address(v3d_resource(v3d->prog.vs->resource)->bo,
+ v3d->prog.vs->offset);
shader.fragment_shader_code_address =
- cl_address(v3d->prog.fs->bo, 0);
+ cl_address(v3d_resource(v3d->prog.fs->resource)->bo,
+ v3d->prog.fs->offset);
/* XXX: Use combined input/output size flag in the common
* case.