Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 29 Dec 2006
Offline Last Active Dec 20 2012 06:23 PM

Topics I've Started

Shaders and Constant Buffer behavior?

11 April 2012 - 06:24 PM

When setting constant buffers to a shader, does DirectX assignn it to the specific shader that is currently loaded, and remember it is for that shader? Or does it keep the same buffer applied through shader changes, and the buffer must be changed as well?

As an example, say I have two different vertex shaders, and each has it's own constant buffer, like the simplified snippet below.

ID3D11Device* Device;
ID3D11DeviceContext* DevCon;
ID3D11VertexShader* Shader1;
ID3D11VertexShader* Shader2;
ID3D11Buffer* CBuff1;
ID3D11Buffer* CBuff2;
//initialization code

//Render Routine
DevCon->VSSetShader(Shader1, NULL, 0);
DevCon->VSSetConstantBuffers(0, 1, CBuff1);
	 //Draw stuff with shader1
DevCon->VSSetShader(Shader2, NULL, 0);
DevCon->VSSetConstantBuffers(0, 1, CBuff2);
	 //Draw stuff with shader2

Now, if I then swap back to Shader1...
DevCon->VSSetShader(Shader1, NULL, 0);
Does DirectX remember to use CBuff1, or do I need to reset it as well?

Runs in debug, not release

28 March 2012 - 04:09 PM

I am using Visual C++ 2010 Express, and I just finished the basics of my engine code, and wanted to test under release to ensure it worked properly. I started by changing the settings in the directx control panel to force debug layer off, swapped to release mode, and added the include and lib directories (same as the debug directories). The program compiles and links fine, with no errors, but when I try to run the executable it crashes. I am using DirectInput for all input and XAudio2 for sound. The sounds I have playing actually start before the program crashes, so I'm sure it's in the graphics.

The odd thing in, I can navigate in windows to the debug executable, and it runs perfectly fine. Is there some other step that must be taken when switching to release mode for it to run properly, when running D3D11? I've been looking for a while now, and the only things I can find are questions about getting an app to run on a different computer, not just swapping from debug to release.


Application won't run?

17 March 2012 - 04:08 PM

I've been writing an application using Visual C++ 2010 Express, and using DirectX 11. It runs fine when I run it from within VC++ Express, but when I try to locate the generated exe file, and run it that way, it crashes every time. Is there something special that must be done before the program can be run in this way?

Why would this fail?

03 March 2012 - 07:42 PM

I am working on developing code to write text to the screen using C++ and DirectX11, and in the code where the text can be changed, I'm getting an error. The error says

Windows has triggered a breakpoint in ZLib.exe.
This may be due to a corruption of the heap, which indicates a bug in ZLib.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while ZLib.exe has focus.
The output window may have more diagnostic information.

I don't see anything extra in the output window, other than "Critical error detected c0000374"

Using breakpoints, I've narrowed down the line that causes the error to this.
int* temp = new int[new_len];
I've also checked the value of new_len in debug mode, to make sure that wasn't the problem, and it is an int variable equal to 11 when it hits this spot. I didn't post all the code, as I can't see why this would fail regardless, but I can if needed. Can anyone help me figure out what's going on?

Vertex Shader Problem

01 February 2012 - 07:10 PM

I'm having trouble with my 3rd vertex shader for my application. I am getting E_FAIL result when calling
D3DX11CompileFromFile. Can anyone take a look at the HLSL below, and let me know if you see anything? I've been over it numerous times, and can't see what I'm doing wrong.

// Buffers
cbuffer OnScreen : register( b0 )
float2 screenSize;
// Typedefs
struct VertexInput
float4 Pos : POSITION;
	float2 Tex : TEXCOORD0;
float2 sPos : TEXCOORD1;
float2 sSize : TEXCOORD2;
float2 tPos : TEXCOORD3;
float2 tSize : TEXCOORD4;
struct PixelInput
	float4 Pos : SV_POSITION;
	float2 Tex : TEXCOORD0;

// Vertex Shader
PixelInput VS( VertexInput input )
	PixelInput output;
output.Pos = input.Pos;
output.Pos[0] = (((output.Pos[0] * output.sSize[0]) + output.sPos[0]) / screenSize[0]) - 1;
output.Pos[1] = (((output.Pos[1] * output.sSize[1]) + output.sPos[1]) / screenSize[1]) - 1;
	output.Tex = input.Tex;
output.Tex[0] = ((output.Tex[0] * input.tSize[0]) + input.tPos[0]);
output.Tex[1] = ((output.Tex[1] * input.tSize[1]) + input.tPos[1]);
	return output;