mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-05 13:20:10 +01:00
clover: bind constant buffer if one is provided
We will use that with NIR as it is easier to manage the constant buffer inside clover instead of letting all drivers to deal with it. Signed-off-by: Karol Herbst <kherbst@redhat.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Francisco Jerez <currojerez@riseup.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6569>
This commit is contained in:
parent
af85985250
commit
adbfff6eae
4 changed files with 25 additions and 17 deletions
|
|
@ -36,6 +36,19 @@ kernel::kernel(clover::program &prog, const std::string &name,
|
|||
if (marg.semantic == module::argument::general)
|
||||
_args.emplace_back(argument::create(marg));
|
||||
}
|
||||
for (auto &dev : prog.devices()) {
|
||||
auto &m = prog.build(dev).binary;
|
||||
auto msym = find(name_equals(name), m.syms);
|
||||
const auto f = id_type_equals(msym.section, module::section::data_constant);
|
||||
if (!any_of(f, m.secs))
|
||||
continue;
|
||||
|
||||
auto mconst = find(f, m.secs);
|
||||
auto rb = std::make_unique<root_buffer>(prog.context(),
|
||||
CL_MEM_COPY_HOST_PTR | CL_MEM_READ_ONLY,
|
||||
mconst.size, mconst.data.data());
|
||||
_constant_buffers.emplace(&dev, std::move(rb));
|
||||
}
|
||||
}
|
||||
|
||||
template<typename V>
|
||||
|
|
@ -163,7 +176,7 @@ kernel::exec_context::bind(intrusive_ptr<command_queue> _q,
|
|||
auto &m = kern.program().build(q->device()).binary;
|
||||
auto msym = find(name_equals(kern.name()), m.syms);
|
||||
auto margs = msym.args;
|
||||
auto msec = find(id_equals(msym.section), m.secs);
|
||||
auto msec = find(id_type_equals(msym.section, module::section::text_executable), m.secs);
|
||||
auto explicit_arg = kern._args.begin();
|
||||
|
||||
for (auto &marg : margs) {
|
||||
|
|
@ -217,6 +230,13 @@ kernel::exec_context::bind(intrusive_ptr<command_queue> _q,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case module::argument::constant_buffer: {
|
||||
auto arg = argument::create(marg);
|
||||
cl_mem buf = kern._constant_buffers.at(&q->device()).get();
|
||||
arg->set(q->device().address_bits() / 8, &buf);
|
||||
arg->bind(*this, marg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#ifndef CLOVER_CORE_KERNEL_HPP
|
||||
#define CLOVER_CORE_KERNEL_HPP
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include "core/object.hpp"
|
||||
|
|
@ -242,6 +243,7 @@ namespace clover {
|
|||
};
|
||||
|
||||
std::vector<std::unique_ptr<argument>> _args;
|
||||
std::map<device *, std::unique_ptr<root_buffer> > _constant_buffers;
|
||||
std::string _name;
|
||||
exec_context exec;
|
||||
const ref_holder program_ref;
|
||||
|
|
|
|||
|
|
@ -76,7 +76,8 @@ namespace clover {
|
|||
grid_dimension,
|
||||
grid_offset,
|
||||
image_size,
|
||||
image_format
|
||||
image_format,
|
||||
constant_buffer
|
||||
};
|
||||
|
||||
argument(enum type type, size_t size,
|
||||
|
|
|
|||
|
|
@ -347,21 +347,6 @@ namespace clover {
|
|||
const std::string &name;
|
||||
};
|
||||
|
||||
class id_equals {
|
||||
public:
|
||||
id_equals(const uint32_t id) : id(id) {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool
|
||||
operator()(const T &x) const {
|
||||
return x.id == id;
|
||||
}
|
||||
|
||||
private:
|
||||
const uint32_t id;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class key_equals_t {
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue