• Advertisement
Sign in to follow this  

what's the fastest way to blend two big texture?

This topic is 4284 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

I have two textures of the same size: 1024*1024*32bit, on the same object, and want to blend it with an alpha changing from 0 to 1, so the object looks like changing it's texture gradually from one to another. What's the best way to do this? I tried pixelshader 2.0a, the compiled shader just include 2 texld and 1 lrp, but on my Nvidia 5200 this short code already limits the speed down to 52fps. It runs on 1280*1024 fullscreen. Is "lrp" instruction really so costy?

Share this post


Link to post
Share on other sites
Advertisement
The GeForce 5200 cards are not very fast. But as every GeForce 5XXX they will slow down even more if you use is full precession 2.0 pixel shader on it. You should try it with a 1.1 pixel shader.

Share this post


Link to post
Share on other sites
Great! After setting the compile target to ps 1.4, the "lrp" instruction is
broke into some adds and muls, and it runs faster than ps 2.0!

But, after adding two more insturctions, ps 1.4 runs slower than ps 2.0.

Isn't there any cheaper way to do this texture blending?
Render stage?
Is that cheap to update alpha in every frame?

Share this post


Link to post
Share on other sites
There is going to be little, if any, difference in performance between the fixed-function texture operators and a pixel shader. The driver is likely to translate both into similar GPU-specific microcode, so the GPU is essentially doing the same thing either way you choose to express it [smile]

Does it absolutely have to be a 1024x1024? Can you not drop it back to a 512 or 256? Dynamically scale it on those cards that lack the grunt to do the job properly?

hth
Jack

Share this post


Link to post
Share on other sites
If possible try PS 1.1. This is the fastest way that a GF 5200 knows.

Share this post


Link to post
Share on other sites
I'd be curious if there was any advantage to doing a simple operation like this with the fixed function pipeline?



Share this post


Link to post
Share on other sites
I second jollyjeffers thought.
drop the main screen resolution to something like 1024x768.
and drop your texture resolution to 512 or 256.

Share this post


Link to post
Share on other sites
Quote:
Original post by don
I'd be curious if there was any advantage to doing a simple operation like this with the fixed function pipeline?

I think that the only advantage would be a programming one. If you're familiar with the FFP then using D3DTOP_BLENDFACTORALPHA might be a bit more convenient than a shader. In terms of performance I think than FFP and PS 1.1 will work the same. But it won't hurt to try.

Share this post


Link to post
Share on other sites
I just tried FFP. It works! And fast enough.
But now I can't use pixel shader and FFP in the same drawprimitive().
Maybe they are using the same part of the hardware.
Someone said in mordern cards FFP is infact implemented in pixel shader.
But for my 5200, it seems that FFP is better.

Share this post


Link to post
Share on other sites
Quote:
Original post by raytracer03
I just tried FFP. It works! And fast enough.
But now I can't use pixel shader and FFP in the same drawprimitive().
Maybe they are using the same part of the hardware.
Someone said in mordern cards FFP is infact implemented in pixel shader.
But for my 5200, it seems that FFP is better.

Pixel shader and FFP do the same thing with different syntaxes. What do you mean about using them in the same drawprimitive?

As for texture stages vs. pixel shader on the 5200, I think that they should work at the same speed if you use ps1.1. However, it's possible that the code generated by the HLSL compiler isn't fully optimised, which could make the FFP faster.

Share this post


Link to post
Share on other sites
Your card might have a dedicated FFP path in silicon which could make it slightly faster than using a shader (which is why I suggested that you try it). Most newer hardware emulates the FFP using a shader internally so you wouldn't see a perf win in that case.

I'm curious, what sort of performance increase did you see when you used the FFP over the pixel shader? Exactly how much faster was it?

Share this post


Link to post
Share on other sites
FFP is much faster than PS 2.0 on my 5200, because it can run at 60fps while PS 2.0 can't go above 50fps.
For PS 1.1 maybe they are the same, but what if it's slower in some other cards, for example savage?
For safe, I think it's better to fall back to older technology, if that's enough for me.

To ET3D: If I set FFP and Setpixelshader(myshader) before the same drawprimitive(),
the card only consider the shader.
While if I set FFP and Setpixelshader(NULL) in one drawprimitive,
and Setpixelshader(myshader) in another drawprimitive,
it works in the desired way.

Share this post


Link to post
Share on other sites
raytracer, as I said, texture stages and pixel shaders do the same thing, so there's no meaning to having them both active at the same time. So it makes sense to disable the pixel shader to get the other thing.

Quote:
Original post by don
Your card might have a dedicated FFP path in silicon which could make it slightly faster than using a shader (which is why I suggested that you try it). Most newer hardware emulates the FFP using a shader internally so you wouldn't see a perf win in that case.

I can see where there's a misunderstanding here. The problem is looking at the "FFP" as if it's one thing.

Graphics cards with shader support have always emulated texture stages with pixel shaders.

When it comes to vertex calculations, the situation is much different. Cards before shader model 2 didn't have expressive enough shaders to support full FFP vertex calculations, so needed dedicated hardware support. When ATI introduced its SM2 cards, they emulated all their FFP vertex processing in shaders. The GeForceFX, on the other hand, still had some "helper FFP" functionality. Not sure about newer GeForces (6x00 and up), but I guess not, since there's not much point these days).

So when it comes to pixel shaders, there should be a way to get performance as good as FFP. When it comes to vertex shaders, that won't be the case on pre-SM2 cards and the GeForceFX family.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement