|
@@ -78,13 +78,11 @@ public:
|
78
|
78
|
DKArray<uint32_t> indexData = { 0, 1, 2, 2, 3, 0 };
|
79
|
79
|
uint32_t indexBufferSize = indexData.Count() * sizeof(uint32_t);
|
80
|
80
|
|
81
|
|
- DKObject<DKGpuBuffer> vertexBuffer = device->CreateBuffer(vertexBufferSize, DKGpuBuffer::StorageModeShared, DKCpuCacheModeDefault);
|
82
|
|
- memcpy(vertexBuffer->Lock(), vertexData, vertexBufferSize);
|
83
|
|
- vertexBuffer->Unlock();
|
|
81
|
+ DKObject<DKGpuBuffer> vertexBuffer = device->CreateBuffer(vertexBufferSize, DKGpuBuffer::StorageModeShared, DKCpuCacheModeReadWrite);
|
|
82
|
+ memcpy(vertexBuffer->Contents(), vertexData, vertexBufferSize);
|
84
|
83
|
|
85
|
|
- DKObject<DKGpuBuffer> indexBuffer = device->CreateBuffer(indexBufferSize, DKGpuBuffer::StorageModeShared, DKCpuCacheModeDefault);
|
86
|
|
- memcpy(indexBuffer->Lock(), indexData, indexBufferSize);
|
87
|
|
- indexBuffer->Unlock();
|
|
84
|
+ DKObject<DKGpuBuffer> indexBuffer = device->CreateBuffer(indexBufferSize, DKGpuBuffer::StorageModeShared, DKCpuCacheModeReadWrite);
|
|
85
|
+ memcpy(indexBuffer->Contents(), indexData, indexBufferSize);
|
88
|
86
|
|
89
|
87
|
DKRenderPipelineDescriptor pipelineDescriptor;
|
90
|
88
|
pipelineDescriptor.vertexFunction = vertShaderFunction;
|
|
@@ -135,25 +133,15 @@ public:
|
135
|
133
|
DKMatrix4 viewMatrix;
|
136
|
134
|
} ubo;
|
137
|
135
|
|
138
|
|
- DKObject<DKGpuBuffer> uboBuffer = device->CreateBuffer(sizeof(ubo), DKGpuBuffer::StorageModeShared, DKCpuCacheModeDefault);
|
|
136
|
+ DKObject<DKGpuBuffer> uboBuffer = device->CreateBuffer(sizeof(ubo), DKGpuBuffer::StorageModeShared, DKCpuCacheModeReadWrite);
|
139
|
137
|
if (uboBuffer)
|
140
|
138
|
{
|
141
|
139
|
ubo.projectionMatrix = DKMatrix4::identity;
|
142
|
140
|
ubo.modelMatrix = DKMatrix4::identity;
|
143
|
141
|
ubo.viewMatrix = DKMatrix4::identity;
|
144
|
142
|
|
145
|
|
- void* p = uboBuffer->Lock(0);
|
146
|
|
- if (p)
|
147
|
|
- {
|
148
|
|
- memcpy(p, &ubo, sizeof(ubo));
|
149
|
|
- uboBuffer->Unlock();
|
150
|
|
-
|
151
|
|
- bindSet->SetBuffer(0, uboBuffer, 0, sizeof(ubo));
|
152
|
|
- }
|
153
|
|
- else
|
154
|
|
- {
|
155
|
|
- DKLogE("GpuBuffer Lock failed!");
|
156
|
|
- }
|
|
143
|
+ memcpy(uboBuffer->Contents(), &ubo, sizeof(ubo));
|
|
144
|
+ bindSet->SetBuffer(0, uboBuffer, 0, sizeof(ubo));
|
157
|
145
|
}
|
158
|
146
|
}
|
159
|
147
|
|