@@ -16,73 +16,43 @@ struct MemoryAdaptor
16
16
{
17
17
BaseAccessor accessor;
18
18
19
- // TODO: template all get,set, atomic... then add static_asserts of `has_method<BaseAccessor,signature>::value`, do vectors and matrices in terms of each other
20
- uint get (const uint ix) { return accessor.get (ix); }
21
- void get (const uint ix, NBL_REF_ARG (uint ) value) { value = accessor.get (ix);}
22
- void get (const uint ix, NBL_REF_ARG (uint2 ) value) { value = uint2 (accessor.get (ix), accessor.get (ix + _NBL_HLSL_WORKGROUP_SIZE_));}
23
- void get (const uint ix, NBL_REF_ARG (uint3 ) value) { value = uint3 (accessor.get (ix), accessor.get (ix + _NBL_HLSL_WORKGROUP_SIZE_), accessor.get (ix + 2 * _NBL_HLSL_WORKGROUP_SIZE_));}
24
- void get (const uint ix, NBL_REF_ARG (uint4 ) value) { value = uint4 (accessor.get (ix), accessor.get (ix + _NBL_HLSL_WORKGROUP_SIZE_), accessor.get (ix + 2 * _NBL_HLSL_WORKGROUP_SIZE_), accessor.get (ix + 3 * _NBL_HLSL_WORKGROUP_SIZE_));}
25
-
26
- void get (const uint ix, NBL_REF_ARG (int ) value) { value = asint (accessor.get (ix));}
27
- void get (const uint ix, NBL_REF_ARG (int2 ) value) { value = asint (uint2 (accessor.get (ix), accessor.get (ix + _NBL_HLSL_WORKGROUP_SIZE_)));}
28
- void get (const uint ix, NBL_REF_ARG (int3 ) value) { value = asint (uint3 (accessor.get (ix), accessor.get (ix + _NBL_HLSL_WORKGROUP_SIZE_), accessor.get (ix + 2 * _NBL_HLSL_WORKGROUP_SIZE_)));}
29
- void get (const uint ix, NBL_REF_ARG (int4 ) value) { value = asint (uint4 (accessor.get (ix), accessor.get (ix + _NBL_HLSL_WORKGROUP_SIZE_), accessor.get (ix + 2 * _NBL_HLSL_WORKGROUP_SIZE_), accessor.get (ix + 3 * _NBL_HLSL_WORKGROUP_SIZE_)));}
19
+ // TODO: template atomic... then add static_asserts of `has_method<BaseAccessor,signature>::value`, do vectors and matrices in terms of each other
20
+ uint get (const uint ix)
21
+ {
22
+ uint retVal;
23
+ accessor.get (ix, retVal);
24
+ return retVal;
25
+ }
30
26
31
- void get (const uint ix, NBL_REF_ARG (float ) value) { value = asfloat (accessor.get (ix));}
32
- void get (const uint ix, NBL_REF_ARG (float2 ) value) { value = asfloat (uint2 (accessor.get (ix), accessor.get (ix + _NBL_HLSL_WORKGROUP_SIZE_)));}
33
- void get (const uint ix, NBL_REF_ARG (float3 ) value) { value = asfloat (uint3 (accessor.get (ix), accessor.get (ix + _NBL_HLSL_WORKGROUP_SIZE_), accessor.get (ix + 2 * _NBL_HLSL_WORKGROUP_SIZE_)));}
34
- void get (const uint ix, NBL_REF_ARG (float4 ) value) { value = asfloat (uint4 (accessor.get (ix), accessor.get (ix + _NBL_HLSL_WORKGROUP_SIZE_), accessor.get (ix + 2 * _NBL_HLSL_WORKGROUP_SIZE_), accessor.get (ix + 3 * _NBL_HLSL_WORKGROUP_SIZE_)));}
27
+ template<typename Scalar>
28
+ void get (const uint ix, NBL_REF_ARG (Scalar) value) { accessor.get (ix, value);}
29
+ template<typename Scalar>
30
+ void get (const uint ix, NBL_REF_ARG (vector <Scalar, 2 >) value) { accessor.get (ix, value.x), accessor.get (ix + _NBL_HLSL_WORKGROUP_SIZE_, value.y);}
31
+ template<typename Scalar>
32
+ void get (const uint ix, NBL_REF_ARG (vector <Scalar, 3 >) value) { accessor.get (ix, value.x), accessor.get (ix + _NBL_HLSL_WORKGROUP_SIZE_, value.y), accessor.get (ix + 2 * _NBL_HLSL_WORKGROUP_SIZE_, value.z);}
33
+ template<typename Scalar>
34
+ void get (const uint ix, NBL_REF_ARG (vector <Scalar, 4 >) value) { accessor.get (ix, value.x), accessor.get (ix + _NBL_HLSL_WORKGROUP_SIZE_, value.y), accessor.get (ix + 2 * _NBL_HLSL_WORKGROUP_SIZE_, value.z), accessor.get (ix + 3 * _NBL_HLSL_WORKGROUP_SIZE_, value.w);}
35
35
36
- void set (const uint ix, const uint value) {accessor.set (ix, value);}
37
- void set (const uint ix, const uint2 value) {
36
+ template<typename Scalar>
37
+ void set (const uint ix, const Scalar value) {accessor.set (ix, value);}
38
+ template<typename Scalar>
39
+ void set (const uint ix, const vector <Scalar, 2 > value) {
38
40
accessor.set (ix, value.x);
39
41
accessor.set (ix + _NBL_HLSL_WORKGROUP_SIZE_, value.y);
40
42
}
41
- void set (const uint ix, const uint3 value) {
43
+ template<typename Scalar>
44
+ void set (const uint ix, const <Scalar, 3 > value) {
42
45
accessor.set (ix, value.x);
43
46
accessor.set (ix + _NBL_HLSL_WORKGROUP_SIZE_, value.y);
44
47
accessor.set (ix + 2 * _NBL_HLSL_WORKGROUP_SIZE_, value.z);
45
48
}
46
- void set (const uint ix, const uint4 value) {
49
+ template<typename Scalar>
50
+ void set (const uint ix, const <Scalar, 4 > value) {
47
51
accessor.set (ix, value.x);
48
52
accessor.set (ix + _NBL_HLSL_WORKGROUP_SIZE_, value.y);
49
53
accessor.set (ix + 2 * _NBL_HLSL_WORKGROUP_SIZE_, value.z);
50
54
accessor.set (ix + 3 * _NBL_HLSL_WORKGROUP_SIZE_, value.w);
51
55
}
52
-
53
- void set (const uint ix, const int value) {accessor.set (ix, asuint (value));}
54
- void set (const uint ix, const int2 value) {
55
- accessor.set (ix, asuint (value.x));
56
- accessor.set (ix + _NBL_HLSL_WORKGROUP_SIZE_, asuint (value.y));
57
- }
58
- void set (const uint ix, const int3 value) {
59
- accessor.set (ix, asuint (value.x));
60
- accessor.set (ix + _NBL_HLSL_WORKGROUP_SIZE_, asuint (value.y));
61
- accessor.set (ix + 2 * _NBL_HLSL_WORKGROUP_SIZE_, asuint (value.z));
62
- }
63
- void set (const uint ix, const int4 value) {
64
- accessor.set (ix, asuint (value.x));
65
- accessor.set (ix + _NBL_HLSL_WORKGROUP_SIZE_, asuint (value.y));
66
- accessor.set (ix + 2 * _NBL_HLSL_WORKGROUP_SIZE_, asuint (value.z));
67
- accessor.set (ix + 3 * _NBL_HLSL_WORKGROUP_SIZE_, asuint (value.w));
68
- }
69
-
70
- void set (const uint ix, const float value) {accessor.set (ix, asuint (value));}
71
- void set (const uint ix, const float2 value) {
72
- accessor.set (ix, asuint (value.x));
73
- accessor.set (ix + _NBL_HLSL_WORKGROUP_SIZE_, asuint (value.y));
74
- }
75
- void set (const uint ix, const float3 value) {
76
- accessor.set (ix, asuint (value.x));
77
- accessor.set (ix + _NBL_HLSL_WORKGROUP_SIZE_, asuint (value.y));
78
- accessor.set (ix + 2 * _NBL_HLSL_WORKGROUP_SIZE_, asuint (value.z));
79
- }
80
- void set (const uint ix, const float4 value) {
81
- accessor.set (ix, asuint (value.x));
82
- accessor.set (ix + _NBL_HLSL_WORKGROUP_SIZE_, asuint (value.y));
83
- accessor.set (ix + 2 * _NBL_HLSL_WORKGROUP_SIZE_, asuint (value.z));
84
- accessor.set (ix + 3 * _NBL_HLSL_WORKGROUP_SIZE_, asuint (value.w));
85
- }
86
56
87
57
void atomicAnd (const uint ix, const uint value, NBL_REF_ARG (uint ) orig) {
88
58
orig = accessor.atomicAnd (ix, value);
0 commit comments