diff options
author | David Neto <dneto@google.com> | 2019-07-31 17:44:20 -0400 |
---|---|---|
committer | Sarah <9856269+sarahM0@users.noreply.github.com> | 2019-07-31 17:44:20 -0400 |
commit | eb58137b5951a032596e3ac43f9772264211fecb (patch) | |
tree | 9c5899e3fd9ca4acbd678f103cc36ce8eea7adbe | |
parent | cc67e6a2ee90bd3faa73ab1791e8e56011e808d8 (diff) | |
download | amber-eb58137b5951a032596e3ac43f9772264211fecb.tar.gz |
Avoid uninitialized-var warning (#610)
-rw-r--r-- | src/dawn/engine_dawn.cc | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/dawn/engine_dawn.cc b/src/dawn/engine_dawn.cc index 46699c1..e0d332b 100644 --- a/src/dawn/engine_dawn.cc +++ b/src/dawn/engine_dawn.cc @@ -1260,26 +1260,25 @@ Result EngineDawn::DoPatchParameterVertices( Result EngineDawn::DoBuffer(const BufferCommand* command) { Result result; - ::dawn::Buffer* dawn_buffer; + ::dawn::Buffer* dawn_buffer = nullptr; + + const auto descriptor_set = command->GetDescriptorSet(); + const auto binding = command->GetBinding(); RenderPipelineInfo* render_pipeline = GetRenderPipeline(command); if (render_pipeline) { - if (render_pipeline->buffer_map.find( - {command->GetDescriptorSet(), command->GetBinding()}) != - render_pipeline->buffer_map.end()) { - auto dawn_buffer_index = render_pipeline->buffer_map[{ - command->GetDescriptorSet(), command->GetBinding()}]; + auto where = render_pipeline->buffer_map.find({descriptor_set, binding}); + if (where != render_pipeline->buffer_map.end()) { + const auto dawn_buffer_index = where->second; dawn_buffer = &render_pipeline->buffers[dawn_buffer_index]; } } ComputePipelineInfo* compute_pipeline = GetComputePipeline(command); if (compute_pipeline) { - if (compute_pipeline->buffer_map.find( - {command->GetDescriptorSet(), command->GetBinding()}) != - compute_pipeline->buffer_map.end()) { - auto dawn_buffer_index = compute_pipeline->buffer_map[{ - command->GetDescriptorSet(), command->GetBinding()}]; + auto where = compute_pipeline->buffer_map.find({descriptor_set, binding}); + if (where != compute_pipeline->buffer_map.end()) { + const auto dawn_buffer_index = where->second; dawn_buffer = &compute_pipeline->buffers[dawn_buffer_index]; } } @@ -1288,6 +1287,11 @@ Result EngineDawn::DoBuffer(const BufferCommand* command) { return Result("DoBuffer: invoked on invalid or missing pipeline"); if (!command->IsSSBO() && !command->IsUniform()) return Result("DoBuffer: only supports SSBO and uniform buffer type"); + if (!dawn_buffer) { + return Result("DoBuffer: no Dawn buffer at descriptor set " + + std::to_string(descriptor_set) + " and binding " + + std::to_string(binding)); + } Buffer* amber_buffer = command->GetBuffer(); if (amber_buffer) { |