Skip to content

Commit

Permalink
fix: getOrCreateRenderPipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuki Shimada committed Aug 19, 2023
1 parent 2dc74d1 commit b319037
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/webgpu/WebGpuResourceRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ export class WebGpuResourceRepository
primitive: Primitive,
instanceIDBufferUid: WebGPUResourceHandle = CGAPIResourceRepository.InvalidCGAPIResourceUid
) {
const buffers = [];
const buffers: GPUVertexBufferLayout[] = [];

// Vertex Buffer Settings
/// Each vertex attributes
Expand Down Expand Up @@ -467,17 +467,24 @@ export class WebGpuResourceRepository
new Error('Shader Modules is not found');
}

const attributes: GPUVertexAttribute[] = [];
// const attributes: GPUVertexAttribute[] = [];

const gpuVertexBufferLayouts: GPUVertexBufferLayout[] = [];
primitive.attributeAccessors.forEach((accessor: Accessor, i: number) => {
const slotIdx = VertexAttribute.toAttributeSlotFromJoinedString(
primitive.attributeSemantics[i]
);
attributes.push({
const attribute = {
shaderLocation: slotIdx,
offset: accessor.byteOffsetInBufferView,
offset: accessor.isAoS ? accessor.byteOffsetInBufferView : 0,
format: (accessor.componentType.webgpu +
accessor.compositionType.webgpu) as GPUVertexFormat,
};
// attributes.push(attribute);
gpuVertexBufferLayouts.push({
stepMode: 'vertex',
arrayStride: primitive.attributeAccessors[i].actualByteStride,
attributes: [attribute],
});
});

Expand All @@ -486,15 +493,7 @@ export class WebGpuResourceRepository
vertex: {
module: modules.vsModule,
entryPoint: 'main',
buffers: [
{
// 配列の要素間の距離をバイト単位で指定します。
arrayStride: primitive.attributeAccessors[0].actualByteStride,

// 頂点バッファの属性を指定します。
attributes: attributes,
},
],
buffers: gpuVertexBufferLayouts,
},
fragment: {
module: modules.fsModule,
Expand Down

0 comments on commit b319037

Please sign in to comment.