#include "core/kernel.hpp"
#include "core/resource.hpp"
+#include "util/u_math.h"
#include "pipe/p_context.h"
using namespace clover;
std::reverse(v.begin(), v.end());
}
+ ///
+ /// Pad buffer \a v to the next multiple of \a n.
+ ///
+ template<typename T>
+ void
+ align(T &v, size_t n) {
+ v.resize(util_align_npot(v.size(), n));
+ }
+
bool
msb(const std::vector<uint8_t> &s) {
if (PIPE_ENDIAN_NATIVE == PIPE_ENDIAN_LITTLE)
extend(w, marg.ext_type, marg.target_size);
byteswap(w, ctx.q->dev.endianness());
+ align(ctx.input, marg.target_align);
insert(ctx.input, w);
}
void
_cl_kernel::global_argument::bind(exec_context &ctx,
const clover::module::argument &marg) {
+ align(ctx.input, marg.target_align);
ctx.g_handles.push_back(allocate(ctx.input, marg.target_size));
ctx.g_buffers.push_back(obj->resource(ctx.q).pipe);
}
extend(v, module::argument::zero_ext, marg.target_size);
byteswap(v, ctx.q->dev.endianness());
+ align(ctx.input, marg.target_align);
insert(ctx.input, v);
ctx.mem_local += __storage;
extend(v, module::argument::zero_ext, marg.target_size);
byteswap(v, ctx.q->dev.endianness());
+ align(ctx.input, marg.target_align);
insert(ctx.input, v);
st = obj->resource(ctx.q).bind_surface(*ctx.q, false);
extend(v, module::argument::zero_ext, marg.target_size);
byteswap(v, ctx.q->dev.endianness());
+ align(ctx.input, marg.target_align);
insert(ctx.input, v);
st = obj->resource(ctx.q).bind_sampler_view(*ctx.q);
extend(v, module::argument::zero_ext, marg.target_size);
byteswap(v, ctx.q->dev.endianness());
+ align(ctx.input, marg.target_align);
insert(ctx.input, v);
st = obj->resource(ctx.q).bind_surface(*ctx.q, true);
TD.getSmallestLegalIntType(mod->getContext(), arg_size * 8) :
arg_type;
unsigned target_size = TD.getTypeStoreSize(target_type);
+ unsigned target_align = TD.getABITypeAlignment(target_type);
if (llvm::isa<llvm::PointerType>(arg_type) && arg.hasByValAttr()) {
arg_type =
default:
args.push_back(
module::argument(module::argument::global, arg_size,
- target_size, 0,
+ target_size, target_align,
module::argument::zero_ext));
break;
}
args.push_back(
module::argument(module::argument::scalar, arg_size,
- target_size, 0, ext_type));
+ target_size, target_align, ext_type));
}
}