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

Started by
28 comments, last by lomateron 12 years, 2 months ago
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.
Advertisement
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

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

[/font]

Is there a problem with your vertex shader maybe? try posting your vertex shader
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
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?
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;
}
Your vertex shader is named VS, but when you try to compile it, you use VS2. do you have another vertex shader?
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
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
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:

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() ) );
}
}


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?

This topic is closed to new replies.

Advertisement