mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 05:08:08 +02:00
clover: use pipe_image_view for images instead of set_compute_resources
Long term we want to git rid of set_compute_resources, this is just one piece. The other bit would be to use the proper const buffer interfaces, but because that path is only hit with r600/radeonsi I won't touch it. Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Francisco Jerez <currojerez@riseup.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7069>
This commit is contained in:
parent
eb965719ab
commit
3aead7198b
4 changed files with 30 additions and 8 deletions
|
|
@ -83,6 +83,8 @@ kernel::launch(command_queue &q,
|
|||
|
||||
q.pipe->set_sampler_views(q.pipe, PIPE_SHADER_COMPUTE, 0,
|
||||
exec.sviews.size(), exec.sviews.data());
|
||||
q.pipe->set_shader_images(q.pipe, PIPE_SHADER_COMPUTE, 0,
|
||||
exec.iviews.size(), exec.iviews.data());
|
||||
q.pipe->set_compute_resources(q.pipe, 0, exec.resources.size(),
|
||||
exec.resources.data());
|
||||
q.pipe->set_global_binding(q.pipe, 0, exec.g_buffers.size(),
|
||||
|
|
@ -99,6 +101,8 @@ kernel::launch(command_queue &q,
|
|||
|
||||
q.pipe->set_global_binding(q.pipe, 0, exec.g_buffers.size(), NULL, NULL);
|
||||
q.pipe->set_compute_resources(q.pipe, 0, exec.resources.size(), NULL);
|
||||
q.pipe->set_shader_images(q.pipe, PIPE_SHADER_COMPUTE, 0,
|
||||
exec.iviews.size(), NULL);
|
||||
q.pipe->set_sampler_views(q.pipe, PIPE_SHADER_COMPUTE, 0,
|
||||
exec.sviews.size(), NULL);
|
||||
q.pipe->bind_sampler_states(q.pipe, PIPE_SHADER_COMPUTE, 0,
|
||||
|
|
@ -279,6 +283,7 @@ kernel::exec_context::unbind() {
|
|||
input.clear();
|
||||
samplers.clear();
|
||||
sviews.clear();
|
||||
iviews.clear();
|
||||
resources.clear();
|
||||
g_buffers.clear();
|
||||
g_handles.clear();
|
||||
|
|
@ -599,20 +604,17 @@ kernel::image_wr_argument::set(size_t size, const void *value) {
|
|||
void
|
||||
kernel::image_wr_argument::bind(exec_context &ctx,
|
||||
const module::argument &marg) {
|
||||
auto v = bytes(ctx.resources.size());
|
||||
auto v = bytes(ctx.iviews.size());
|
||||
|
||||
extend(v, module::argument::zero_ext, marg.target_size);
|
||||
byteswap(v, ctx.q->device().endianness());
|
||||
align(ctx.input, marg.target_align);
|
||||
insert(ctx.input, v);
|
||||
|
||||
st = img->resource_in(*ctx.q).bind_surface(*ctx.q, true);
|
||||
ctx.resources.push_back(st);
|
||||
ctx.iviews.push_back(img->resource_in(*ctx.q).create_image_view(*ctx.q));
|
||||
}
|
||||
|
||||
void
|
||||
kernel::image_wr_argument::unbind(exec_context &ctx) {
|
||||
img->resource_in(*ctx.q).unbind_surface(*ctx.q, st);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ namespace clover {
|
|||
std::vector<uint8_t> input;
|
||||
std::vector<void *> samplers;
|
||||
std::vector<pipe_sampler_view *> sviews;
|
||||
std::vector<pipe_image_view> iviews;
|
||||
std::vector<pipe_surface *> resources;
|
||||
std::vector<pipe_resource *> g_buffers;
|
||||
std::vector<size_t> g_handles;
|
||||
|
|
@ -226,9 +227,6 @@ namespace clover {
|
|||
virtual void bind(exec_context &ctx,
|
||||
const module::argument &marg);
|
||||
virtual void unbind(exec_context &ctx);
|
||||
|
||||
private:
|
||||
pipe_surface *st;
|
||||
};
|
||||
|
||||
class sampler_argument : public argument {
|
||||
|
|
|
|||
|
|
@ -112,6 +112,26 @@ resource::unbind_sampler_view(command_queue &q,
|
|||
q.pipe->sampler_view_destroy(q.pipe, st);
|
||||
}
|
||||
|
||||
pipe_image_view
|
||||
resource::create_image_view(command_queue &q) {
|
||||
pipe_image_view view;
|
||||
view.resource = pipe;
|
||||
view.format = pipe->format;
|
||||
view.access = 0;
|
||||
view.shader_access = PIPE_IMAGE_ACCESS_WRITE;
|
||||
|
||||
if (pipe->target == PIPE_BUFFER) {
|
||||
view.u.buf.offset = 0;
|
||||
view.u.buf.size = obj.size();
|
||||
} else {
|
||||
view.u.tex.first_layer = 0;
|
||||
view.u.tex.last_layer = 0;
|
||||
view.u.tex.level = 0;
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
pipe_surface *
|
||||
resource::bind_surface(command_queue &q, bool rw) {
|
||||
pipe_surface info {};
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ namespace clover {
|
|||
pipe_surface *bind_surface(command_queue &q, bool rw);
|
||||
void unbind_surface(command_queue &q, pipe_surface *st);
|
||||
|
||||
pipe_image_view create_image_view(command_queue &q);
|
||||
|
||||
pipe_resource *pipe;
|
||||
vector offset;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue