| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 #include <stddef.h> | 4 #include <stddef.h> |
| 5 #include <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 attrib_helper.depth_size = 0; | 107 attrib_helper.depth_size = 0; |
| 108 attrib_helper.stencil_size = 0; | 108 attrib_helper.stencil_size = 0; |
| 109 attrib_helper.context_type = gles2::CONTEXT_TYPE_OPENGLES3; | 109 attrib_helper.context_type = gles2::CONTEXT_TYPE_OPENGLES3; |
| 110 | 110 |
| 111 bool result = | 111 bool result = |
| 112 decoder_->Initialize(surface_.get(), context_.get(), true, | 112 decoder_->Initialize(surface_.get(), context_.get(), true, |
| 113 gles2::DisallowedFeatures(), attrib_helper); | 113 gles2::DisallowedFeatures(), attrib_helper); |
| 114 CHECK(result); | 114 CHECK(result); |
| 115 decoder_->set_max_bucket_size(8 << 20); | 115 decoder_->set_max_bucket_size(8 << 20); |
| 116 context_group->buffer_manager()->set_max_buffer_size(8 << 20); | 116 context_group->buffer_manager()->set_max_buffer_size(8 << 20); |
| 117 if (!vertex_translator_) { |
| 118 // Keep a reference to the translators, which keeps them in the cache even |
| 119 // after the decoder is reset. They are expensive to initialize, but they |
| 120 // don't keep state. |
| 121 vertex_translator_ = decoder_->GetTranslator(GL_VERTEX_SHADER); |
| 122 fragment_translator_ = decoder_->GetTranslator(GL_FRAGMENT_SHADER); |
| 123 } |
| 117 } | 124 } |
| 118 | 125 |
| 119 void ResetDecoder() { | 126 void ResetDecoder() { |
| 120 decoder_->Destroy(true); | 127 decoder_->Destroy(true); |
| 121 decoder_.reset(); | 128 decoder_.reset(); |
| 122 command_buffer_.reset(); | 129 command_buffer_.reset(); |
| 123 } | 130 } |
| 124 | 131 |
| 125 ~CommandBufferSetup() { | 132 ~CommandBufferSetup() { |
| 126 sync_point_client_ = nullptr; | 133 sync_point_client_ = nullptr; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 const gpu::CommandBufferId command_buffer_id_; | 224 const gpu::CommandBufferId command_buffer_id_; |
| 218 | 225 |
| 219 scoped_refptr<gles2::ShaderTranslatorCache> translator_cache_; | 226 scoped_refptr<gles2::ShaderTranslatorCache> translator_cache_; |
| 220 scoped_refptr<gles2::FramebufferCompletenessCache> completeness_cache_; | 227 scoped_refptr<gles2::FramebufferCompletenessCache> completeness_cache_; |
| 221 | 228 |
| 222 std::unique_ptr<CommandBufferService> command_buffer_; | 229 std::unique_ptr<CommandBufferService> command_buffer_; |
| 223 | 230 |
| 224 std::unique_ptr<gles2::GLES2Decoder> decoder_; | 231 std::unique_ptr<gles2::GLES2Decoder> decoder_; |
| 225 std::unique_ptr<CommandExecutor> executor_; | 232 std::unique_ptr<CommandExecutor> executor_; |
| 226 | 233 |
| 234 scoped_refptr<gles2::ShaderTranslatorInterface> vertex_translator_; |
| 235 scoped_refptr<gles2::ShaderTranslatorInterface> fragment_translator_; |
| 236 |
| 227 scoped_refptr<Buffer> buffer_; | 237 scoped_refptr<Buffer> buffer_; |
| 228 int32_t buffer_id_ = 0; | 238 int32_t buffer_id_ = 0; |
| 229 }; | 239 }; |
| 230 | 240 |
| 231 } // anonymous namespace | 241 } // anonymous namespace |
| 232 } // namespace gpu | 242 } // namespace gpu |
| 233 | 243 |
| 234 | 244 |
| 235 static gpu::CommandBufferSetup& GetSetup() { | 245 static gpu::CommandBufferSetup& GetSetup() { |
| 236 static gpu::CommandBufferSetup setup; | 246 static gpu::CommandBufferSetup setup; |
| 237 return setup; | 247 return setup; |
| 238 } | 248 } |
| 239 | 249 |
| 240 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | 250 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
| 241 GetSetup().RunCommandBuffer(data, size); | 251 GetSetup().RunCommandBuffer(data, size); |
| 242 return 0; | 252 return 0; |
| 243 } | 253 } |
| OLD | NEW |