Simulated palette with 1d texture lookup is way too slow...

Win32 Programming

    Next

  • 1. How can i use user-defined template in DX9.0c?
    I define and regist a new template to support to use dummybox in X file format And I succeed in exporting a x-file. Sample file ------------------------------------------------------------------------------ header file // {EB9FFE25-B7F9-4006-BEAC-2080B8159AA2} DEFINE_GUID(DXFILEOBJ_UserTemplate, 0xeb9ffe25, 0xb7f9, 0x4006, 0xbe, 0xac, 0x20, 0x80, 0xb8, 0x15, 0x9a, 0xa2); // user defined Object #define FOXEXP_TEMPLATES \ "xof 0303txt 0032\ template UserTemplate \ { \ <EB9FFE25-B7F9-4006-BEAC-2080B8159AA2> \ array Vector vertices[8]; \ } " source file hr = pxofapi->RegisterTemplates((LPVOID)FOXEXP_TEMPLATES, strlen(FOXEXP_TEMPLATES)); ----------------------------------------------------------------------------- But, While using "D3DXLoadMeshHierarchyFromX" func on Loader Program in DX9.0c. How can i use user-defined template in DX9.0c?
  • 2. Small Project
    Greetings! I am new to direct x and want to create what I think should be a fairly simple project. I have about 50 object to display on the screen with about 10 possible images to display on each object. I need the objects to be able to move around the screen at a rate which will look smooth (about 20fps give or take). I am implementing this in Visual Basic Dot Net and hav not been able to get concsistantly past 12fps. Thanks in advance for any possible help Regards, David
  • 3. Can the vertex texture have the usage of rendertarget?
    Works fine here... pd3dDevice->CreateTexture(256,256,1,D3DUSAGE_RENDERTARGET,D3DFMT_A32B32G32R32F,D3DPOOL_DEFAULT,&g_pTex,NULL); pd3dDevice->SetTexture(D3DVERTEXTEXTURESAMPLER0,g_pTex); No errors. However, you can't lock these textures, which seems to be the error you're getting... Wessam Bahnassi Microsoft DirectX MVP, Lead Programmer In|Framez "Zephyr" < XXXX@XXXXX.COM > wrote in message news: XXXX@XXXXX.COM ... > Hi, there, > I want to set a texture which was created with d3dusage_rendertarget > as a vertex texture, but I got a error message from D3D. > > This the code to set the vertex texture > HRESULT hr=m_pd3dDev->SetTexture(D3DVERTEXTEXTURESAMPLER0, ***); > > The error message is, > > Direct3D9: (ERROR) :Lock is not supported for textures allocated with > POOL_DEFAULT unless they are marked D3DUSAGE_DYNAMIC. > Direct3D9: (ERROR) :UnlockRect failed on a mip level; surface wasn't > locked. > > Does it mean that the vertex texture can not be a render target? > > Thanks
  • 4. DirectX9 Screensaver samples?
    I'm trying to port an older screensaver I did to DX9, but the only code I've been able to track down is the screensaver framework from Phil Taylor's articles around DX8.1, and that makes use of the DX8 util libraries. I saw mention of a version in the July 2003 update, but I can't seem to find that anywhere. Certainly I can port the old framework up to DX9 if need be, but does anyone know of one already availalbe? Many thanks! Steven Stadnicki XXXX@XXXXX.COM

Simulated palette with 1d texture lookup is way too slow...

Postby Gabest » Fri, 20 May 2005 22:10:39 GMT

.. is there any way to improve it?

I think there is none, but I thought it might be worth asking once.

Just for the reference, my lookup code is something like this in HLSL:
tex1D(Palette, tex2D(Texture, TexCoord).x - a_little_correction);

Doing it four times and lerping the samples to get bilinear filtering only 
makes it even slower, of course.

The HLSL code compiles to 10-20 assembly instructions for point sampling and 
30-40 with bilinear.



Re: Simulated palette with 1d texture lookup is way too slow...

Postby Wessam Bahnassi » Fri, 20 May 2005 23:33:18 GMT

I think the problem is in the dependant read itself. Four dependant reads 
will really hurt performance.
Unfortunately, support for indexed textures is gone with new hardware. 
Perhaps there is another way of doing this without palettes?
What are you trying to do exactly?

Wessam Bahnassi
Microsoft DirectX MVP,
Lead Programmer
In|Framez








Re: Simulated palette with 1d texture lookup is way too slow...

Postby Gabest » Sat, 21 May 2005 02:31:44 GMT

>I think the problem is in the dependant read itself. Four dependant reads 

Emulation ;) At each frame a great number of textures have to be uploaded to 
the video card every time, especially if the palette changes, but as it 
turned out it actually hurts less than doing the palette lookups in the 
shader.




Re: Simulated palette with 1d texture lookup is way too slow...

Postby mikegi » Sat, 21 May 2005 04:36:45 GMT

What is in your tex2d? Is it a scalar value? If so, you probably should
sample it four times, average the result, then do the tex1d lookup. That
would be post-classification. What you're doing now is pre-classification,
which usually produces ugly results.

Mike





and



Re: Simulated palette with 1d texture lookup is way too slow...

Postby Eyal Teler » Sat, 21 May 2005 17:33:22 GMT



Doesn't make sense to me that this code will come to 10 instructions, 
unless "a_little_correction" is pretty complicated. What code are you 
getting?

	Eyal

Re: Simulated palette with 1d texture lookup is way too slow...

Postby Gabest » Sun, 22 May 2005 01:56:47 GMT








This is not the full shader, just the part doing the sampling. But there are 
not many more instructions, just something to substitute the texture 
functions of the fixed pipeline (modulation, decal, two highlight modes).

The source can be viewed here, if you are interested:
 http://www.**--****.com/ 



Re: Simulated palette with 1d texture lookup is way too slow...

Postby Gabest » Sun, 22 May 2005 02:01:08 GMT

> What is in your tex2d? Is it a scalar value?

Nope, it's the index of the palette. Can't be averaged.



Re: Simulated palette with 1d texture lookup is way too slow...

Postby Eyal Teler » Mon, 23 May 2005 09:16:15 GMT

> This is not the full shader, just the part doing the sampling. But there are 

If the extras you're talking about are "if(!fRT) c.a *= 2;" and so on, 
they likely take most of the shader. A == or != comparison is quite 
costly, IIRC (translates into quite a few instructions). Try using > 
or >= instead. Better yet, use different shaders if you can (one which 
doubles a, one which doesn't).

	Eyal

Re: Simulated palette with 1d texture lookup is way too slow...

Postby Gabest » Tue, 24 May 2005 00:17:58 GMT






Not really, only those shaders are much slower which do a palette lookup. 
I've tried to comment out as much of those extras as I could already.


That's a funny thing actually. I'm setting those consts to be either 0 or 1 
so != 0 should be the same as > 0 (which compiles to one instruction less) 
but in reality it just does not want to work on nvidia, while on ati 
hardware it does.


The current number of shaders are already the result of such separation, 
they could be broken into more, just each step doubles their number. I wish 
there was something like #ifdef in hlsl, that would surely make it easier to 
prepare different versions of the shaders.



Re: Simulated palette with 1d texture lookup is way too slow...

Postby Eyal Teler » Tue, 24 May 2005 06:35:35 GMT

> Not really, only those shaders are much slower which do a palette lookup. 

It's possible, but in that case it's unlikely to do with the number of 
instructions.


The compiler doesn't know which values you will use. Since the only 
way to compare in PS 2.0 is with cmp, which tests ">= 0", any exact 
comparisons need to use two tests.

It's helpful to understand what the code compiles to. You can then 
choose the constants and code better. We're not yet in a position 
where there's such an abundance of computing power that we can just 
use whatever code we like. For example, if instead of 0 and 1 you 
chose 1 and 2, then you could simply multiply the value with this, 
instead of having to test anything -- that'd be much shorter and 
faster. (Although even with 0 and 1, just add 1 and multiply :)


You can use constants in the shader definitions. Check for example the 
HLSL Workshop tutorial 1 (goal1.fx). At the end of the file you'll see 
the same vertex shader compiled quite a few times with different 
boolean parameters, resulting in totally different code.

	Eyal

Similar Threads:

1.renderingto texture while using same texture for lookup

Is is possible to
render a cene to a texture A
set the texture A as lookuptexture
render scene to texture A

This means that in the second render call the texture is being red and 
written at the same time.

I assume the answer is no, but in theory I assume it could... if one reads 
the axact pixel one is about to write? 


2.I am looking for Gscape, a freeware simulated-terrain graphic editor

3.Slow Rendering on Windows Forms when I am using graphics as backgr

Hello,

I am trying to build a KIOSK application, where all windows forms are filled 
with graphics images and a lot of buttons.

The major bproblem is that when the application is running and the forms are 
ready to display on the screen I see a lot of cuts... for example when I show 
a form that has a background image (800x600) and about 20 buttons on it, 
which each of the button has a background image, the render on the screen is 
not the recomended....!

Is there any technique that I could do the rendering smoother and faster???

Many thanks
George Barbagiannis

P.S. Computer 2.4G 1GB 128MB VGA

4.1D textures

Hi,

I was wondering if there is a way
to use 1D textures in OpenInventor.

There are the nodes SoTexture2 and 
SoTexture3, but no SoTexture1.

Thanks in advance
---
Luis

5.1D Texture and clamping

6. Is it possible Texture lookup operation with Pixel Buffer object

7. texture-lookup using ARB_fragment_program on ATI FireGL card

8. texture lookup



Return to Win32 Programming

 

Who is online

Users browsing this forum: No registered users and 9 guest