Jump to content

  • Log In with Google      Sign In   
  • Create Account

Sawiner

Member Since 09 Sep 2010
Offline Last Active Jan 24 2013 02:33 PM

Topics I've Started

c++ D3D 11 DXGI Present in another thread - window not responding

21 January 2013 - 01:50 PM

Hi guys.

 

 

I'm trying to make a simple game loop, where the

usual window message pump is in the initial thread,

while the directx rendering is at another thread.

 

The code is something like that:

 

// The next method runs at the initial thread
// it is called after DirectX and win32 initialization.
int Run()
{
	std::thread tRender(&ThreadProc_Render);
	if (tRender.joinable())
		tRender.detach();

	MSG msg;
	while (this->m_bRun)
	{
		BOOL bGetMsg(::GetMessage(&msg, NULL, 0, 0));


		if (bGetMsg == -1) // Error
		{
			this->m_bRun = false;
		}
		else if (bGetMsg == 0) // WM_QUIT
			this->m_bRun = false;
		else
		{
			// ::TranslateMessage(&msg);
			::DispatchMessage(&msg);
		}
	}

	return (msg.wParam);
}

 

 

ThreadProc_Render:

void ThreadProc_Render()
{
	StopWatch sw;

	// Render Loop
	while (pWnd->m_bRun)
	{
		uint32 nMS = sw.Restart();
		HRESULT hr(gpSwapChain->Present(0, 0));

		// ::Sleep(15);
		std::this_thread::yield();
	}
}

 

in case you're wondering, StopWatch is a class of mine. Restart()

sets the watch old time to now, and return the different between the old and the new time.

 

The problem is, the window it self is not responding (can't move or resize it)

It seems as if the other thread is taking all the GetMessage() thread resources.

 

However, as you can see, the function call to sleep with 15 ms is commented out.

when it's not commented out, the program runs fine.

 

Also, if I comment out the Present() call, same thing - window seem to "work" again

(can resize, move).

 

Also, when looking at task manager, the application doesn't seem to consume

high cpu at all.

 

As far as I can see, it looks like a blocking issue. The thing is, there is no blocking at all.

I even tried replacing GetMessage() wit PeekMessage(),

and calling 'yield' when there are no messages. That gave me the same result though,

window stuck unless Present() line is commented out (or Sleep isn't).

 

 

Why is this even happening? What am I missing here?

 


drawindexed: index buffer has not enough space!

08 December 2012 - 02:30 AM

I'm working on a project of mine, using D3D11 C++, and from some reason I keep getting the warning that
an index buffer has not enough space.
I'm afraid the code is not as simple to debug, not as short and straight forward, so I would rather
not write it here.

I did however captured a frame using PIX, and uploaded it.
Notice if you go to the last draw frame, and to the 'Render' tab, you'll see
the warning.
The full warning is:
D3D11: WARNING: ID3D11DeviceContext::DrawIndexed: Index buffer has not enough space! [ EXECUTION WARNING #359: DEVICE_DRAW_INDEX_BUFFER_TOO_SMALL ]


You can look at the index buffer size, and the parameters to the DrawIndexed. Combining everything together,
the size of the buffer is big enough.

Also, everything is rendering fine. The only problem is the warning.

Note:
I know PIX is old, however the "new pix" is available in visual studio, but not in express edition. PIX however,
is still free. Which is why i'm using it.

The PIX File:
https://skydrive.live.com/redir?resid=D53CCD6B7847C67F!131&authkey=!AJZnMjFLeh9v7Pc

If anyone has any other place he would like me to upload the PIX file to, please say so.
Also, it would be nice if someone can at least comment and say he see the same thing as me - that is, he see the warning while also seeing buffer is big enough.

VClip Collision Detection - "Planar edges"

24 December 2011 - 01:48 PM

I have been reading the document ( www.merl.com/papers/docs/TR97-05.pdf ) and implement it.


I have almost succeeded, however I am having a few troubles with the EF/FF states;
I am not sure which one is the problematic, I keep getting into infinite loop where I keep changing from first feature to the second one,
and then back to the first one.

After debugging, I noticed something wrong with my topology;
That is, I noticed one of my edges contain a plane, which should contain the set of all points
that are closest to that edges, but isn't.

The problem is, I am constructing the polygon using Incremental algorithm (convex hull construction).
That is, the algorithm is creating triangles and not quadrants, even if they match.
e.g. for a cube, the result will be 12 triangles, and not 6 quadrants.

I was wondering then, how in such case I should handle.
As far as I can see, I have two options:

(a) quadrangulation (not sure how it's written); However, I haven't found any algorithm for it, and really not sure how to do so.
(b) Make the edge have the correct planes. The problem is, the edge shouldn't even have a plane.
The sets of points that are closest to the edge are all only the points above that edge.
Also, if that is the case, how can I represent and create such set of points?

Also, if anyone has any suggestion on how to correctly debug such an algorithm, I would be helpful.
The problem debugging such code is understanding the meaning of the values. I understand the code and what
it's supposes to do, but I can't be sure if it does it right or wrong because of the values, and something
the scene isn't clear enough.

Rotational Joint Constraints (using Quaternions)

09 September 2010 - 08:59 AM

A bit more than a week ago I have started creating a real-time IK system for my solvers. I looked up solvers and implemented the simplest one, CCD Limb IK Solver.

It was really easy creating it, however after first few times of checking I noticed the problem: the joints were rotating in a way that is not humanly possible, and I figured I need joint rotational constraints, so joints like the elbow won't be able to rotate everywhere they go.

I represent rotations using quaternions.

My initial idea was at each step of the solver, to take the rotation defined by a quaternion that the solver find(calculates), and constraint it using 6 floats: minX, maxX, minY, maxY, minZ, maxZ.

I tried to look it up online, and it seem to involve a lot of math; A lot more I thought I initially thought I will need.

Then I also thought I could try to convert the quaternions to euler angles (probably Yaw Pitch Roll), clamp them, then create the quaternion from it again.
The problem of it is, I would lose all the advantages of using quaternions over euler angles... right?

My questions are these then:

1. Is there a better way to create joint rotational constraints? or even a better approach for constraining the joint, so such a problem like the elbow problem I mentioned above won't happen ? (hopefully while still using quaternions)

2. If this is the only approach to, and I just need to learn more mat in order to constrain the quaternions, can anyone refer/suggest me to a good resource (such as a website or even book), perhaps including some specific subjects I should learn ?

Yours, Matan.

p.s.
I'm using xna and quaternions, and I have to say I wasn't sure if this is the right forum to post this message in. However my question is more math related than xna related, so I hope this is the right forum to post this in.

PARTNERS