| Ralf's profileFun with GPUsBlogLists | Help |
|
August 31 XNA Framework (Beta) finally arrived.
As I prefer to camp in the managed world I couldn’t resist to download the new XNA beta. I must confess that I was less interested in the Game Studio. I was locking for what Microsoft had done with MDX 2. The first impression wasn’t that bad as it looks very similar to what we have seen in MDX 1 and 2. Even if there are some leftovers the fixed function are gone as announced. Some classes are renamed but that’s fine. I like the step that gives us properties for the old descriptions structures. The new effect framework looks very similar what I am already have seen for Direct3D 10. Good work guys.
But with light comes shadows. I really don’t like that the have cut the possibility to lock and unlock resources. This makes dynamic resources less effective. Remove most of Direct3DX doesn’t make me happy too. This reduces the use of the XNA framework to write tools.
As this is only the first impression on a first beta I am still undecided how useful the final version would be for me. If I will not be happy at the end I still could use MDX 1 or write my own wrapper. August 30 The power of reflectionLast night I spend some time on my managed layer for Direct3D 10. It’s nearly complete and therefore I start playing with some advanced features. One thing I never really like since Direct3D 9 was the need to define your vertex structure twice. One time for the compiler and then for Direct3D again. It’s still the same for D3D10. The name has changed from vertex declaration to input layout. Some other details have changed too but the pain to do it twice is still there.
C++:
struct SimpleVertex { D3DXVECTOR3 Pos; D3DXVECTOR4 Color; };
To create and set the input layout for this structure the following code is necessary.
// Define the input layout D3D10_INPUT_ELEMENT_DESC layout[] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 }, { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0 }, }; UINT numElements = sizeof(layout)/sizeof(layout[0]);
// Create the input layout D3D10_PASS_DESC PassDesc; g_pTechnique->GetPassByIndex( 0 )->GetDesc( &PassDesc ); hr = g_pd3dDevice->CreateInputLayout( layout, numElements, PassDesc.pIAInputSignature, PassDesc.IAInputSignatureSize, &g_pVertexLayout ); if( FAILED(hr) ) return hr;
// Set the input layout g_pd3dDevice->IASetInputLayout( g_pVertexLayout );
This can easily be ported to C#:
struct SimpleVertex { public SimpleVertex(DXGI.R32G32B32Float position, DXGI.R32G32B32A32Float color) { this.position = position; this.color = color; }
DXGI.R32G32B32Float position; DXGI.R32G32B32A32Float color; }
// Define the input layout D3D10.InputElement[] layout = new D3D10.InputElement[] { new D3D10.InputElement ("position", 0, DXGI.Format.R32G32B32Float, 0, 0, D3D10.InputClassification.PerVertexData, 0), new D3D10.InputElement ("color", 0, DXGI.Format.R32G32B32A32Float, 0, 12, D3D10.InputClassification.PerVertexData, 0) };
// Create the input layout inputLayout = new D3D10.InputLayout(device, layout, technique.Passes[0].InputAssemblerSignature);
// Set the input layout device.InputAssembler.InputLayout = inputLayout;
Clever usage of propertys save some lines of code but the main problem is still the same. Let’s add some reflection magic.
// Create the input layout inputLayout = new D3D10.InputLayout(device, typeof(SimpleVertex), technique.Passes[0].InputAssemblerSignature);
// Set the input layout device.InputAssembler.InputLayout = inputLayout;
This new construtor I add last night use reflection to analyse the vertex structure and create the nessary layout on the fly. If you change the structure the layout will be automatically in sync. August 26 Time to upgradeAfter staying a long time with Vista Beta2 I moved forward to the new pre RC1 last night. Installation of the ~2.5 GB ISO runs very well. A nice new feature compared to Beta 2 is that it grabs missing drivers from Windows update before it starts installing. No pain to find and install drivers for my two Ethernet adapters without network access this time. As this pre RC1 supports the current August version of D3D 10 I need to upgrade my code to the new interfaces. But with limited amount of changes this should not take that long. I am trying to deliver an updated and more complete version of my managed D3D10 layer over at MDX Info next week. Muhammad Haggag has written a fine managed milkshape model viewer for MDX 1.1. As he was so kindly to release it as public domain I thought I will make a port to my managed D3D10 layer and include it as sample how to use it. August 04 Direct3D 10 changes in the August 2006 release
DirectX SDK August 2006Two months are over again and we got a new SDK. Warning: The Direct3D 10 part will require RC1. |
|
|