• Advertisement
Sign in to follow this  

problem:stream output from vertex shader(not geometry shader)

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

so i was developing a physics system, then i feel the necesity to acces the gpu memory from the shaders to change the vertex buffer fast after moving an object, so i started searching and i find the stream output step in the shaders, so i incorporated this step in my program, modifiying the step because i am still not using the geometry shader as the title of this topic says,i writted all the lines of codes required to do this correctly, the problem came when i runned it in debug mode, the program wasnt going further than the D3DX10CreateEffectFromFile(), it wasnt reading my .fx file, so i started searching for the promen and then i realize that when i added the line:
VertexShader vss = CompileShader( vs_4_0, VS2() );
the D3DX10CreateEffectFromFile() wont read the file, so i want someone to tell me whats the problem, is it a library? what i am missing, the libraries i am using are these:
#include <windows.h>
#include <d3d10.h>
#include <d3dx10.h>
#include "resource.h"
#include <dinput.h>
i am not using DXUT i know the advanceParticles sample from the SDK uses this line and the sample works when i run it from there.

So what i am doing at the end of the .fx file just to prove that that line isnt working is this:

VertexShader vss = CompileShader( vs_4_0, VS2() ); ---> this is the line that makes the file unreadable
technique10 Pa
{
pass P0
{
SetVertexShader( vss ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, PS2() ) );
}
}

And what i am finally wanting to do is this:

VertexShader vss = CompileShader( vs_4_0, VS2() ); ---> this is the line that makes the file unreadable
GeometryShader gss= ConstructGSWithSO( vss, "POSITION.xyz; COLOR.xyzw;VEL.xyz;MASS.x" );
technique10 Pa
{
pass P0
{
SetVertexShader( vss ) );
SetGeometryShader( gss );
SetPixelShader( CompileShader( ps_4_0, PS2() ) );
}
}

but without that first line working this final code wouldnt work.

Share this post


Link to post
Share on other sites
Advertisement
Hidden
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left]CompileShader() is not supposed to be in HLSL. I'm not sure if you knew that or not, but it's supposed to be in your main app, not in the effects file[/left][/size][/font][/color]

Share this post


Link to post
nop it doent because the man has misplaced the code where it doent belong, what happens to me is different, the D3DX10CreateEffectFromFile() stops working when i am using the line i show you, pls read my post correctly

Share this post


Link to post
Share on other sites
i know, that was my mistake, sorry, so i edited my post to say post your vertex shader instead. actually, could you just post your whole effect file?

Share this post


Link to post
Share on other sites
struct VS_INPUT
{
float4 Pos : POSITION;
float4 Color : COLOR;
float3 Vel : VEL;
float Ma : MA;
};



struct PS_INPUT
{
float4 Pos : SV_POSITION;
float4 Color : COLOR;
};



PS_INPUT VS2( VS_INPUT input )
{
PS_INPUT output = (PS_INPUT)0;
output.Pos = mul( input.Pos, World );
output.Pos = mul( output.Pos, View );
output.Pos = mul( output.Pos, Projection );
output.Color = input.Color;
return output;
}

Share this post


Link to post
Share on other sites
Your vertex shader is named VS, but when you try to compile it, you use VS2. do you have another vertex shader?

Share this post


Link to post
Share on other sites
ohhh no i putted the wrong name in here,in my project is ok, i mean thats not the problem sorry for that, just think the name is correct, i am gona edit it

Share this post


Link to post
Share on other sites
the thing is that there is no error with the names in my project, its just that line that makes it all dont work, maybe its because when compile it doent knows what the class VertexShader because the right part of the equation CompileShader( vs_4_0, VS2() ); is running normally when it runs down in the shaders metodos

Share this post


Link to post
Share on other sites
I don't know why, but i used that line just like you did, and it compiles perfect for me. here is the effect file i tried it with:

[code]cbuffer cbPerObject
{
float4x4 WVP;
};

struct VS_INPUT
{
float4 Pos : POSITION;
float4 Color : COLOR;
};

struct VS_OUTPUT
{
float4 Pos : SV_POSITION;
float4 Color : COLOR;
};

VS_OUTPUT VS(VS_INPUT vIn)
{
VS_OUTPUT output = (VS_OUTPUT)0;

output.Pos = mul(vIn.Pos, WVP);
output.Color = vIn.Color;
return output;
}

float4 PS(VS_OUTPUT input) : SV_Target
{
return input.Color;
}

VertexShader vss = CompileShader( vs_4_0, VS() );
GeometryShader gss= ConstructGSWithSO( vss, "POSITION.xyz; COLOR.xyzw" );
technique10 Tech
{
pass P0
{
SetVertexShader(vss );
SetGeometryShader( gss );
SetPixelShader( CompileShader( ps_4_0, PS() ) );
}
}[/code]

I know that's probably not helpful for you. What is the exact error you are getting?

wait, are you saying that if you remove this single line, it works, but if you put it there, it doesn't? does it show you an error for your effect file? or is the error only in the applications code?

Share this post


Link to post
Share on other sites
damm yes it runs here too when i run it in the advanceParticles sample from the sdk but it doent runs in my proyect, read my reply that is behind this one, i edited it

Share this post


Link to post
Share on other sites
this is where it fails

[indent=1]//////////////////////////////////////////////////*******************effect*************************/////////////////////////////////////////
DWORD dwShaderFlags = D3D10_SHADER_ENABLE_STRICTNESS;
#if defined( DEBUG ) || defined( _DEBUG )
dwShaderFlags |= D3D10_SHADER_DEBUG;
#endif

ID3D10Blob* pErr;

hr = D3DX10CreateEffectFromFile( L"Tutorial01.fx", NULL, NULL, "fx_4_0", dwShaderFlags, 0, g_pd3dDevice, NULL,NULL, &g_pEffect, &pErr, NULL );
if( FAILED( hr ) )
{
if (pErr != NULL)
{
LPCSTR psErr = (LPCSTR)pErr->GetBufferPointer();
pErr->Release ();
}

return hr;

}[/indent]

Share this post


Link to post
Share on other sites
ok, this might not be the problem, but i'm just going to ask anyway since i can't see at all what your doing wrong. but did you install a more recent version of directx over an older version of directx?

I'm asking, because a couple months ago or so, i had the second latest version of directx sdk installed. everything worked fine. Then i saw there was a new release of the sdk and installed it "over" the version i had before, so i ended up with two versions. all my projects worked fine, but when i tried to use debug mode for directx 10, it was giving me an error when i used a debug flag. so at first i just stopped using the debug flags for directx 10 projects. last month i decided to reinstal windows, and just got the newest version of the dx sdk, so now i only have the latest version, and everything works normal again. If you have two versions of the sdk installed, try uninstalling both of them, then just reinstall the latest version

Share this post


Link to post
Share on other sites
yes i had a problem installing the Microsoft DirectX SDK (June 2010) because i intalled the Microsoft DirectX SDK (February 2010) first and then i realiced that there was a new version just after intalling it, but when i tried intalling the newest Microsoft DirectX SDK (June 2010), the intaller said that the intallation failed dont remember why, then i saw the samples all that folders i needed from the Microsoft DirectX SDK (June 2010) where there int hte Microsoft DirectX SDK (June 2010) folder so i didnt bothered to reintalling it because the folders were already there with everything, i dont know were the intaller failed, its all there. But ok i will do it i will try unistalling all that, man but that like 600mb to download, mmm it doent matter

Share this post


Link to post
Share on other sites
I am stuck, how do you unistall that, theres no directx sdk program in the control panel programs

Share this post


Link to post
Share on other sites
yeah i know, reinstalling the sdk is a pain because of it's size to download, but i'm sure it's for the better ;) hope it works for ya!

Share this post


Link to post
Share on other sites
hey i ultimately discorvered that the error is in the .fx file (after long test) but i really really dont see where is it look this is the code pls help me find where is the mistake

[code]matrix World;
matrix View;
matrix Projection;
float Time;
//--------------------------------------------------------------------------------------
struct VS_INPUT
{
float4 Pos : POSITION;
float4 Color : COLOR;
float3 Vel : VEL;
float Ma : MA;
};
struct PS_INPUT
{
float4 Pos : SV_POSITION;
float4 Color : COLOR;
};
PS_INPUT VS( VS_INPUT input )
{
PS_INPUT output = (PS_INPUT)0;
output.Pos = mul( input.Pos, World );
output.Pos = mul( output.Pos, View );
output.Pos = mul( output.Pos, Projection );
output.Color = input.Color;
return output;
}
float4 PS( PS_INPUT input) : SV_Target
{
return input.Color;
}
PS_INPUT VS2( VS_INPUT input )
{
PS_INPUT output = (PS_INPUT)0;
output.Pos = mul( input.Pos, World );
output.Pos = mul( output.Pos, View );
output.Pos = mul( output.Pos, Projection );
output.Color = input.Color;
return output;
}
float4 PS2( PS_INPUT input) : SV_Target
{
return input.Color;
}
technique10 Render
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, VS() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, PS() ) );
}
}
VertexShader vss = CompileShader( vs_4_0, VS2() );
technique10 Pa
{
pass P0
{
SetVertexShader( vss ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, PS2() ) );
}
}[/code]

Share this post


Link to post
Share on other sites
come on ppl you can find the mistake, i am stuck because of it, grate proyects come after this big rock thats not letting me pass

Share this post


Link to post
Share on other sites
I really can't see anything wrong at the moment, but you said if you don't use the debug flag when compiling your shader, it works right? I would just skip the debug flag for now. Try out the advanceparticles sample from the sdk or whatever like you said, and try using the debug flag when compiling the shader. if it still doesn't work even with the sample, then i'm sure it's a problem with your directx install

Share this post


Link to post
Share on other sites
hey man replace the .fx proyect that you have any, with my exact .fx file code i will say it would not work

Share this post


Link to post
Share on other sites
maybe this was a mistake, but check out this line:


[color=#660066]SetVertexShader[/color][color=#666600]([/color][color=#000000] vss [/color][color=#666600])[/color][color=#000000] [/color][color=#666600]);[/color]

you have an extra ")". delete one of them if that wasn't just a typo in your post

Otherwise, sorry to say but it does compile for me... Other than that extra ")", there's no errors in the file

Share this post


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

  • Advertisement