Ralf's profileFun with GPUsBlogLists Tools Help

Blog


    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 reflection

    Last 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 upgrade

    After 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

    • The Shader Mirror interface is removed
      • D3D10_VERTEX_SHADER_DESC is removed
      • D3D10_GEOMETRY_SHADER_DESC is removed
      • D3D10_PIXEL_SHADER_DESC is removed
      • D3D10_INPUT_LAYOUT_DESC is removed
    • D3D10_COMMONSHADER_CONSTANT_BUFFER_SLOT_COUNT (15) is replaced byD3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT ( 14 ) andD3D10_COMMONSHADER_CONSTANT_BUFFER_HW_SLOT_COUNT ( 15 )
    • D3D10_FTOU_INSTRUCTION_MAX_INPUT is changed from 4294967296.999f to 4294967295.999f
    • D3D10_REQ_MIP_LEVELS is changed from 13 to 14
    • The specification date is now 06/21/2006 and the version is 1.050004
    • The WGF version is finally removed
    • The constant D3D10_APPEND_ALIGNED_ELEMENT is added
    • The D3D10_FRONT_WINDING enumeration is removed
    • The D3D10_BUFFEROFFSET_APPEND constant is removed
    • Two new format support flags
      • D3D10_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET
      • D3D10_FORMAT_SUPPORT_MULTISAMPLE_LOAD
    • Get and Set methods now use “StartSlot” instead of “Offset” as variable name
    • Methods that need a pointer to shader byte code need the size too
    • The new SDK Version is 29
    • D3D10_COMPILE_CHILD_EFFECT is replaced with D3D10_EFFECT_COMPILE_CHILD_EFFECT
    • D3D10_COMPILE_DISABLE_PERFORMANCE_MODE is replaced with D3D10_EFFECT_COMPILE_ALLOW_SLOW_OPS
    • New effect variable flag: D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT
    • D3D10_EFFECT_VARIABLE_DESC has a new member: ExplicitBindPoint
    • New As methods for effect variables:
      • AsRenderTargetView
      • AsDepthStencilView
    • New element in D3D10_PASS_DESC structure: IAInputSignatureSize
    • New shader variable flag: D3D10_SVF_USED
    • New shader variable types:
      • D3D10_SVT_TEXTURE2DMS
      • D3D10_SVT_TEXTURE2DMSARRAY
    • Multiple new count values in the shader description structure:
      • TempArrayCount
      • DefCount
      • DclCount
      • TextureNormalInstructions
      • TextureLoadInstructions
      • TextureCompInstructions
      • TextureGradientInstructions
      • FloatInstructionCount
      • IntInstructionCount
      • UintInstructionCount
      • StaticFlowControlCount
      • DynamicFlowControlCount
      • MacroInstructionCount
      • ArrayInstructionCount
      • CutInstructionCount
      • EmitInstructionCount
    • The D3D10_SHADER_TYPE_DESC structure contains a new offset member
    • The GetShaderSize functions is removed
    • D3D10ReflectShader, D3D10GetInputSignatureBlob, D3D10GetOutputSignatureBlob and D3D10GetInputAndOutputSignatureBlob now requires the size of the shader code.
    • The DXGI_SWAP_CHAIN_DESC don’t have the MaxFrameLatency and BufferRotation members anymore.
    • CreateDataTransportDevice is removed
    • New status result code: DXGI_STATUS_MODE_CHANGED
    • New error result: DXGI_ERROR_FRAME_STATISTICS_DISJOINT

    DirectX SDK August 2006

    Two months are over again and we got a new SDK.

    Warning: The Direct3D 10 part will require RC1.