Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7956655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:03:24+00:00 2026-06-04T04:03:24+00:00

While using texture memory I have come across the following code:- uint f =

  • 0

While using texture memory I have come across the following code:-

uint f = (blockIdx.x * blockDim.x) + threadIdx.x;
uint c = (blockIdx.y * blockDim.y) + threadIdx.y;

uint read = tex2D( refTex, c+0.5f, f+0.5f);

My question is why do we add 0.5f to both c and f?
This confuses me..
thankyou

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:03:25+00:00Added an answer on June 4, 2026 at 4:03 am

    In graphics, a texture is a set of samples that describes the visual appearance of a surface. A sample is a point. That is, it has no size (as opposed to a pixel that has a physical size). When using samples to determine the colors of pixels, each sample is positioned in the exact center of its corresponding pixel. When addressing pixels with whole number coordinates, the exact center for a given pixel becomes its whole number coordinate plus an offset of 0.5 (in each dimension).

    In other words, adding 0.5 to texture coordinates ensures that, when reading from those coordinates, the exact value of the sample for that pixel is returned.

    However, it is only when filterMode for the texture has been set to cudaFilterModeLinear that the value that is read from a texture varies within a pixel. In that mode, reading from coordinates that are not in the exact center of a pixel returns values that are interpolated between the sample for the given pixel and the samples for neighboring pixels. So, adding 0.5 to whole number coordinates effectively negates the cudaFilterModeLinear mode. But, since adding 0.5 to the texture coordinates takes up cycles in the kernel, it is better to simply turn off the interpolation by setting filterMode to cudaFilterModePoint. Then, reading from any coordinate within a pixel returns the exact texture sample value for that pixel, and so, texture samples can be read directly by using whole numbers.

    When using cudaFilterModePoint, if any floating point math is involved in calculating the texture coordinates, care must be taken to ensure that floating point inaccuracies don’t cause the texture coordinates to fall outside the range for the intended target pixel.

    Also, as the comments mention, there might be a problem in your code. Adding 0.5f to the texture coordinates implies that the cudaFilterModeLinear mode is being used, but that mode returns a float, not an int.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

while using the following constructor $this->pdo = new PDO ($this->source, $this->username, $this->password); if I
While using this code to serialize an object: public object Clone() { var serializer
While using regex to help solve a problem in the Python Challenge , I
While using the vector why do we sometime use the operator[] like homework[mid] but
While using Aptana and Eclipse for the first time in my programming life for
While using fixed width select tag , there is one bug in IE. When
while using g.drawImage(img,0,0,100,100,0,0,0,0,null) it does not produce any result. So how to draw on
while using beautifulsoup to parse a table in html every other row starts with
while using the appengine sdk i can't view the Output of my System.out.println statements
While using new_list = my_list , any modifications to new_list changes my_list every time.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.