# DX11 DX11 .fx-Effect - disable shaders [SlimDX, C#]

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

## Recommended Posts

Hi, now I hit another problem in my engine. I have some effect files. In those effects I compile shaders in this way:
SetVertexShader(CompileShader(vs_5_0, VS()));

In some effects, I do not use all of the shaders. For example for the z-pass I do not need the pixel shader, so I'm disabling it with:
SetVertexShader(CompileShader(vs_5_0, VS()));

Now I have a problem while rendering my GUI. Because the GUI does not need the hull/domain/geometry shaders, I want to disable them too. If I do not disable it, just saing:
SetVertexShader(CompileShader(vs_5_0, VS()));

then somehow the old h/d/g shaders are still active. I tried to do this:
SetVertexShader(CompileShader(vs_5_0, VS()));

But then I get an error saing:
System.Exception: Error occured while creating shader: Managed shader: Resources/Shader/gui.fx ---> SlimDX.Direct3D11.Direct3D11Exception: E_FAIL: An undetermined error occurred (-2147467259)
bei SlimDX.Result.Throw[T](Object dataKey, Object dataValue)
bei SlimDX.Result.Record[T](Int32 hr, Boolean failed, Object dataKey, Object dataValue)
bei SlimDX.Direct3D11.Effect..ctor(Device device, ShaderBytecode data, EffectFlags effectFlags)

Does someone know, how I can disable the shaders using the effect files? Or do I have to disable it in my C# code manually by setting for example the vertex shader of the devicecontext to NULL. Is there an other way to "reset" quickly(!) the shaders on a device? Is this maybe a bug? ^^

##### Share on other sites
OK, I figured it out, that the problem must be a SlimDX or DX bug. The fxc.exe compiler from the DX SDK compiles the shaders successfully. I will post this isue on the SlimDX project page. Maybe they can help. :)

##### Share on other sites
Have you tried using the overloaded Effect ctor with the out errors parameter? It might give you some more information on why SlimDX is having problems with the file (although it uses fxc.exe, so it shouldn't).

I'm assuming you're using the latest SlimDX release too? (Feb 2010)

##### Share on other sites
Yes, I used the 02.2010 release on my first try. Actually I'm using the SVN version, but this has still the same problem.

I tried out the constructor with the out-parameter. But I can't get the error string, because calling to this method causes the mentioned exception.

I've posted this isue here: https://code.google.com/p/slimdx/issues/detail?id=633&colspec=ID%20Type%20Status%20Priority%20Owner%20Summary%20Milestone

##### Share on other sites

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

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628698
• Total Posts
2984274
• ### Similar Content

• Hi, I'm building a game engine using DirectX11 in c++.
I need a basic physics engine to handle collisions and motion, and no time to write my own.
What is the easiest solution for this? Bullet and PhysX both seem too complicated and would still require writing my own wrapper classes, it seems.
I found this thing called PAL - physics abstraction layer that can support bullet, physx, etc, but it's so old and no info on how to download or install it.
The simpler the better. Please let me know, thanks!
• By Hexaa
I try to draw lines with different thicknesses using the geometry shader approach from here:
It seems to work great on my development machine (some Intel HD). However, if I try it on my target (Nvidia NVS 300, yes it's old) I get different results. See the attached images. There
seem to be gaps in my sine signal that the NVS 300 device creates, the intel does what I want and expect in the other picture.
It's a shame, because I just can't figure out why. I expect it to be the same. I get no Error in the debug output, with enabled native debugging. I disabled culling with CullMode.None. Could it be some z-fighting? I have little clue about it but I tested to play around with the RasterizerStateDescription and DepthBias properties with no success, no change at all. Maybe I miss something there?
I develop the application with SharpDX btw.
Any clues or help is very welcome

• Hi,
I'm currently trying to write a shader which shoud compute a fast fourier transform of some data, manipulating the transformed data, do an inverse FFT an then displaying the result as vertex offset and color. I use Unity3d and HLSL as shader language. One of the main problems is that the data should not be passed from CPU to GPU for every frame if possible. My original plan was to use a vertex shader and do the fft there, but I fail to find out how to store changing data betwen shader calls/passes. I found a technique called ping-ponging which seems to be based on writing and exchangeing render targets, but I couldn't find an example for HLSL as a vertex shader yet.
which seem to use COLOR0 and COLOR1 as such render targets.
Is it even possible to do such calculations on the gpu only? (/in this shader stage?, because I need the result of the calculation to modify the vertex offsets there)
I also saw the use of compute shaders in simmilar projects (ocean wave simulation), do they realy copy data between CPU / GPU for every frame?
How does this ping-ponging / rendertarget switching technique work in HLSL?
Have you seen an example of usage?
Thank you
appswert
Hi
Do the atomic operations (InterlockedAdd in my case) should work without any issues on RWByteAddressBuffer and be globaly coherent ?
I'v come back from CUDA world and commited fairly simple kernel that does some job, the pseudo-code is as follows:
(both kernels use that same RWByteAddressBuffer)
first kernel does some job and sets Result[0] = 0;
(using Result.Store(0, 0))
I'v checked with debugger, and indeed the value stored at dword 0 is 0
now my second kernel
RWByteAddressBuffer Result;  [numthreads(8, 8, 8)] void main() {     for (int i = 0; i < 5; i++)     {         uint4 v0 = DoSomeCalculations1();         uint4 v1 = DoSomeCalculations2();         uint4 v2 = DoSomeCalculations3();                  if (v0.w == 0 && v1.w == 0 && v2.w)             continue;         //    increment counter by 3, and get it previous value         // this should basically allocate space for 3 uint4 values in buffer         uint prev;         Result.InterlockedAdd(0, 3, prev);                  // this fills the buffer with 3 uint4 values (+1 is here as the first 16 bytes is occupied by DrawInstancedIndirect data)         Result.Store4((prev+0+1)*16, v0);         Result.Store4((prev+1+1)*16, v1);         Result.Store4((prev+2+1)*16, v2);     } } Now I invoke it with Dispatch(4,4,4)
Now I use DrawInstancedIndirect to draw the buffer, but ocassionaly there is missed triangle here and there for a frame, as if the atomic counter does not work as expected
do I need any additional synchronization there ?
I'v tried 'AllMemoryBarrierWithGroupSync' at the end of kernel, but without effect.
If I do not use atomic counter, and istead just output empty vertices (that will transform into degenerated triangles) the all is OK - as if I'm missing some form of synchronization, but I do not see such a thing in DX11.
I'v tested on both old and new nvidia hardware (680M and 1080, the behaviour is that same).

• Hello,
I am, like many others before me, making a displacement map tesselator. I want render some terrain using a quad, a texture containing heightdata and the geometryshader/tesselator.
So far, Ive managed the utilize the texture on the pixelshader (I return different colors depending on the height). I have also managed to tesselate my surface, i.e. subdivided my quad into lots of triangles .

What doesnt work however is the sampling step on the domain shader. I want to offset the vertices using the heightmap.
I tried calling the same function "textureMap.Sample(textureSampler, texcoord)" as on the pixelshader but got compiling errors. Instead I am now using the "SampleLevel" function to use the 0 mipmap version of the input texture.
But yeah non of this seem to be working. I wont get anything except [0, 0, 0, 0] from my sampler.
Below is some code: The working pixelshader, the broken domain shader where I want to sample, and the instanciations of the samplerstates on the CPU side.
Been stuck on this for a while! Any help would be much appreciated!

Texture2D textureMap: register(t0); SamplerState textureSampler : register(s0); //Pixel shader float4 PS(PS_IN input) : SV_TARGET {     float4 textureColor = textureMap.Sample(textureSampler, input.texcoord);     return textureColor; } GS_IN DS(HS_CONSTANT_DATA input, float3 uvwCoord : SV_DomainLocation, const OutputPatch<DS_IN, 3> patch) {     GS_IN output;     float2 texcoord = uvwCoord.x * patch[0].texcoord.xy + uvwCoord.y * patch[1].texcoord.xy + uvwCoord.z *                    patch[2].texcoord.xy;     float4 textureColor = textureMap.SampleLevel(textureSampler, texcoord.xy, 0);      //fill  and return output....  }             //Sampler             SharpDX.Direct3D11.SamplerStateDescription samplerDescription;             samplerDescription = SharpDX.Direct3D11.SamplerStateDescription.Default();             samplerDescription.Filter = SharpDX.Direct3D11.Filter.MinMagMipLinear;             samplerDescription.AddressU = SharpDX.Direct3D11.TextureAddressMode.Wrap;             samplerDescription.AddressV = SharpDX.Direct3D11.TextureAddressMode.Wrap;             this.samplerStateTextures = new SharpDX.Direct3D11.SamplerState(d3dDevice, samplerDescription);             d3dDeviceContext.PixelShader.SetSampler(0, samplerStateTextures);             d3dDeviceContext.VertexShader.SetSampler(0, samplerStateTextures);             d3dDeviceContext.HullShader.SetSampler(0, samplerStateTextures);             d3dDeviceContext.DomainShader.SetSampler(0, samplerStateTextures);             d3dDeviceContext.GeometryShader.SetSampler(0, samplerStateTextures);

• 20
• 9
• 13
• 13
• 11