码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-01-16 23:42:33      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:

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

 

教程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起始位置、跨度、图元绘制方式

 

 

 

 

 

 

 

 

 

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

标签:

原文地址:http://www.cnblogs.com/dust-fly/p/4229902.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!