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