Loads the shader files and makes it usable to DirectX and the GPU 加载着色器文件并使其可用于DirectX和GPU

Now we will start with one of the more important functions to this tutorial which is called InitializeShader. This function is what actually loads the shader files and makes it usable to DirectX and the GPU. You will also see the setup of the layout and how the vertex buffer data is going to look on the graphics pipeline in the GPU. The layout will need the match the VertexType in the modelclass.h file as well as the one defined in the color.vs file.

现在我们将从本教程的一个更重要的函数开始,称为InitializeShader。此功能实际上是加载着色器文件并使其可用于DirectX和GPU。您还将看到布局的设置以及顶点缓冲区数据在GPU中的图形管线上的外观。布局将需要匹配modelclass.h文件中的VertexType以及color.vs文件中定义的那个。

bool ColorShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
HRESULT result;
ID3D10Blob* errorMessage;
ID3D10Blob* vertexShaderBuffer;
ID3D10Blob* pixelShaderBuffer;
D3D11_INPUT_ELEMENT_DESC polygonLayout[2];
unsigned int numElements;
D3D11_BUFFER_DESC matrixBufferDesc; // Initialize the pointers this function will use to null.
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;

Compile the shader programs into buffers 将着色器程序编译到缓冲区中

Here is where we compile the shader programs into buffers. We give it the name of the shader file, the name of the shader, the shader version (5.0 in DirectX 11), and the buffer to compile the shader into. If it fails compiling the shader it will put an error message inside the errorMessage string which we send to another function to write out the error. If it still fails and there is no errorMessage string then it means it could not find the shader file in which case we pop up a dialog box saying so.

这是我们将着色器程序编译到缓冲区的地方。我们给它着色器文件的名称,着色器的名称,着色器版本(DirectX 11中的5.0),以及用于编译着色器的缓冲区。如果编译着色器失败,它将在errorMessage字符串中放入一条错误消息,我们将其发送给另一个函数以写出错误。如果它仍然失败并且没有errorMessage字符串,则表示它找不到着色器文件,在这种情况下我们会弹出一个对话框。

	// Compile the vertex shader code. /编译顶点着色器代码。
result = D3DCompileFromFile(vsFilename, NULL, NULL, "ColorVertexShader", "vs_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0,
&vertexShaderBuffer, &errorMessage);
if(FAILED(result))
{
// If the shader failed to compile it should have writen something to the error message. 如果着色器无法编译,它应该写入错误消息。
if(errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
}
// If there was nothing in the error message then it simply could not find the shader file itself. 如果错误消息中没有任何内容,那么它根本找不到着色器文件本身。
else
{
MessageBox(hwnd, vsFilename, L"Missing Shader File", MB_OK);
} return false;
} // Compile the pixel shader code.
result = D3DCompileFromFile(psFilename, NULL, NULL, "ColorPixelShader", "ps_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0,
&pixelShaderBuffer, &errorMessage);
if(FAILED(result))
{
// If the shader failed to compile it should have writen something to the error message.
if(errorMessage)
{
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
}
// If there was nothing in the error message then it simply could not find the file itself.
else
{
MessageBox(hwnd, psFilename, L"Missing Shader File", MB_OK);
} return false;
}

D3DCompileFromFile function D3DCompileFromFile函数

Note You can use this API to develop your Windows Store apps, but you can't use it in apps that you submit to the Windows Store. Refer to the section, "Compiling shaders for UWP", in the remarks for D3DCompile2.

注意您可以使用此API开发Windows应用商店应用,但不能在提交到Windows应用商店的应用中使用它。请参阅D3DCompile2备注中的“为UWP编译着色器”一节。

Compiles Microsoft High Level Shader Language (HLSL) code into bytecode for a given target.

将Microsoft高级着色器语言(HLSL)代码编译为给定目标的字节码。

Syntax


HRESULT D3DCompileFromFile(
LPCWSTR pFileName,
const D3D_SHADER_MACRO *pDefines,
ID3DInclude *pInclude,
LPCSTR pEntrypoint,
LPCSTR pTarget,
UINT Flags1,
UINT Flags2,
ID3DBlob **ppCode,
ID3DBlob **ppErrorMsgs
);

Parameters

pFileName

A pointer to a constant null-terminated string that contains the name of the file that contains the shader code.

指向以null结尾的常量字符串的指针,该字符串包含包含着色器代码的文件的名称。(译注:需要从生成exe文件的位置到待编译文件的相对位置)

pDefines

An optional array of D3D_SHADER_MACRO structures that define shader macros. Each macro definition contains a name and a NULL-terminated definition. If not used, set to NULL.

可选的D3D_SHADER_MACRO结构数组,用于定义着色器宏。每个宏定义都包含一个名称和一个以NULL结尾的定义。如果未使用,则设置为NULL。

pInclude

An optional pointer to an ID3DInclude interface that the compiler uses to handle include files. If you set this parameter to NULL and the shader contains a #include, a compile error occurs. You can pass the D3D_COMPILE_STANDARD_FILE_INCLUDE macro, which is a pointer to a default include handler. This default include handler includes files that are relative to the current directory.

指向编译器用于处理包含文件的ID3DInclude接口的可选指针。如果将此参数设置为NULL并且着色器包含#include,则会发生编译错误。您可以传递D3D_COMPILE_STANDARD_FILE_INCLUDE宏,该宏是指向默认包含处理程序的指针。此默认包含处理程序包含与当前目录相关的文件。

#define D3D_COMPILE_STANDARD_FILE_INCLUDE ((ID3DInclude*)(UINT_PTR)1)

pEntrypoint

A pointer to a constant null-terminated string that contains the name of the shader entry point function where shader execution begins. When you compile an effect, D3DCompileFromFile ignores pEntrypoint; we recommend that you set pEntrypoint to NULL because it is good programming practice to set a pointer parameter to NULL if the called function will not use it.

指向常量以null结尾的字符串的指针,该字符串包含着色器执行开始的着色器入口点函数的名称。编译效果时,D3DCompileFromFile会忽略pEntrypoint;我们建议您将pEntrypoint设置为NULL,因为如果被调用的函数不使用它,那么将指针参数设置为NULL是一种很好的编程习惯。

pTarget

A pointer to a constant null-terminated string that specifies the shader target or set of shader features to compile against. The shader target can be a shader model (for example, shader model 2, shader model 3, shader model 4, or shader model 5 and later). The target can also be an effect type (for example, fx_4_1). For info about the targets that various profiles support, see Specifying Compiler Targets.

指向常量以null结尾的字符串的指针,该字符串指定要编译的着色器目标或着色器要素集。着色器目标可以是着色器模型(例如,着色器模型2,着色器模型3,着色器模型4或着色器模型5及更高版本)。目标也可以是效果类型(例如,fx_4_1)。有关各种配置文件支持的目标的信息,请参阅指定编译器目标。

Flags1

A combination of shader compile options that are combined by using a bitwise OR operation. The resulting value specifies how the compiler compiles the HLSL code.

通过使用按位OR运算组合的着色器编译选项的组合。结果值指定编译器如何编译HLSL代码。

Flags2

A combination of effect compile options that are combined by using a bitwise OR operation. The resulting value specifies how the compiler compiles the effect. When you compile a shader and not an effect file, D3DCompileFromFile ignores Flags2; we recommend that you set Flags2 to zero because it is good programming practice to set a nonpointer parameter to zero if the called function will not use it.

通过使用按位OR运算组合的效果编译选项的组合。结果值指定编译器如何编译效果。编译着色器而不是效果文件时,D3DCompileFromFile会忽略Flags2;我们建议您将Flags2设置为零,因为如果被调用的函数不使用它,那么将非指针参数设置为零是一种很好的编程习惯。

ppCode

A pointer to a variable that receives a pointer to the ID3DBlob interface that you can use to access the compiled code.

指向变量的指针,该变量接收指向可用于访问已编译代码的ID3DBlob接口的指针。

ppErrorMsgs

An optional pointer to a variable that receives a pointer to the ID3DBlob interface that you can use to access compiler error messages, or NULL if there are no errors.

指向变量的可选指针,该变量接收可用于访问编译器错误消息的ID3DBlob接口的指针,如果没有错误,则返回NULL。


Create the shader objects 创建着色器对象

Once the vertex shader and pixel shader code has successfully compiled into buffers we then use those buffers to create the shader objects themselves. We will use these pointers to interface with the vertex and pixel shader from this point forward.

一旦顶点着色器和像素着色器代码成功编译到缓冲区中,我们就可以使用这些缓冲区自己创建着色器对象。从这一点开始,我们将使用这些指针与顶点和像素着色器进行交互。

	// Create the vertex shader from the buffer. 从缓冲区创建顶点着色器。
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
if(FAILED(result))
{
return false;
} // Create the pixel shader from the buffer. 从缓冲区创建像素着色器。
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
if(FAILED(result))
{
return false;
}

ID3D11Device::CreateVertexShader method ID3D11Device :: CreateVertexShader方法

Create a vertex-shader object from a compiled shader.

从已编译的着色器创建顶点着色器对象。

Syntax


HRESULT CreateVertexShader(
const void *pShaderBytecode,
SIZE_T BytecodeLength,
ID3D11ClassLinkage *pClassLinkage,
ID3D11VertexShader **ppVertexShader
);

Parameters

pShaderBytecode

Type: const void*

A pointer to the compiled shader.

指向已编译着色器的指针。

BytecodeLength

Type: SIZE_T

Size of the compiled vertex shader.

已编译顶点着色器的大小。

pClassLinkage

Type: ID3D11ClassLinkage*

A pointer to a class linkage interface (see ID3D11ClassLinkage); the value can be NULL.

指向类链接接口的指针(参见ID3D11ClassLinkage);值可以为NULL。

ppVertexShader

Type: ID3D11VertexShader**

Address of a pointer to a ID3D11VertexShader interface. If this is NULL, all other parameters will be validated, and if all parameters pass validation this API will return S_FALSE instead of S_OK.

指向ID3D11VertexShader接口的指针的地址。如果这是NULL,则将验证所有其他参数,如果所有参数都通过验证,则此API将返回S_FALSE而不是S_OK。

Return Value

Type: HRESULT

This method returns one of the Direct3D 11 Return Codes.

此方法返回Direct3D 11返回代码之一。

Remarks

The Direct3D 11.1 runtime, which is available starting with Windows 8, provides the following new functionality for CreateVertexShader.

Direct3D 11.1运行时(从Windows 8开始提供)为CreateVertexShader提供以下新功能。

The following shader model 5.0 instructions are available to just pixel shaders and compute shaders in the Direct3D 11.0 runtime. For the Direct3D 11.1 runtime, because unordered access views (UAV) are available at all shader stages, you can use these instructions in all shader stages.

以下着色器模型5.0指令仅适用于Direct3D 11.0运行时中的像素着色器和计算着色器。对于Direct3D 11.1运行时,由于无序访问视图(UAV)在所有着色器阶段都可用,因此您可以在所有着色器阶段使用这些指令。

Therefore, if you use the following shader model 5.0 instructions in a vertex shader, you can successfully pass the compiled vertex shader to pShaderBytecode. That is, the call to CreateVertexShader succeeds.

因此,如果在顶点着色器中使用以下着色器模型5.0指令,则可以成功将已编译的顶点着色器传递给pShaderBytecode。也就是说,对CreateVertexShader的调用成功。

If you pass a compiled shader to pShaderBytecode that uses any of the following instructions on a device that doesn’t support UAVs at every shader stage (including existing drivers that are not implemented to support UAVs at every shader stage), CreateVertexShader fails. CreateVertexShader also fails if the shader tries to use a UAV slot beyond the set of UAV slots that the hardware supports.

如果将已编译的着色器传递给pShaderBytecode,该pShaderBytecode在每个着色器阶段不支持UAV的设备上使用以下任何指令(包括未在每个着色器阶段支持UAV的现有驱动程序),CreateVertexShader将失败。如果着色器尝试使用超出硬件支持的UAV插槽集的UAV插槽,CreateVertexShader也会失败。

  • dcl_uav_typed
  • dcl_uav_raw
  • dcl_uav_structured
  • ld_raw
  • ld_structured
  • ld_uav_typed
  • store_raw
  • store_structured
  • store_uav_typed
  • sync_uglobal

All atomics and immediate atomics (for example, atomic_and and imm_atomic_and)

所有原子操作和立即原子操作(?)


Create the layout of the vertex data 创建顶点数据的布局

The next step is to create the layout of the vertex data that will be processed by the shader. As this shader uses a position and color vector we need to create both in the layout specifying the size of both. The semantic name is the first thing to fill out in the layout, this allows the shader to determine the usage of this element of the layout. As we have two different elements we use POSITION for the first one and COLOR for the second. The next important part of the layout is the Format. For the position vector we use DXGI_FORMAT_R32G32B32_FLOAT and for the color we use DXGI_FORMAT_R32G32B32A32_FLOAT. The final thing you need to pay attention to is the AlignedByteOffset which indicates how the data is spaced in the buffer. For this layout we are telling it the first 12 bytes are position and the next 16 bytes will be color, AlignedByteOffset shows where each element begins. You can use D3D11_APPEND_ALIGNED_ELEMENT instead of placing your own values in AlignedByteOffset and it will figure out the spacing for you. The other settings I've made default for now as they are not needed in this tutorial.

步是创建将由着色器处理的顶点数据的布局。由于此着色器使用位置和颜色向量,我们需要在布局中创建指定两者的大小。语义名称是布局中首先填写的内容,这允许着色器确定布局的此元素的用法。由于我们有两个不同的元素,我们使用POSITION作为第一个,COLOR作为第二个。布局的下一个重要部分是格式。对于位置向量,我们使用DXGI_FORMAT_R32G32B32_FLOAT,对于颜色,我们使用DXGI_FORMAT_R32G32B32A32_FLOAT。您需要注意的最后一件事是AlignedByteOffset,它指示数据在缓冲区中的间隔方式。对于这种布局,我们告诉它前12个字节是位置,接下来的16个字节是彩色,AlignedByteOffset显示每个元素开始的位置。你可以使用D3D11_APPEND_ALIGNED_ELEMENT而不是在AlignedByteOffset中放置你自己的值,它会为你找出间距。我现在默认的其他设置,因为本教程不需要它们。

	// Create the vertex input layout description. 创建顶点输入布局描述。
// This setup needs to match the VertexType stucture in the ModelClass and in the shader. 此设置需要匹配ModelClass和着色器中的VertexType结构。
polygonLayout[0].SemanticName = "POSITION";
polygonLayout[0].SemanticIndex = 0;
polygonLayout[0].Format = DXGI_FORMAT_R32G32B32_FLOAT;
polygonLayout[0].InputSlot = 0;
polygonLayout[0].AlignedByteOffset = 0;
polygonLayout[0].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
polygonLayout[0].InstanceDataStepRate = 0; polygonLayout[1].SemanticName = "COLOR";
polygonLayout[1].SemanticIndex = 0;
polygonLayout[1].Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
polygonLayout[1].InputSlot = 0;
polygonLayout[1].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
polygonLayout[1].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
polygonLayout[1].InstanceDataStepRate = 0;

D3D11_INPUT_ELEMENT_DESC structure D3D11_INPUT_ELEMENT_DESC结构

A description of a single element for the input-assembler stage.

汇编程序阶段的单个元素的描述。

Syntax


typedef struct D3D11_INPUT_ELEMENT_DESC {
LPCSTR SemanticName;
UINT SemanticIndex;
DXGI_FORMAT Format;
UINT InputSlot;
UINT AlignedByteOffset;
D3D11_INPUT_CLASSIFICATION InputSlotClass;
UINT InstanceDataStepRate;
} D3D11_INPUT_ELEMENT_DESC;

Members

SemanticName

Type: LPCSTR

The HLSL semantic associated with this element in a shader input-signature.

与着色器输入签名中的此元素关联的HLSL语义。

SemanticIndex

Type: UINT

The semantic index for the element. A semantic index modifies a semantic, with an integer index number. A semantic index is only needed in a case where there is more than one element with the same semantic. For example, a 4x4 matrix would have four components each with the semantic name

元素的语义索引。语义索引使用整数索引号修改语义。只有在存在多个具有相同语义的元素的情况下才需要语义索引。例如,4x4矩阵将具有四个组件,每个组件具有语义名称

matrix

, however each of the four component would have different semantic indices (0, 1, 2, and 3).

但是,四个组件中的每一个都将具有不同的语义索引(0,1,2和3)。

Format

Type: DXGI_FORMAT

The data type of the element data. See DXGI_FORMAT.

元素数据的数据类型。请参阅DXGI_FORMAT。

InputSlot

Type: UINT

An integer value that identifies the input-assembler (see input slot). Valid values are between 0 and 15, defined in D3D11.h.

一个标识输入汇编程序的整数值(请参阅输入槽)。有效值介于0和15之间,在D3D11.h中定义。

AlignedByteOffset

Type: UINT

Optional. Offset (in bytes) between each element. Use D3D11_APPEND_ALIGNED_ELEMENT for convenience to define the current element directly after the previous one, including any packing if necessary.

可选的。每个元素之间的偏移量(以字节为单位)。使用D3D11_APPEND_ALIGNED_ELEMENT以方便直接在前一个元素之后定义当前元素,包括必要时的任何打包。

InputSlotClass

Type: D3D11_INPUT_CLASSIFICATION

Identifies the input data class for a single input slot (see D3D11_INPUT_CLASSIFICATION).

标识单个输入槽的输入数据类(请参阅D3D11_INPUT_CLASSIFICATION)。

InstanceDataStepRate

Type: UINT

The number of instances to draw using the same per-instance data before advancing in the buffer by one element. This value must be 0 for an element that contains per-vertex data (the slot class is set to D3D11_INPUT_PER_VERTEX_DATA).

在缓冲区中前进一个元素之前使用相同的每个实例数据绘制的实例数。对于包含每顶点数据的元素,此值必须为0(槽类设置为D3D11_INPUT_PER_VERTEX_DATA)。


Create Input Layout 创建输入布局

Once the layout description has been setup we can get the size of it and then create the input layout using the D3D device. Also release the vertex and pixel shader buffers since they are no longer needed once the layout has been created.

一旦设置了布局描述,我们就可以获得它的大小,然后使用D3D设备创建输入布局。同时释放顶点和像素着色器缓冲区,因为一旦创建了布局,就不再需要它们了。


// Get a count of the elements in the layout. 获取布局中元素的计数。
numElements = sizeof(polygonLayout) / sizeof(polygonLayout[0]); // Create the vertex input layout. 创建顶点输入布局。
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(),
vertexShaderBuffer->GetBufferSize(), &m_layout);
if(FAILED(result))
{
return false;
} // Release the vertex shader buffer and pixel shader buffer since they are no longer needed. 释放顶点着色器缓冲区和像素着色器缓冲区,因为它们不再需要。
vertexShaderBuffer->Release();
vertexShaderBuffer = 0; pixelShaderBuffer->Release();
pixelShaderBuffer = 0;

ID3D11Device::CreateInputLayout method

Create an input-layout object to describe the input-buffer data for the input-assembler stage.

创建一个输入布局对象来描述输入 - 汇编程序阶段的输入缓冲区数据。

Syntax


HRESULT CreateInputLayout(
const D3D11_INPUT_ELEMENT_DESC *pInputElementDescs,
UINT NumElements,
const void *pShaderBytecodeWithInputSignature,
SIZE_T BytecodeLength,
ID3D11InputLayout **ppInputLayout
);

Parameters

pInputElementDescs

Type: const D3D11_INPUT_ELEMENT_DESC*

An array of the input-assembler stage input data types; each type is described by an element description (see D3D11_INPUT_ELEMENT_DESC).

汇编程序阶段输入数据类型的数组;每种类型都由元素描述描述(参见D3D11_INPUT_ELEMENT_DESC)。

NumElements

Type: UINT

The number of input-data types in the array of input-elements.

输入元素数组中的输入数据类型的数量。

pShaderBytecodeWithInputSignature

Type: const void*

A pointer to the compiled shader. The compiled shader code contains a input signature which is validated against the array of elements. See remarks.

指向已编译着色器的指针。已编译的着色器代码包含一个输入签名,该签名针对元素数组进行验证。

BytecodeLength

Type: SIZE_T

Size of the compiled shader.

已编译着色器的大小。

ppInputLayout

Type: ID3D11InputLayout**

A pointer to the input-layout object created (see ID3D11InputLayout). To validate the other input parameters, set this pointer to be NULL and verify that the method returns S_FALSE.

指向创建的输入布局对象的指针(请参阅ID3D11InputLayout)。要验证其他输入参数,请将此指针设置为NULL并验证该方法是否返回S_FALSE。

constant buffer 常量缓冲区

The final thing that needs to be setup to utilize the shader is the constant buffer. As you saw in the vertex shader we currently have just one constant buffer so we only need to setup one here so we can interface with the shader. The buffer usage needs to be set to dynamic since we will be updating it each frame. The bind flags indicate that this buffer will be a constant buffer. The cpu access flags need to match up with the usage so it is set to D3D11_CPU_ACCESS_WRITE. Once we fill out the description we can then create the constant buffer interface and then use that to access the internal variables in the shader using the function SetShaderParameters.

需要设置以利用着色器的最后一件事是常量缓冲区。正如您在顶点着色器中看到的那样,我们目前只有一个常量缓冲区,所以我们只需要在这里设置一个,这样我们就可以与着色器进行交互。缓冲区使用需要设置为动态,因为我们将每帧更新它。绑定标志表明此缓冲区将是一个常量缓冲区。 cpu访问标志需要与用法匹配,因此它设置为D3D11_CPU_ACCESS_WRITE。一旦我们填写了描述,我们就可以创建常量缓冲区接口,然后使用它来使用函数SetShaderParameters访问着色器中的内部变量。

	// Setup the description of the dynamic matrix constant buffer that is in the vertex shader. 设置顶点着色器中动态矩阵常量缓冲区的描述。
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0; // Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class. 创建常量缓冲区指针,以便我们可以从此类中访问顶点着色器常量缓冲区。
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
if(FAILED(result))
{
return false;
} return true;
}

ID3D11Device::CreateInputLayout method ID3D11Device :: CreateInputLayout方法

Create an input-layout object to describe the input-buffer data for the input-assembler stage.

创建一个输入布局对象来描述输入 - 汇编程序阶段的输入缓冲区数据。

Syntax

C++

HRESULT CreateInputLayout(

const D3D11_INPUT_ELEMENT_DESC *pInputElementDescs,

UINT NumElements,

const void *pShaderBytecodeWithInputSignature,

SIZE_T BytecodeLength,

ID3D11InputLayout **ppInputLayout

);

Parameters

pInputElementDescs

Type: const D3D11_INPUT_ELEMENT_DESC*

An array of the input-assembler stage input data types; each type is described by an element description (see D3D11_INPUT_ELEMENT_DESC).

汇编程序阶段输入数据类型的数组;每种类型都由元素描述描述(参见D3D11_INPUT_ELEMENT_DESC)。

NumElements

Type: UINT

The number of input-data types in the array of input-elements.

输入元素数组中的输入数据类型的数量。

pShaderBytecodeWithInputSignature

Type: const void*

A pointer to the compiled shader. The compiled shader code contains a input signature which is validated against the array of elements. See remarks.

指向已编译着色器的指针。已编译的着色器代码包含一个输入签名,该签名针对元素数组进行验证。

BytecodeLength

Type: SIZE_T

Size of the compiled shader.

已编译着色器的大小。

ppInputLayout

Type: ID3D11InputLayout**

A pointer to the input-layout object created (see ID3D11InputLayout). To validate the other input parameters, set this pointer to be NULL and verify that the method returns S_FALSE.

指向创建的输入布局对象的指针(请参阅ID3D11InputLayout)。要验证其他输入参数,请将此指针设置为NULL并验证该方法是否返回S_FALSE。

Initialize the shader 初始化着色器的更多相关文章

  1. WebGL 创建和初始化着色器过程

    1.编译GLSL ES代码,创建和初始化着色器供WebGL使用.这些过程一般分为7个步骤: 创建着色器对象(gl.createBuffer()); 向着色器对象中填充着色器程序的源代码(gl.shad ...

  2. 着色器(Shader)

    着色器(Shader) 顶点着色器(Vertex shader) 片段着色器(Fragment shader) 几何着色器(Geometry Shader) 提供通用计算能力的着色器(Compute ...

  3. GLSL-几何着色器详解跟实例(GS:Geometry Shader)[转]

    [OpenGL4.0]GLSL-几何着色器详解和实例(GS:Geometry Shader) 一.什么是几何着色器(GS:Geometry Shader) Input Assembler(IA)从顶点 ...

  4. (译)Minimal Shader(最小的着色器)

    (原文:https://en.wikibooks.org/wiki/Cg_Programming/Unity/Minimal_Shader) This tutorial covers the basi ...

  5. 【Android 应用开发】OpenGL ES 2.0 -- 制作 3D 彩色旋转三角形 - 顶点着色器 片元着色器 使用详解

    最近开始关注OpenGL ES 2.0 这是真正意义上的理解的第一个3D程序 , 从零开始学习 . 案例下载地址 : http://download.csdn.net/detail/han120201 ...

  6. 着色器语言 GLSL (opengl-shader-language)入门大全

    基本类型: 类型 说明 void 空类型,即不返回任何值 bool 布尔类型 true,false int 带符号的整数 signed integer float 带符号的浮点数 floating s ...

  7. WebGL编程指南案例解析之多数据存储于一个缓冲区以及着色器通信

    //顶点着色器往片元着色器传值 //多个参数值存于一个缓冲对象中 var vShader = ` attribute vec4 a_Position; attribute float a_PointS ...

  8. OpenGL ES 2.0 -- 制作 3D 彩色旋转三角形 - 顶点着色器 片元着色器 使用详解

    最近开始关注OpenGL ES 2.0 这是真正意义上的理解的第一个3D程序 , 从零开始学习 . 案例下载地址 : http://download.csdn.net/detail/han120201 ...

  9. WebGL简易教程(二):向着色器传输数据

    目录 1. 概述 2. 示例:绘制一个点(改进版) 1) attribute变量 2) uniform变量 3) varying变量 3. 结果 4. 参考 1. 概述 在上一篇教程<WebGL ...

随机推荐

  1. 【洛谷P1090 合并果子】

    题目描述 在一个果园里,多多已经将所有的果子打了下来,而且按果子的不同种类分成了不同的堆.多多决定把所有的果子合成一堆. 每一次合并,多多可以把两堆果子合并到一起,消耗的体力等于两堆果子的重量之和.可 ...

  2. Jenkins安装后无法安装插件

    处理方法 Jenkins -- 管理插件 -- 高级 -- 升级站点 将URL 中的https 改为 http

  3. 如何在Linux中使用命令行卸载软件

    您可以使用“dpkg”命令来查看您的计算机,按“Ctrl + Alt + T”的所有已安装包的列表,打开一个终端窗口. 在提示符下键入以下命令,然后按Enter键.dpkg -- list 要卸载程序 ...

  4. 浅谈Kubernetes生产架构

    注意本文,只是笔者针对Kubernetes生产环境运行的一些关于架构设计和实现方案的总结,内容很粗糙,同时也会不断完善. 首先,我们来梳理下Kubernetes生产架构,其设计适用于绝大多数环境.如下 ...

  5. python全栈开发中级班全程笔记(第二模块、第四章)(常用模块导入)

    python全栈开发笔记第二模块 第四章 :常用模块(第二部分)     一.os 模块的 详解 1.os.getcwd()    :得到当前工作目录,即当前python解释器所在目录路径 impor ...

  6. Java基础--面向对象编程3(继承)

    1.继承的作用 为了提取两个类中公共的代码,可以使用继承抽取重复性的代码到一个公共类中. 这个公共的类称为父类(super class),继承于父类的类称为子类(sub class). 2.java继 ...

  7. Cmake出现CMake Error: Could not find CMAKE_ROOT !!!

    试了很多方式, 其实只需要这一句话!!!!!! hash -r

  8. grep sed awk 3个Linux中对文件内容操作的命令

    在学习Linux命令中,发现3个有关于文件内容操作的命令grep,sed和awk,在这里简单汇总这3个命令主要作用,在实际中找到最合适的情景应用,详细用法可以参考其他文章. 1.grep命令 主要作用 ...

  9. 转 原生js canvas实现苹果电脑mac OS窗口最小化效果

    http://www.17sucai.com/pins/demo-show?id=2459 http://www.17sucai.com/pins/demo-show?id=2458  很多资料 ,前 ...

  10. 切换npm源地址

    全局安装nrm (npm源管理工具) npm install -g nrm 查看所有的源地址   * 代表当前的源地址 nrm ls * npm ----- https://registry.npmj ...