mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 06:48:06 +02:00
clover: Switch samplers to the new model.
Tested-by: Tom Stellard <thomas.stellard@amd.com>
This commit is contained in:
parent
d6f7afc3ed
commit
04d0ab9f64
7 changed files with 57 additions and 57 deletions
|
|
@ -28,64 +28,62 @@ using namespace clover;
|
|||
PUBLIC cl_sampler
|
||||
clCreateSampler(cl_context d_ctx, cl_bool norm_mode,
|
||||
cl_addressing_mode addr_mode, cl_filter_mode filter_mode,
|
||||
cl_int *errcode_ret) try {
|
||||
cl_int *r_errcode) try {
|
||||
auto &ctx = obj(d_ctx);
|
||||
|
||||
ret_error(errcode_ret, CL_SUCCESS);
|
||||
ret_error(r_errcode, CL_SUCCESS);
|
||||
return new sampler(ctx, norm_mode, addr_mode, filter_mode);
|
||||
|
||||
} catch (error &e) {
|
||||
ret_error(errcode_ret, e);
|
||||
ret_error(r_errcode, e);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PUBLIC cl_int
|
||||
clRetainSampler(cl_sampler s) {
|
||||
if (!s)
|
||||
throw error(CL_INVALID_SAMPLER);
|
||||
|
||||
s->retain();
|
||||
clRetainSampler(cl_sampler d_s) try {
|
||||
obj(d_s).retain();
|
||||
return CL_SUCCESS;
|
||||
|
||||
} catch (error &e) {
|
||||
return e.get();
|
||||
}
|
||||
|
||||
PUBLIC cl_int
|
||||
clReleaseSampler(cl_sampler s) {
|
||||
if (!s)
|
||||
throw error(CL_INVALID_SAMPLER);
|
||||
|
||||
if (s->release())
|
||||
delete s;
|
||||
clReleaseSampler(cl_sampler d_s) try {
|
||||
if (obj(d_s).release())
|
||||
delete pobj(d_s);
|
||||
|
||||
return CL_SUCCESS;
|
||||
|
||||
} catch (error &e) {
|
||||
return e.get();
|
||||
}
|
||||
|
||||
PUBLIC cl_int
|
||||
clGetSamplerInfo(cl_sampler s, cl_sampler_info param,
|
||||
clGetSamplerInfo(cl_sampler d_s, cl_sampler_info param,
|
||||
size_t size, void *r_buf, size_t *r_size) try {
|
||||
property_buffer buf { r_buf, size, r_size };
|
||||
|
||||
if (!s)
|
||||
throw error(CL_INVALID_SAMPLER);
|
||||
auto &s = obj(d_s);
|
||||
|
||||
switch (param) {
|
||||
case CL_SAMPLER_REFERENCE_COUNT:
|
||||
buf.as_scalar<cl_uint>() = s->ref_count();
|
||||
buf.as_scalar<cl_uint>() = s.ref_count();
|
||||
break;
|
||||
|
||||
case CL_SAMPLER_CONTEXT:
|
||||
buf.as_scalar<cl_context>() = &s->ctx;
|
||||
buf.as_scalar<cl_context>() = desc(s.ctx);
|
||||
break;
|
||||
|
||||
case CL_SAMPLER_NORMALIZED_COORDS:
|
||||
buf.as_scalar<cl_bool>() = s->norm_mode();
|
||||
buf.as_scalar<cl_bool>() = s.norm_mode();
|
||||
break;
|
||||
|
||||
case CL_SAMPLER_ADDRESSING_MODE:
|
||||
buf.as_scalar<cl_addressing_mode>() = s->addr_mode();
|
||||
buf.as_scalar<cl_addressing_mode>() = s.addr_mode();
|
||||
break;
|
||||
|
||||
case CL_SAMPLER_FILTER_MODE:
|
||||
buf.as_scalar<cl_filter_mode>() = s->filter_mode();
|
||||
buf.as_scalar<cl_filter_mode>() = s.filter_mode();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ namespace clover {
|
|||
class image3d;
|
||||
class platform;
|
||||
class program;
|
||||
typedef struct _cl_sampler sampler;
|
||||
class sampler;
|
||||
|
||||
///
|
||||
/// Class that represents an error that can be converted to an
|
||||
|
|
|
|||
|
|
@ -441,7 +441,7 @@ kernel::sampler_argument::set(size_t size, const void *value) {
|
|||
if (size != sizeof(cl_sampler))
|
||||
throw error(CL_INVALID_ARG_SIZE);
|
||||
|
||||
s = *(cl_sampler *)value;
|
||||
s = &obj(*(cl_sampler *)value);
|
||||
_set = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -203,4 +203,7 @@ struct _cl_program :
|
|||
struct _cl_command_queue :
|
||||
public clover::descriptor<clover::command_queue, _cl_command_queue> {};
|
||||
|
||||
struct _cl_sampler :
|
||||
public clover::descriptor<clover::sampler, _cl_sampler> {};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ namespace clover {
|
|||
friend class root_resource;
|
||||
friend class mapping;
|
||||
friend class hard_event;
|
||||
friend struct ::_cl_sampler;
|
||||
friend class sampler;
|
||||
friend class kernel;
|
||||
friend class clover::timestamp::query;
|
||||
friend class clover::timestamp::current;
|
||||
|
|
|
|||
|
|
@ -25,30 +25,30 @@
|
|||
|
||||
using namespace clover;
|
||||
|
||||
_cl_sampler::_cl_sampler(clover::context &ctx, bool norm_mode,
|
||||
cl_addressing_mode addr_mode,
|
||||
cl_filter_mode filter_mode) :
|
||||
sampler::sampler(context &ctx, bool norm_mode,
|
||||
cl_addressing_mode addr_mode,
|
||||
cl_filter_mode filter_mode) :
|
||||
ctx(ctx), _norm_mode(norm_mode),
|
||||
_addr_mode(addr_mode), _filter_mode(filter_mode) {
|
||||
}
|
||||
|
||||
bool
|
||||
_cl_sampler::norm_mode() {
|
||||
sampler::norm_mode() {
|
||||
return _norm_mode;
|
||||
}
|
||||
|
||||
cl_addressing_mode
|
||||
_cl_sampler::addr_mode() {
|
||||
sampler::addr_mode() {
|
||||
return _addr_mode;
|
||||
}
|
||||
|
||||
cl_filter_mode
|
||||
_cl_sampler::filter_mode() {
|
||||
sampler::filter_mode() {
|
||||
return _filter_mode;
|
||||
}
|
||||
|
||||
void *
|
||||
_cl_sampler::bind(clover::command_queue &q) {
|
||||
sampler::bind(command_queue &q) {
|
||||
struct pipe_sampler_state info {};
|
||||
|
||||
info.normalized_coords = norm_mode();
|
||||
|
|
@ -68,6 +68,6 @@ _cl_sampler::bind(clover::command_queue &q) {
|
|||
}
|
||||
|
||||
void
|
||||
_cl_sampler::unbind(clover::command_queue &q, void *st) {
|
||||
sampler::unbind(command_queue &q, void *st) {
|
||||
q.pipe->delete_sampler_state(q.pipe, st);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,29 +27,28 @@
|
|||
#include "core/queue.hpp"
|
||||
|
||||
namespace clover {
|
||||
typedef struct _cl_sampler sampler;
|
||||
class sampler : public ref_counter, public _cl_sampler {
|
||||
public:
|
||||
sampler(context &ctx, bool norm_mode,
|
||||
cl_addressing_mode addr_mode,
|
||||
cl_filter_mode filter_mode);
|
||||
|
||||
bool norm_mode();
|
||||
cl_addressing_mode addr_mode();
|
||||
cl_filter_mode filter_mode();
|
||||
|
||||
context &ctx;
|
||||
|
||||
friend class kernel;
|
||||
|
||||
private:
|
||||
void *bind(command_queue &q);
|
||||
void unbind(command_queue &q, void *st);
|
||||
|
||||
bool _norm_mode;
|
||||
cl_addressing_mode _addr_mode;
|
||||
cl_filter_mode _filter_mode;
|
||||
};
|
||||
}
|
||||
|
||||
struct _cl_sampler : public clover::ref_counter {
|
||||
public:
|
||||
_cl_sampler(clover::context &ctx, bool norm_mode,
|
||||
cl_addressing_mode addr_mode, cl_filter_mode filter_mode);
|
||||
|
||||
bool norm_mode();
|
||||
cl_addressing_mode addr_mode();
|
||||
cl_filter_mode filter_mode();
|
||||
|
||||
clover::context &ctx;
|
||||
|
||||
friend class clover::kernel;
|
||||
|
||||
private:
|
||||
void *bind(clover::command_queue &q);
|
||||
void unbind(clover::command_queue &q, void *st);
|
||||
|
||||
bool _norm_mode;
|
||||
cl_addressing_mode _addr_mode;
|
||||
cl_filter_mode _filter_mode;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue