Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 120 lines (98 sloc) 2.828 kb
675d59a Ryusuke SEKIYAMA Add context, etc.
authored
1 /**
2 * The OpenCL PHP extension
3 *
4 * @package php-opencl
5 * @author Ryusuke SEKIYAMA <rsky0711@gmail.com>
6 * @copyright 2012 Ryusuke SEKIYAMA
7 * @license http://www.opensource.org/licenses/mit-license.php MIT License
8 */
9
10 #include "sampler.h"
bc19908 Ryusuke SEKIYAMA Refactor.
authored
11 #include "params.h"
675d59a Ryusuke SEKIYAMA Add context, etc.
authored
12
13 #define get_info ((phpcl_get_info_func_t)_get_sampler_info)
14 #define get_info_ex NULL
15
16 /* {{{ globals */
17
18 static const phpcl_info_param_t sampler_info_params[] = {
19 { NULL, 0, 0 }
20 };
21
22 /* }}} */
23 /* {{{ _get_sampler_info() */
24
25 static cl_int _get_sampler_info(cl_sampler sampler,
26 void *reserved __attribute__ ((unused)),
27 cl_sampler_info name,
28 size_t value_size,
29 void *value,
30 size_t *value_size_ret)
31 {
32 return clGetSamplerInfo(sampler, name, value_size, value, value_size_ret);
33 }
34
35 /* }}} */
36 /* {{{ _get_sampler_info_all() */
37
bc19908 Ryusuke SEKIYAMA Refactor.
authored
38 static void _get_sampler_info_all(
39 INTERNAL_FUNCTION_PARAMETERS,
675d59a Ryusuke SEKIYAMA Add context, etc.
authored
40 cl_sampler sampler)
41 {
42 const phpcl_info_param_t *param = sampler_info_params;
43 char buf[32] = {0};
44
45 array_init_size(return_value, 8);
46 snprintf(buf, sizeof(buf), "%p", sampler);
47 add_assoc_string(return_value, "id", buf, 1);
48
49 while (param->key != NULL) {
50 zval *entry = phpcl_get_info(get_info, get_info_ex,
51 sampler, NULL, param TSRMLS_CC);
52 if (entry) {
53 add_assoc_zval(return_value, param->key, entry);
54 } else {
55 add_assoc_null(return_value, param->key);
56 }
57 param++;
58 }
59 }
60
61 /* }}} */
62 /* {{{ _get_sampler_info_by_name() */
63
bc19908 Ryusuke SEKIYAMA Refactor.
authored
64 static void _get_sampler_info_by_name(
65 INTERNAL_FUNCTION_PARAMETERS,
675d59a Ryusuke SEKIYAMA Add context, etc.
authored
66 cl_sampler sampler, cl_int name)
67 {
68 const phpcl_info_param_t *param = sampler_info_params;
69
70 RETVAL_NULL();
71
72 while (param->key != NULL) {
73 if (param->name == name) {
74 zval *entry = phpcl_get_info(get_info, get_info_ex,
75 sampler, NULL, param TSRMLS_CC);
76 if (entry) {
77 RETVAL_ZVAL(entry, 0, 1);
78 }
79 return;
80 }
81 param++;
82 }
83 }
84
85 /* }}} */
86 /* {{{ mixed cl_get_sampler_info(resource cl_sampler sampler[, int name]) */
87
9bc403e Ryusuke SEKIYAMA Add __attribute__((visibility("hidden"))) to internal APIs.
authored
88 PHPCL_FUNCTION(cl_get_sampler_info)
675d59a Ryusuke SEKIYAMA Add context, etc.
authored
89 {
90 zval *zid = NULL;
91 cl_sampler sampler = NULL;
92 long name = 0;
93
94 RETVAL_FALSE;
95
96 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
97 "r|l", &zid, &name) == FAILURE) {
98 return;
99 }
100 ZEND_FETCH_RESOURCE(sampler, cl_sampler, &zid, -1,
101 "cl_sampler", phpcl_le_sampler());
102
103 if (ZEND_NUM_ARGS() == 2) {
104 _get_sampler_info_by_name(INTERNAL_FUNCTION_PARAM_PASSTHRU, sampler, (cl_int)name);
105 } else {
106 _get_sampler_info_all(INTERNAL_FUNCTION_PARAM_PASSTHRU, sampler);
107 }
108 }
109
110 /* }}} */
111
112 /*
113 * Local variables:
114 * tab-width: 4
115 * c-basic-offset: 4
116 * End:
117 * vim600: noet sw=4 ts=4 fdm=marker
118 * vim<600: noet sw=4 ts=4
119 */
Something went wrong with that request. Please try again.