ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Overview of Direct3D 11
    CS/게임 프로그래밍 2024. 1. 29. 15:05

    책 정보 : 실용 Direct3D 11 렌더링 & 계산 (Jason Zink, Matt Pettineo, Jack Hoxley 저 | 류광 역)

    Direct3D Framework

    Direct3D 11

    • Native API (Application Programming Interface), used to render an image by controlling and linking the computer's video hardware.
    • Native code : written in the "native" machine language of the computer that is running on and is executed directly by the processor.

     

    Graphic Architecture

    • Application
      • Mainly interacts with Direct3D in the uppermost position.
      • Control how data is presented to an output.
      • Provide high-level contents. (image, text, animation, etc...)
    • Direct 3D runtime module
      • Convert high-level contents to the form which user mode driver can translate.
      • Generate the command for GPU with user mode driver.
    • DXGI (Microsoft DirectX Graphics Infrastructure)
      • Handle low-level communication with the kernel mode driver.
      • Manage available hardware resources.
    • Windows Display Driver Model (WDDM)
      • Virtualize video resources so that all applications can share them.

    Layout of DXGI (Microsoft DirectX Graphics Infrastructure)

     

    Resource

    Types of the Resource

    • Texture : Classified in dimensions.
    • Buffer : Classified as content or purpose.

     

    Where to use Resources

    • C/C++ : Generate resources and connect or detach them to the right place on the pipeline.
    • HLSL : Manipulate or consume the contents of resources.

     

    Resource View

    • Objects required to bind resources to pipelines.
    • Types of resource view
      • Render Target View, RTV
      • Depth Stencil View, DSV
      • Shader Resource View, SRV
      • Unordered Access View, UAV

     

    Direct3D Interface

    Device

    • Used to create and link resources.
    • Supply of various resources to be used in the application program.
    • Provide several methods for resource generation.
    • Provide several methods for diagnosis and debugging.
    • Feature level encapsulation : executable in hardware consisting of previous versions of features

     

    Device Context

    • Used to bind a device-generated resource or object to a pipeline.
    • Control the execution of rendering pipelines and calculating pipelines.
    • Two types of context support for multithread rendering
      1. Immediate Context
        • An interface for direct interaction with all components of the pipeline.
        • Only one immediate context is available in one application.
        • Must be used as the top priority for GPU on the main rendering thread.
      2. Deferred Context
        • Provide a mechanism to safely record commands sent by secondary threads.
        • Create a command list object and play it on the main thread later.

     

    Direct3D Basics

    Interfacing with Direct3D

    • Component Object Model, COM
      • Standards and servicves at the binary level that allow software components made in different languages to be shared and intergrated with other software.
      • The interface does not change.
      • Independent on programming langauge.
      • External program can access to methods of COM components, not COM data (security assurance)
    • Reference Counting
      • Manage the lifetime of COM objects.
      • Return a reference to the object when Direct3D creates a COM object.
      • Both application and Direct3D 11 can share objects with multiple references.
      • After using up the object, the method to release must be called.
    • Interface Query
      • IUnknown::QueryInterface()
      • A query method providing the additional interfaces that an object is implementing.
      • Parameter : UUID (universal unique identifier), Pointer
        1. UUID : the identifier of the interface.
        2. Pointer : appropriate reference when an object implements the corresponding interface, which increase the reference counter of the object.
      • An interface for debug or a DXGI interface from a device.
    • HRESULT
      • Success (S_OK) or failure (E_FAIL) as a return value of the method call.
    // The example of HRESULT
    HRESULT hr = m_pDevice->CreateBlendState(&Config, &pState);
    if (FAILED(hr))
    {
        Log::Get().Write(L"Failed to create blend state!");
        return(-1);
    }

     

    Application Requirements

    • Swap Chain
      • A set of frame buffers sequentially connecting a front buffer and back buffers on which rendering is performed.
      • Frame buffer : a buffer that temporarily stores image information to appear on the screen.
      • Front buffer : the frame buffer that is currently being displayed on the screen.
      • Back buffer : the frame buffer where rendering occurs. (render target)

    The image of explaining the Swap Chain

    • Presentation
      • Transferring the contents of back buffer to front buffer.
      • Types of presentation
        1. Flipping
          • A hardware method of swapping the front buffer and back buffer.
          • Fast because only the memory address is changed.
        2. Blit
          • Copy the back buffer to the front buffer.
          • Used for advanced technologies using post processing.
    • Initialize the application : create a Win32 window to display the results of rendering operation.
    • Device and device context creation : create a swap chain object and the device
    HRESULT D3D11CreateDeviceAndSwapChain(
    	IDXGIAdapter *pAdapter, 
    	D3D_DRIVER_TYPE DriverType, 
    	HMODULE Software,
    	UNIT Flags,
    	const D3D_FEATURE_LEVEL *pFeatureLevels,
    	UINT FeatureLevels,
    	UINT SDKVersion,
    	const DXGI_SWAP_CHAIN_DESC *pSwapChainDesc,
    	IDXGISwapChain **ppSwapChain,
    	ID3D11Device **ppDevice,
    	D3D_FEATURE_LEVEL *pFeatureLevel,
    	ID3D11DeviceContext **ppImmediateContext
    );
    • Resource creation
      • Create resources, shader objects, and state objects to be used in rendering operation.
      • All Direct3D resources should be created at the initialization.
      • All pipeline components should be created in advance.
    • Application loop
      • Message processing : occurs in the specified callback function when creating the application window.
      • Update : change the status of the application.
      • Rendering
        1. Bind render target view and depth-stencil view to the pipeline.
        2. Empty resource view for rendering path. (clear)
        3. Perform practically rendering.
    • Display the results in the window : display the contents of the buffer containing the rendering result in the client area of the window.
    • The process of terminating the application : release the objects or resources created by the application program

    A lifecycle of applications

     

    'CS > 게임 프로그래밍' 카테고리의 다른 글

    The Tessellation Pipeline  (0) 2024.02.12
    The Rendering Pipeline - After Tessellation  (0) 2024.02.05
    The Rendering Pipeline - Before Tessellation  (0) 2024.02.04
    The Rendering Pipeline - Background  (0) 2024.02.04
    Direct3D 11 Resources  (0) 2024.02.02
Designed by Tistory.