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!

Nick C.

Member Since 06 Nov 2012
Offline Last Active Mar 08 2015 06:11 PM

Topics I've Started

debugging extremely slow after CreateSwapChain

05 October 2014 - 04:43 AM

Hello everyone

Everything was going well with the project I'm working on, until suddenly it's almost impossible to debug my code.

I can step over all my instructions in Visual Studio just fine, until I try to create a swap chain. From then on, I can barely move my mouse (5+ seconds to see change), and everything in visual studio takes  a very long time. Stepping over instructions then take up to 5 seconds and almost 20 seconds to stop debugging (shift + F5). All other programs running on my computer have no problems though.

I've used this code for over two years now, and never had any problems.

At this point, it's just impossible to continue my work if I can't solve this problem. Any help would be greatly appreciated.

Edit: I also notice calling std::exit(0) takes longer than usual.

Code (in case it matters):

bool D3DApp::InitD3D()
	UINT createDeviceFlags = 0;
#if defined(DEBUG) || defined(_DEBUG)  
	createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;

	D3D_FEATURE_LEVEL featureLevel;
		0,                 // default adapter
		0,                 // no software device
		0, 0,              // default feature level array
		&D3D->md3dImmediateContext), "D3D11CreateDevice failed.");

	if (featureLevel != D3D_FEATURE_LEVEL_11_0)
		MessageBox(0, "Direct3D Feature Level 11 unsupported.", 0, 0);
		return false;

		DXGI_FORMAT_R8G8B8A8_UNORM, 4, &D3D->m4xMsaaQuality), "Multisample quality level not supported by device.");

	sd.BufferDesc.Width = WINDOW->mClientWidth;
	sd.BufferDesc.Height = WINDOW->mClientHeight;
	sd.BufferDesc.RefreshRate.Numerator = 60;
	sd.BufferDesc.RefreshRate.Denominator = 1;
	sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;

	if (D3D->mEnable4xMsaa)
		sd.SampleDesc.Count = 4;
		sd.SampleDesc.Quality = D3D->m4xMsaaQuality - 1;
		sd.SampleDesc.Count = 1;
		sd.SampleDesc.Quality = 0;

	sd.BufferCount = 1;
	sd.OutputWindow = mhMainWnd;
	sd.Windowed = true;
	sd.Flags = 0;

	IDXGIDevice* dxgiDevice = 0;
	HR(D3D->md3dDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice), "D3D::md3dDevice->QueryInterface failed.");
	IDXGIAdapter* dxgiAdapter = 0;
	HR(dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&dxgiAdapter), "dxgiDevice->GetParent failed.");
	IDXGIFactory* dxgiFactory = 0;
	HR(dxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&dxgiFactory), "dxgiDevice->GetParent failed.");
	HR(dxgiFactory->CreateSwapChain(D3D->md3dDevice, &sd, &D3D->mSwapChain), "dxgiFactory->CreateSwapChain failed.");



	return true;

optimizing my code (memory usage, postfix and prefix notation, "continue")

27 March 2013 - 08:47 AM

Hello all

I don't usually write posts here, as I can find most information in the books I have, but I really have an interesting question here.
I read some info on sequence points and order of evaluation in C++, but I'm still not sure about this issue.

I have the following code (tiny part of a bigger function ofcourse).

line is a string, ll is an int, j is an int and splitchar is a char
The object of this piece of code is to increase j by 1, as long as the characer of line with index j, equals splitchar.
The character of line with index j, before execution of the inner while loop code, always equals splitchar, quaranteed. So j will be increased by at least one.

//some code
int ll = line.length();
int  j(0);
while(j < ll)
//some code that uses and changes j, but nothing very important. It doesn't influence the following code or the subject of this topic.
while (j < ll - 1 && line[j] == splitchar)
//some code

I changed the inner while loop to

while (j++ < ll - 1 && line[j] == splitchar)


while (j < ll - 1 && line[++j] == splitchar)


which are pretty much the same. Trust me, I've tested everything in detail ;)
Note: postfix or prefix notation is very important here!


Now, my questions are;

1. Does it matter if I write "continue", or empty braces ("{}") in the last two examples, and how does this affect the performance?
2. Which one of these three would have the best performance?

3. Is there an even better possibility?

Performance is not very important in this program, but I really want to know the little details, because it WILL matter in future projects.
Thanks in advance smile.png


hundreds of errors and warnings in xnamath.h

29 November 2012 - 05:17 PM

Hello everyone.
I'm getting hundreds of errors (251 to be precise) in the file xnamath.h. I'm not going to show them all, because that wouldn't make sense. The file is fine, and I can use it perfectly in other projects. It's hard to find the cause of a problem if visual studio shows errors which are not wrong. I got this problem when creating the following class (pretty simple, so I don't see how this would cause any problems). Thanks in advance. (btw, I'm pretty sure this belongs to general programming. If not, sorry about that Posted Image )


[source lang="cpp"]#include "ModelInstance.h"ModelInstance::ModelInstance(XMFLOAT3 scale, XMFLOAT3 rot, XMFLOAT3 offset) :Scale(scale), Rot(rot), Offset(offset), Scale2(XMFLOAT3(1.0f, 1.0f, 1.0f)), Rot2(XMFLOAT3(0, 0, 0)), Offset2(XMFLOAT3(0, 0, 0)){}ModelInstance::~ModelInstance(){}void Modelinstance::Update(float dt, bool walk, XMFLOAT3 scale, XMFLOAT3 rot, XMFLOAT3 offset){ Scale2 = scale; Rot2 = rot; Offset2 = offset;}XMFLOAT4X4 Modelinstance::World(){ XMFLOAT4X4 worldTransform; XMStoreFloat4x4(&worldTransform, XMMatrixScaling(Scale.x, Scale.y, Scale.z) * (XMMatrixRotationX(Rot.x) * XMMatrixRotationY(Rot.y) * XMMatrixRotationZ(Rot.z)) * XMMatrixTranslation(Offset.x, Offset.y, Offset.z) * XMMatrixScaling(Scale2.x, Scale2.y, Scale2.z) * (XMMatrixRotationX(Rot2.x) * XMMatrixRotationY(Rot2.y) * XMMatrixRotationZ(Rot2.z)) * XMMatrixTranslation(Offset2.x, Offset2.y, Offset2.z)); return worldTransform;}[/source]


[source lang="cpp"]#ifndef MODELINSTANCE_H#define MODELINSTANCE_H#include <xnamath.h>struct ModelInstance{public: ModelInstance(XMFLOAT3 scale, XMFLOAT3 rot, XMFLOAT3 offset); virtual ~ModelInstance(); virtual void Update(float dt, bool walk, XMFLOAT3 scale, XMFLOAT3 rot, XMFLOAT3 offset); XMFLOAT4X4 World();protected: XMFLOAT3 Scale, Scale2; XMFLOAT3 Rot, Rot2; XMFLOAT3 Offset, Offset2;};#endif[/source]

'Unresolved external symbol' when using static struct in static method

11 November 2012 - 09:39 AM

Hello everyone

I'm writing an input managing class, and I've stumbled upon a problem right now. I've been trying to fix it for a long time, but I just don't see the problem. It's probably a minor detail (like always.. -.-), but I would really apreciate it if someone could take a look at it.

The error I'm getting is:

Error 13 error LNK2001: unresolved external symbol "private: static struct Input::Keyinfo * Input::KeyinfoArr" (?KeyinfoArr@Input@@0PAUKeyinfo@1@A) C:\Nick\D3D projects\DVD\Code\Chapter 25 Character Animation\SkinnedMesh\InputManager.obj

[source lang="cpp"]header file:struct Input{//...some codepublic: enum Action{ MOVEFORWARD, MOVEBACKWARD, STRAFELEFT, STRAFERIGHT, JUMP}; static bool AllowAction(Action action);private: //...some code static const int ACTIONCOUNT = 5; // amount of possible controls/actions struct Keyinfo { Action action; int code; // virtual-key code associated with action bool pressed; bool down; }; static Keyinfo KeyinfoArr[ACTIONCOUNT];};cpp file://...some codebool Input::AllowAction(Action action){ for (int i = 0; i < ACTIONCOUNT; ++i) { if (KeyinfoArr[i].action == action) {if ((KeyinfoArr[i].action == Action::MOVEFORWARD ||KeyinfoArr[i].action == Action::MOVEBACKWARD ||KeyinfoArr[i].action == Action::STRAFELEFT ||KeyinfoArr[i].action == Action::STRAFELEFT)&& KeyinfoArr[i].down) return true; if (KeyinfoArr[i].action == Action::MOVEFORWARD && KeyinfoArr[i].pressed) return true; } } return false;}[/source]

Program exits at Direct3D initialization (D3D11CreateDevice)

06 November 2012 - 04:26 AM

Hello everyone

About a week ago I've started reading "3D game programming with DirectX 11" by Frank D. Luna. After a few days I came at the point of the initialization. It took me a while to get everything to work properly (linking libraries (especially Effects11.lib) and including wrong paths), but eventually it worked. But all of a sudden (that's what I'm here for, possible causes Posted Image), not one of my projects works anymore. In each of my projects the program exits at the same line: D3D11CreateDevice. Using breakpoints, I can't step into the line. I don't get any errors or warnings.

The values of the datamembers, just before execution of this method are:

createDeviceFlags = 2; (changed from 0 to 2 at the preceding instruction)
D3D11_SDK_VERSION: speaks for itself. (7 possibilities ofcourse)
&md3dDevice, and &md3dImmediateContext: 0X00000000;
&featureLevel: some random address;

Any possible causes would be appreciated Posted Image
Btw, I've already reinstalled directx sdk (June 2010), after some problems.

[source lang="cpp"]bool D3DApp::InitDirect3D(){// Create the device and device context.UINT createDeviceFlags = 0;#if defined(DEBUG) || defined(_DEBUG) createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;#endifD3D_FEATURE_LEVEL featureLevel;HRESULT hr = D3D11CreateDevice( 0, // default adapter md3dDriverType, 0, // no software device createDeviceFlags, 0, 0, // default feature level array D3D11_SDK_VERSION, &md3dDevice, &featureLevel, &md3dImmediateContext); //...remaining thing to do}[/source]

Edit: Sigh, even code tags don't work -.-
Edit2: Damnit, I don't know anymore, recreated project (new projects, but dragged same files), and now I'm getting the same error I got a few hours ago:
"warning LNK4204: 'C:\Nick\D3D projects\DVD\Code\Test\Debug\vc100.pdb' is missing debugging information for referencing module; linking object as if no debug info C:\Nick\D3D projects\DVD\Code\Test\Effects11d.lib(d3dx11dbg.obj)"

14 warnings. Alle possible solutions I found from google didn't help.