summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorFrancisco Jerez <[email protected]>2013-09-15 22:20:43 -0700
committerFrancisco Jerez <[email protected]>2013-10-21 10:47:03 -0700
commit04d0ab9f6456229df1a83b0b1c133e1c458aedd2 (patch)
treecf3f0a33549bd6ce6102626fb56723fd30525d65 /src/gallium/state_trackers
parentd6f7afc3ed41a94175a0fdf9cf9651750104974c (diff)
clover: Switch samplers to the new model.
Tested-by: Tom Stellard <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/clover/api/sampler.cpp44
-rw-r--r--src/gallium/state_trackers/clover/core/error.hpp2
-rw-r--r--src/gallium/state_trackers/clover/core/kernel.cpp2
-rw-r--r--src/gallium/state_trackers/clover/core/object.hpp3
-rw-r--r--src/gallium/state_trackers/clover/core/queue.hpp2
-rw-r--r--src/gallium/state_trackers/clover/core/sampler.cpp16
-rw-r--r--src/gallium/state_trackers/clover/core/sampler.hpp37
7 files changed, 53 insertions, 53 deletions
diff --git a/src/gallium/state_trackers/clover/api/sampler.cpp b/src/gallium/state_trackers/clover/api/sampler.cpp
index 846f8d4fe33..288df080eba 100644
--- a/src/gallium/state_trackers/clover/api/sampler.cpp
+++ b/src/gallium/state_trackers/clover/api/sampler.cpp
@@ -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:
diff --git a/src/gallium/state_trackers/clover/core/error.hpp b/src/gallium/state_trackers/clover/core/error.hpp
index 256b61be438..28459f3821e 100644
--- a/src/gallium/state_trackers/clover/core/error.hpp
+++ b/src/gallium/state_trackers/clover/core/error.hpp
@@ -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
diff --git a/src/gallium/state_trackers/clover/core/kernel.cpp b/src/gallium/state_trackers/clover/core/kernel.cpp
index b98a0ba5691..7e18366c728 100644
--- a/src/gallium/state_trackers/clover/core/kernel.cpp
+++ b/src/gallium/state_trackers/clover/core/kernel.cpp
@@ -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;
}
diff --git a/src/gallium/state_trackers/clover/core/object.hpp b/src/gallium/state_trackers/clover/core/object.hpp
index 461ccb0ceec..ea71879512c 100644
--- a/src/gallium/state_trackers/clover/core/object.hpp
+++ b/src/gallium/state_trackers/clover/core/object.hpp
@@ -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
diff --git a/src/gallium/state_trackers/clover/core/queue.hpp b/src/gallium/state_trackers/clover/core/queue.hpp
index 65f2d63ffc8..4618a1bde02 100644
--- a/src/gallium/state_trackers/clover/core/queue.hpp
+++ b/src/gallium/state_trackers/clover/core/queue.hpp
@@ -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;
diff --git a/src/gallium/state_trackers/clover/core/sampler.cpp b/src/gallium/state_trackers/clover/core/sampler.cpp
index 32c415e7611..adab96a2e1a 100644
--- a/src/gallium/state_trackers/clover/core/sampler.cpp
+++ b/src/gallium/state_trackers/clover/core/sampler.cpp
@@ -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);
}
diff --git a/src/gallium/state_trackers/clover/core/sampler.hpp b/src/gallium/state_trackers/clover/core/sampler.hpp
index ad1531914b6..3d2acaa9be1 100644
--- a/src/gallium/state_trackers/clover/core/sampler.hpp
+++ b/src/gallium/state_trackers/clover/core/sampler.hpp
@@ -27,29 +27,28 @@
#include "core/queue.hpp"
namespace clover {
- typedef struct _cl_sampler sampler;
-}
-
-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);
+ 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();
+ bool norm_mode();
+ cl_addressing_mode addr_mode();
+ cl_filter_mode filter_mode();
- clover::context &ctx;
+ context &ctx;
- friend class clover::kernel;
+ friend class kernel;
-private:
- void *bind(clover::command_queue &q);
- void unbind(clover::command_queue &q, void *st);
+ 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;
-};
+ bool _norm_mode;
+ cl_addressing_mode _addr_mode;
+ cl_filter_mode _filter_mode;
+ };
+}
#endif