Sitelet https://github.com/gpuweb/gpuweb/pull/1307/files
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 29 additions & 26 deletions samples/hello-cube.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,47 +123,48 @@
verticesWriteArray.set(verticesArray);
verticesBuffer.unmap();

// Bind group binding layout
const transformBufferBindGroupLayoutEntry = {
binding: transformBindingNum, // id[[(0)]]
visibility: GPUShaderStageBit.VERTEX,
type: "uniform-buffer"
};

const bindGroupLayoutDescriptor = { entries: [transformBufferBindGroupLayoutEntry] };
bindGroupLayout = device.createBindGroupLayout(bindGroupLayoutDescriptor);

const pipelineLayoutDescriptor = { bindGroupLayouts: [bindGroupLayout] };
const pipelineLayout = device.createPipelineLayout(pipelineLayoutDescriptor);

// Vertex Input
const positionAttributeDescriptor = {
const positionAttribute = {
shaderLocation: positionAttributeNum, // [[attribute(0)]]
offset: 0,
format: "float4"
};
const colorAttributeDescriptor = {
const colorAttribute = {
shaderLocation: colorAttributeNum,
offset: colorOffset,
format: "float4"
}
const vertexBufferDescriptor = {
attributeSet: [positionAttributeDescriptor, colorAttributeDescriptor],
const vertexBufferLayout = {
attributeSet: [positionAttributeDescriptor, colorAttribute],
stride: vertexSize,
stepMode: "vertex"
};
const vertexInputDescriptor = { vertexBuffers: [vertexBufferDescriptor] };

// Bind group binding layout
const transformBufferBindGroupLayoutEntry = {
binding: transformBindingNum, // id[[(0)]]
visibility: GPUShaderStageBit.VERTEX,
type: "uniform-buffer"
};

const bindGroupLayoutDescriptor = { entries: [transformBufferBindGroupLayoutEntry] };
bindGroupLayout = device.createBindGroupLayout(bindGroupLayoutDescriptor);
const vertexInputState = { vertexBuffers: [vertexBufferLayout] };

// Pipeline
const depthStateDescriptor = {
const depthState = {
depthWriteEnabled: true,
depthCompare: "less"
};

const pipelineLayoutDescriptor = { bindGroupLayouts: [bindGroupLayout] };
const pipelineLayout = device.createPipelineLayout(pipelineLayoutDescriptor);
const vertexStageDescriptor = {
const vertexStage = {
module: shaderModule,
entryPoint: "vertex_main"
};
const fragmentStageDescriptor = {
const fragmentStage = {
module: shaderModule,
entryPoint: "fragment_main"
};
Expand All @@ -183,16 +184,18 @@
},
writeMask: GPUColorWriteBits.ALL
};
const colorWriteState = {
outputs: [colorState]
};
const pipelineDescriptor = {
layout: pipelineLayout,

vertexStage: vertexStageDescriptor,
fragmentStage: fragmentStageDescriptor,
vertexStage: vertexStage,
fragmentStage: fragmentStage,

primitiveTopology: "triangle-list",
colorStates: [colorState],
depthStencilState: depthStateDescriptor,
vertexInput: vertexInputDescriptor
vertexInput: vertexInputState
depthStencilState: depthState,
colorWrite: colorWriteState,
};
pipeline = device.createRenderPipeline(pipelineDescriptor);

Expand Down
Loading