Welcome, Guest.
Username: Password: Remember me

TOPIC: texture/sampler array support?

texture/sampler array support? 1 year 1 month ago #1

just wondering... and proper syntax?
Last Edit: 1 year 1 month ago by kingeric1992.
The administrator has disabled public write access.

texture/sampler array support? 1 year 1 month ago #2

  • crosire
  • crosire's Avatar
  • Offline
  • Posts: 2437
  • Thank you received: 1385
As in
sampler mySamplers[50];
or in
samplerArray mySamplers;
?
Cheers, crosire =)
The administrator has disabled public write access.
The following user(s) said Thank You: kingeric1992

texture/sampler array support? 1 year 1 month ago #3

I'm thinking the first one. but I suppose that wouldn't matters at all without branching by the index.

anyway, how about array = array ?
I can construct a function that returns a array of float2 like this
void test (out float2 a[8], float2 b[8])
{     
    a[0] = b[0]; 
    a[1] = b[1];
    ...
    a[7] = b[7];
 };
but unable to retrieve it later with
   float2 r[8] = {float2(0,0), float2(1,1),  ....float2(7,7)};
   r = test(r);
and report: error X3013: no matching function overload for 'test'
Last Edit: 1 year 1 month ago by kingeric1992.
The administrator has disabled public write access.

texture/sampler array support? 1 year 1 month ago #4

  • crosire
  • crosire's Avatar
  • Offline
  • Posts: 2437
  • Thank you received: 1385
kingeric1992 wrote:
but unable to retrieve it later with
   float2 r[8] = {float2(0,0), float2(1,1),  ....float2(7,7)};
   r = test(r);
and report: error X3013: no matching function overload for 'test'
Should be:
float2 a[8] = { ... };
float2 b[8] = { ... };
test(a, b);
Assigning arrays to each other is tricky, because the values inside could be stored in different registers, meaning a simple copy from one to another does not work. That's why you usually need a loop or explicit assignment of each value inside the array. To properly reflect that in the high level code, array assignment is not supported by the language directly, as it would introduce a lot more boilerplate code behind the scenes that one would not guess from looking just at the high level code.

Samplers arrays are a similar story. They would only be possible if the array index is known at compile time:
sampler samplers[5];

tex2D(samplers[2], ...);
The following would not work due to the same register restrictions:
sampler samplers[5];

int i = ...;
tex2D(samplers[i], ...);
That however makes the whole sampler array thing a little useless, which is why I decided to simply not have the language support them at all back then.
Cheers, crosire =)
The administrator has disabled public write access.

texture/sampler array support? 1 year 1 month ago #5

Thanks, that works.
sadly the result is not as expected...as expected.
more debugging then. (≧∀≦)ゞ
The administrator has disabled public write access.