Jump to content

  • Log In with Google      Sign In   
  • Create Account

Funkymunky

Member Since 28 Jul 1999
Offline Last Active Yesterday, 08:39 PM

Topics I've Started

Direct2D kills my CriticalSection...?

11 December 2014 - 09:24 PM

I have an Application, running on Windows 7, compiled with Visual Studio 2013.  It uses sockets to interact with another program.  That program sends one string to this program, who has a "receiver" thread running that stores the string into a queue. The receiver thread calls EnterCriticalSection, puts the string in the queue, and then calls LeaveCriticalSection.  In the main thread of the program, it calls TryEnterCriticalSection before checking this queue and retrieving the string, and then calls LeaveCriticalSection.

 

This all worked beautifully every time I tried it.  Then I added a minimal Direct2D rendering to the program and it stopped working!  Literally, all I'm doing extra now is calling:

 

rt->BeginDraw();
rt->Clear();
rt->EndDraw();

...

 

And now it never succeeds on the TryEnterCriticalSection calls!  Has anyone seen anything like this before?


Windows Dialog Background Color

06 December 2014 - 10:21 PM

I recently downloaded the Visual Studio 2013 Community Edition after years of using Express editions.  This means I can finally use the built-in resource editor again for things like Icons and Dialog Boxes!

 

Which is awesome, but now I'm trying to do it and I'm struggling to just set the background color of the dialog box.  I created it, I set "Use MFC" to False, and I assigned the same Class Name that I set in my WNDCLASS structure (that I then pass to RegisterClassW).  This has the desired effect of using the icon I wanted for the dialog!  But no matter what I try, I can't get the thing to draw with a default background color.  It's always white.  From everything I've read, I should just have to set "wc.hbrBackground = (HBRUSH)(COLOR_BACKGROUND + 1);"

 

But it doesn't work.  Nothing I set in wc.hbrBackground seems to have any effect.  The only thing that does anything is when I override WM_ERASEBKGND and do a FillRect with a brush from GetSysColorBrush, but I don't want to really do all that.  I want to just get the default erase mechanism to paint my window the default gray color of a regular dialog window.

 

What am I missing...?


Multiple Inheritance or lots of pointers?

27 November 2014 - 10:10 PM

Say I have a class called "Entity".  I want to have different types of "Entity"s: An Entity with Mesh data, an Entity with Physics data, an Entity with Skeletal Animation data, etc.

 

I could create the base Entity class, and then inherit these other Entity types.  Or I could just include a pointer to Mesh data, Physics data, Skeletal data etc. in every Entity, and I would only assign the data that the Entity actually used.  This would be beneficial since I might have an Entity that has both Mesh and Physics data, and I could avoid doing multiple inheritance.

 

I'm actually learning toward the second method, even though it wastes a little extra memory.  Is there a generally agreed upon methodology behind this?  Or any strong opinions either way?  (Or another better option that I haven't thought of?)


DirectCompute UAV between CS and PS

19 October 2014 - 05:36 PM

(I apologize if this is a bit verbose, but I want to make sure I cite everything I'm doing).

 

I am trying to get the basics of DirectCompute up and running.  I want to have a compute shader that fills out an array, which I can then use in my pixel shader.  I am specifically trying to get an array of data here, not a texture, because of how I eventually intend to use this.

 

So I do my calls to D3DX11CompileFromFile, CreateComputeShader, CSSetShader, and everything seems fine (no error messages).  My target buffer is a 32x32 array of float4 data.  I called CreateUnorderedAccessView with a buffer and a descriptor calling out that size.  Here is what my compute shader looks like:

.

RWStructuredBuffer<float4> dataBuffer : register(u0);

[numthreads(16, 16, 1)]
void main(uint3 DTid : SV_DispatchThreadID)
{
	dataBuffer[DTid.y * 32 + DTid.x] = float4(DTid.x / 32.0, 0.0, DTid.y / 32.0, 1.0);
}

.

I call UseProgram, CSSetUnorderedAccessViews(0, 1, &UAV, &initCounts), and then Dispatch(2, 2, 1).  Everything seems fine.  Now I want to see this data in the pixel shader, just as a debugging exercise.  So this is my pixel shader (it's just being performed on a quad):

.

struct PixelInputType
{
	float4 position : SV_POSITION;
	float2 uv : TEXCOORD0;
};

RWStructuredBuffer<float4> dataBuffer : register(u1);

float4 main(PixelInputType input) : SV_TARGET
{
	int x = (int)(input.uv.x * 32.0);
	int y = (int)(input.uv.y * 32.0);
	return dataBuffer[y * 32 + x];
}

.

The intention being to just see a red/blue gradient.  I render this like I've rendered countless other quads, but I try to bind the UAV with OMSetRenderTargetsAndUnorderedAccessViews(D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL, NULL, NULL, 1, 1, &UAV, &initCounts);

 

 

...

 

 

I get no errors, but my pixel shader shows me absolutely nothing.  Does that at least look like the right sequence of calls?  I'm scratching my head as to what could have went wrong and where.


DX11 HLSL: pass SamplerState to a function?

27 September 2014 - 06:41 PM

I have a texture sampler that I set via PSSetSamplers and define in the HLSL code as "SamplerState sampler;"  I have a function in the HLSL code that I want to pass the sampler to, like this:

 

"float4 texFunc(Texture3D table, SamplerState sampler..."

 

But I get an error on that function declaration: "syntax error: unexpected token 'sampler'"  Why is that?  How can I tell my hlsl function which sampler, defined in my cpu-side program, to use?  (I want to pass it to the function because it is common code that is called from several different shaders).


PARTNERS