• dx11 入门 Tutorial 02: 数据传入GPU的设置 和绘制一个三角形 DirectXSampleBrowser(June 2010)


      烦...一年前看过教程,但全忘掉了,这一年我都干什么了、、、

    教程2遇到的两个error:

    error 1:ID3DBlob调用不成功 ,是重复调用版本冲突的原因?ID3DBlob在D3DCommon.h中, 因为window include里和SDK里各有一份,造成了冲突,修改头文件的调用,先调用SDK内的即可。参考:http://www.cnblogs.com/Wilson-Loo/archive/2013/01/20/2797902.html 那为什么先后顺序就解决问题呢》

    error 2:FXC : error X3501: 'main': entrypoint not found   项目属性里shader的设置问题... 参考http://stackoverflow.com/questions/20363360/fxc-error-x3501-main-entrypoint-not-found

    这一讲主要是拷贝数据到GPU中,并设置数据属性,告知GPU。

    笔记1:That takes care of storing vertex information in system memory in our application. However, when we feed the
    GPU the vertex buffer containing our vertices, we are just feeding it a chunk of memory. The GPU must also know
    about the vertex layout in order to extract correct attributes out from the buffer. To accomplish this requires
    the use of an input layout.

    意思:设置vertex的struct,存储vertex的信息后在vertexBuffer内,但当我们向GPU填充vertexBuffer内的数据时,GPU不知道这块数据干嘛用的,怎么用,为了告诉GPU数据正确属性,我们使用input layout

    // Define the input layout
    D3D11_INPUT_ELEMENT_DESC layout[] =
    {
        { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },  
    };
    UINT numElements = ARRAYSIZE(layout);
    

    如上,告知GPU,input到vertexShader里数据块格式为12Byte,

    vertex Layout创建前提是:我得有vertexShader,告诉device我需要layout才行;所以ID3DBlob指向编译后shader的二进制地址,然后ID3DBlob和相应的device、context绑定这个inputLayout,。

    总结:总体流程:

    1.编译fx   VS和PS

    2.设置InputLayout的参数,用于input到GPU

    3.device、context分别创建和设置vertexLayout,并和相应的编译后的vertexShader绑定(ID3DBlob),

    4.device创建vertexBuffer,

        context设置相应的buffer起始位置、跨度、图元绘制方式,即render时,告诉gpu拷贝哪一段buffer,怎么拷贝。

    记住:layout的设置告诉cpu数据的使用方式

            vertexBuffer的创建设置(起始位置、跨度)告诉拷贝给gpu实际的数据

     

  • 相关阅读:
    Mithril – 构建杰出 Web 应用的 JS MVC 框架
    构建 iOS 风格移动 Web 应用程序的8款开发框架
    优秀设计:纹理在网页设计中的20个应用示例
    HTML5 Dashboard – 那些让你激动的 Web 技术
    免费下载!10套流行的扁平化界面设计素材
    另类网页设计:30个复古怀旧风格的网站作品
    2014年3月新鲜出炉的最佳 JavaScript 工具库
    25个最佳的 WordPress Gallery 画廊插件
    Gremlins.js – 模拟用户随机操作的 JS 测试库
    15款提高工作效率的 Web 项目管理工具
  • 原文地址:https://www.cnblogs.com/dust-fly/p/4229902.html
Copyright © 2020-2023  润新知