• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

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

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

29 replies to this topic

### #1lomateron  Members

Posted 03 February 2012 - 03:25 AM

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

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

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

### #2iedoc  GDNet+

Posted 03 February 2012 - 04:48 AM

Is there a problem with your vertex shader maybe? try posting your vertex shader
Braynzar Soft - DirectX Lessons & Game Programming Resources!

### #3lomateron  Members

Posted 03 February 2012 - 04:54 AM

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

### #4iedoc  GDNet+

Posted 03 February 2012 - 04:57 AM

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?
Braynzar Soft - DirectX Lessons & Game Programming Resources!

### #5lomateron  Members

Posted 03 February 2012 - 04:59 AM

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

### #6iedoc  GDNet+

Posted 03 February 2012 - 05:05 AM

Your vertex shader is named VS, but when you try to compile it, you use VS2. do you have another vertex shader?
Braynzar Soft - DirectX Lessons & Game Programming Resources!

### #7lomateron  Members

Posted 03 February 2012 - 05:09 AM

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

### #8lomateron  Members

Posted 03 February 2012 - 05:16 AM

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

### #9iedoc  GDNet+

Posted 03 February 2012 - 05:21 AM

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
{
}
}

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?
Braynzar Soft - DirectX Lessons & Game Programming Resources!

### #10lomateron  Members

Posted 03 February 2012 - 05:25 AM

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

### #11lomateron  Members

Posted 03 February 2012 - 05:30 AM

the error is:CXX0030: Error: expression canot be evaluated

### #12iedoc  GDNet+

Posted 03 February 2012 - 05:31 AM

could you post a little of your applications code? like when you compile the shader?
Braynzar Soft - DirectX Lessons & Game Programming Resources!

### #13lomateron  Members

Posted 03 February 2012 - 05:39 AM

this is where it fails

//////////////////////////////////////////////////*******************effect*************************/////////////////////////////////////////
#if defined( DEBUG ) || defined( _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;

}

### #14iedoc  GDNet+

Posted 03 February 2012 - 05:52 AM

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
Braynzar Soft - DirectX Lessons & Game Programming Resources!

### #15lomateron  Members

Posted 03 February 2012 - 06:06 AM

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

### #16lomateron  Members

Posted 03 February 2012 - 06:18 AM

I am stuck, how do you unistall that, theres no directx sdk program in the control panel programs

### #17iedoc  GDNet+

Posted 03 February 2012 - 06:19 AM

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!
Braynzar Soft - DirectX Lessons & Game Programming Resources!

### #18lomateron  Members

Posted 03 February 2012 - 08:56 AM

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

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
{
}
}
VertexShader vss = CompileShader( vs_4_0, VS2() );
technique10 Pa
{
pass P0
{
SetVertexShader( vss ) );
}
}

### #19lomateron  Members

Posted 03 February 2012 - 11:25 AM

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

### #20iedoc  GDNet+

Posted 03 February 2012 - 11:29 AM

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
Braynzar Soft - DirectX Lessons & Game Programming Resources!

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.