Sign in to follow this  

tex2d with offset

This topic is 3562 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I recently bought a Radeon 3870 graphics card, but before I was working on a geforce 7600 GS version. There seems to be an inconsistency between these two cards to address certain pixels. Maybe some more information, I’m working on my thesis regarding an iterative solver on a GPU. The solver needs the pixels around the pixel in question and this is done in the next way (which up till now worked): VS: QuadVertexOutput ScreenQuadVS( float4 Position : POSITION, float2 TexCoord : TEXCOORD0 ) { QuadVertexOutput OUT; OUT.Position = float4(Position.x,Position.y,0.01, 1); OUT.UV = TexCoord.xy;//+float2(0.5*ONEPIXELX,0.5*ONEPIXELY); return OUT; } PS: float4 UpdateField2D(QuadVertexOutput IN) : COLOR { float2 H = tex2D(HSampler,IN.UV).xy; float2 A; // do not update, this part is the source, the other boundary's are always 0 if(IN.UV.x<ONEPIXELX) { A=float2(0,0); } else { // updatable variables: float2 n_2 = tex2D(nSampler,IN.UV).xy; float2 Hxmin = tex2D(HSampler,IN.UV+float2(-ONEPIXELX,0)).xy; float2 Hxplus = tex2D(HSampler,IN.UV+float2(ONEPIXELX,0)).xy; float2 Hymin = tex2D(HSampler,IN.UV+float2(0,-ONEPIXELY)).xy; float2 Hyplus = tex2D(HSampler,IN.UV+float2(0,ONEPIXELY)).xy; … } Where ONEPIXELX and ONEPIXELY are 1.0f/TextureWidth and 1.0f/TextureHeight respectively. In all current documentation the same principle is found, so why isn’t it working on this brand new card? My guesses were: - hlsl: but this code worked so ...? - Ati driver malfunction, but what's the link between hlsl and drivers? - DirectX 10, because I use the DXUT framework of microsoft for the GUI. But I don't set any of the DX10 callbacks so normally cannot be the problem. - Is there a difference in texture storage between these? because I got the same problem with the old card when trying to do non power of 2 textures (although supported it didn't work for this) but now I do square pow of 2 textures and still get the problem. So I'm out of clues... thanks

Share this post


Link to post
Share on other sites
Can you describe what doesn't work?

My guess would be it's some different default. You might be getting different filtering or something else may be different. "Not working" doesn't really help narrow it down.

I'd also suggest trying to run with the ref device. That should give you some indication if you've missed setting something, and the NVIDIA driver just happens to set it.

Share this post


Link to post
Share on other sites
Normally I should get a procedural texture, you could state that it does the same thing as gaussian filtering and this for x times.

The algorithm needs the if part because I use the first pixels to set the source, and because when using:

pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER );
pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER );
pd3dDevice->SetSamplerState(0, D3DSAMP_BORDERCOLOR, D3DCOLOR_ARGB(0,0,0,0));

you can say that every point outside the texture is taken as a point with argb value (0,0,0,0). This I use because I need Dirichlet boundary conditions.

The problem I get is that the texture doesn't update itself with respect to the contents of the neighbours. Three things I came across which had the same impact on the GeForce card were:
- not the correct boundary conditions, but this had another effect.
- not using pixelsize in tex2D but -1 and +1, so off course wrong pixels taken.
- When using a non power of 2 texture (although the Geforce card is capable of doing), I changed this to only using power of 2 and the problem was solved.

So if it is the driver, how can I check this?

I used the REF type and get an error on the next line:
V( pd3dDevice->CreateOffscreenPlainSurface(totalfieldx-parameters.boundary_layer,totalfieldy-parameters.boundary_layer*2,D3DFMT_A32B32G32R32F,D3DPOOL_SYSTEMMEM,&readback,NULL));

I don't find anything about this function and the REF regarding incompatibility.

Anyway, I need this texture because I which to get the information back from the GPU by:

pd3dDevice->GetRenderTargetData(Hfield,readback);

So where's the problem there?

Share this post


Link to post
Share on other sites
I already tried and didn't work:

OUT.UV = TexCoord.xy+float2(0.5*ONEPIXELX,0.5*ONEPIXELY);
and:
OUT.UV = TexCoord.xy;

though, I use the DXUT framework and am only using DX9 so should be no problem in any way (I guess).

Share this post


Link to post
Share on other sites
Normally I should get a procedural texture, you could state that it does the same thing as gaussian filtering and this for x times.

The algorithm needs the if part because I use the first pixels to set the source, and because when using:

pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER );
pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER );
pd3dDevice->SetSamplerState(0, D3DSAMP_BORDERCOLOR, D3DCOLOR_ARGB(0,0,0,0));

you can say that every point outside the texture is taken as a point with argb value (0,0,0,0). This I use because I need Dirichlet boundary conditions.

The problem I get is that the texture doesn't update itself with respect to the contents of the neighbours. Three things I came across which had the same impact on the GeForce card were:
- not the correct boundary conditions, but this had another effect.
- not using pixelsize in tex2D but -1 and +1, so off course wrong pixels taken.
- When using a non power of 2 texture (although the Geforce card is capable of doing), I changed this to only using power of 2 and the problem was solved.

So if it is the driver, how can I check this?

I used the REF type and get an error on the next line:
V( pd3dDevice->CreateOffscreenPlainSurface(totalfieldx-parameters.boundary_layer,totalfieldy-parameters.boundary_layer*2,D3DFMT_A32B32G32R32F,D3DPOOL_SYSTEMMEM,&readback,NULL));

I don't find anything about this function and the REF regarding incompatibility.

Anyway, I need this texture because I which to get the information back from the GPU by:

pd3dDevice->GetRenderTargetData(Hfield,readback);

So where's the problem there?

Share this post


Link to post
Share on other sites
I found the problem,

it seems that the annonanations in effect files aren't there only for documentation or for the fx composer. But DirectX reads these and overwrite your states of your program witht these. So when I changed from linear to point sampling in the effect files too, everything seems to work!

regards

Share this post


Link to post
Share on other sites

This topic is 3562 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this