OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrVkUniformBuffer.h" | 8 #include "GrVkUniformBuffer.h" |
9 #include "GrVkGpu.h" | 9 #include "GrVkGpu.h" |
10 | 10 |
11 | 11 |
12 GrVkUniformBuffer* GrVkUniformBuffer::Create(GrVkGpu* gpu, size_t size, bool dyn
amic) { | 12 GrVkUniformBuffer* GrVkUniformBuffer::Create(GrVkGpu* gpu, size_t size, bool dyn
amic) { |
13 if (0 == size) { | 13 if (0 == size) { |
14 return nullptr; | 14 return nullptr; |
15 } | 15 } |
16 GrVkBuffer::Desc desc; | 16 GrVkBuffer::Desc desc; |
17 desc.fDynamic = dynamic; | 17 desc.fAccessPattern = dynamic ? kDynamic_GrAccessPattern : kStatic_GrAccessP
attern; |
18 desc.fType = GrVkBuffer::kUniform_Type; | 18 desc.fType = kUniform_GrBufferType; |
19 desc.fSizeInBytes = size; | 19 desc.fSizeInBytes = size; |
20 | 20 |
21 const GrVkBuffer::Resource* bufferResource = GrVkBuffer::Create(gpu, desc); | 21 const GrVkBuffer::Resource* bufferResource = GrVkBuffer::Create(gpu, desc); |
22 if (!bufferResource) { | 22 if (!bufferResource) { |
23 return nullptr; | 23 return nullptr; |
24 } | 24 } |
25 | 25 |
26 GrVkUniformBuffer* buffer = new GrVkUniformBuffer(desc, bufferResource); | 26 GrVkUniformBuffer* buffer = new GrVkUniformBuffer(gpu, desc, bufferResource)
; |
27 if (!buffer) { | 27 if (!buffer) { |
28 bufferResource->unref(gpu); | 28 bufferResource->unref(gpu); |
29 } | 29 } |
30 return buffer; | 30 return buffer; |
31 } | 31 } |
OLD | NEW |