Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 13 Nov 2008
Offline Last Active Mar 27 2014 06:52 AM

Posts I've Made

In Topic: C++ error

25 September 2013 - 06:33 AM

Oh, ok.. I see! :) But check your result values anyway.

In Topic: C++ error

25 September 2013 - 06:31 AM

Maybe D3D11CreateDeviceAndSwapChain failed and your device context is not initialized properly. You should definitely check your result values (i.e.):

HRESULT hr = D3D11CreateDeviceAndSwapChain(NULL,

if (FAILED(hr))
  // do your error handling

In Topic: Particles Rotation

09 August 2013 - 07:16 AM

You could just set up to UNIT_Y (some pseudocode):

view = normalize(cameraOrigin - particleOrigin);
if (sphericalBillboard) // whenever the particle normal should truly face the camera
  vertical = cameraUpVector;
  vertical = Vector3::UNIT_Y;
horizontal = cross(view, vertical);

Keep in mind to do the calculation in the right space (i.e. worldspace) and to adjust to your coordinate system.

In Topic: Asynchronous constant buffer update

17 July 2013 - 07:36 AM

The BUFFER_DESC is fairly standard:

const bool isStatic = (flags & CBF_STATIC_BUFFER) != 0;

desc.ByteWidth = size; // size is already multiple of 16 here
desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
desc.CPUAccessFlags = 0;

if (isStatic)
  desc.Usage = D3D11_USAGE_IMMUTABLE;
  desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
  desc.Usage = D3D11_USAGE_DYNAMIC;
desc.MiscFlags = 0;
desc.StructureByteStride = 0;

data.pSysMem = p_Data;
data.SysMemPitch = 0;
data.SysMemSlicePitch = 0;

ID3D11Buffer* buffer;
hr = device->CreateBuffer(&desc, isStatic ? &data : 0, &buffer);
I can't provide the actual update code, since it's to deeply integrated in the engine. But what basically happens is that the buffers which are marked for update are mapped, the memory chunk is copied via memcpy and the buffers are unmapped afterwards.

Note: the device is only *thread-safe* for resource creation.

Yes, I'm aware of that. But the context can be used still from many threads, although the access needs to be synchronized manually. I thought maybe someone here does have some knowledge with this.

In Topic: DirectX11 performance problems

12 July 2013 - 01:44 AM

For release builds no flags are set when shaders are compiled, except for matrix order. For debug I use DEBUG, PREFRER_FLOW_CONTROL and SKIP_OPTIMIZATION. As for the InputLayouts. I use a simple caching system to share inputlayouts whenever possible. Whenever a shader is associated with some renderable entity a IL is requested from the cache. A hash is created over the vertex declaration and the shader input signature and if an equal hash is found the layout is returned and shared. Otherwise a new layout is created. This all happens only once per shader-renderable entity combination at loading time, so I assure not to create this stuff 'on the fly' at runtime.