Use uv or 0 for 1x1 texture reads?

  • luluco250
  • Topic Author
More
6 years 1 week ago #1 by luluco250 Use uv or 0 for 1x1 texture reads? was created by luluco250
Is there any notable difference between using regular coordinates or 0.0 in tex2D() when reading from a 1x1 texture?
I had heard some time ago that simple uv reads were more optimized than offset coordinates. Does that also apply to static coordinates?

And maybe someone will suggest tex2Dfetch(), that has never worked with me, throws errors on some compilers.

Please Log in or Create an account to join the conversation.

  • Marty McFly
More
6 years 1 week ago #2 by Marty McFly Replied by Marty McFly on topic Use uv or 0 for 1x1 texture reads?
iirc independent texture reads (constant value as offset) are almost for free. You can try this out by reading a texture a lot of times with a loop, a) only computing the offset with the loop variable (then you have fixed coordinates) and b) by adding texcoord to it so it's dependant. Compare performance of both.

Please Log in or Create an account to join the conversation.

  • luluco250
  • Topic Author
More
6 years 1 week ago #3 by luluco250 Replied by luluco250 on topic Use uv or 0 for 1x1 texture reads?
Well after testing it there seems to be absolutely no difference, at least not in DX9. I guess I'll go with 0 since it's quicker to write.

Please Log in or Create an account to join the conversation.

  • crosire
More
6 years 1 week ago #4 by crosire Replied by crosire on topic Use uv or 0 for 1x1 texture reads?
tex2Dfetch would technically the best solution, since it skips interpolation, which has no effect on a 1x1 texture (only in Dx10+ and OpenGL). What sort of errors do you get with it.

Please Log in or Create an account to join the conversation.

  • luluco250
  • Topic Author
More
6 years 1 week ago - 6 years 1 week ago #5 by luluco250 Replied by luluco250 on topic Use uv or 0 for 1x1 texture reads?

crosire wrote: tex2Dfetch would technically the best solution, since it skips interpolation, which has no effect on a 1x1 texture (only in Dx10+ and OpenGL). What sort of errors do you get with it.


Well ages ago when I tried to use it I got strange compiler errors, specially under OpenGL. Testing it now it works as long as the second argument is an explicit int4, if I just write 0 it doesn't work, complaining about "incorrect number of arguments to numeric-type constructor", but (int4)0 does, which is odd. This is happening under DX9, which according to you shouldn't have any effect anyway.
Last edit: 6 years 1 week ago by luluco250.

Please Log in or Create an account to join the conversation.

  • crosire
More
6 years 3 days ago #6 by crosire Replied by crosire on topic Use uv or 0 for 1x1 texture reads?
tex2Dfetch works correctly in OpenGL now.

Please Log in or Create an account to join the conversation.

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.