Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: gpu/command_buffer/service/command_buffer_service.cc

Issue 2150803003: Introduce gpu_fuzzer to fuzz the GPU command buffers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fuzzer_land_base
Patch Set: Fix check, zero-out padding Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 4
5 #include "gpu/command_buffer/service/command_buffer_service.h" 5 #include "gpu/command_buffer/service/command_buffer_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 UpdateState(); 131 UpdateState();
132 } 132 }
133 133
134 void CommandBufferService::SetGetOffset(int32_t get_offset) { 134 void CommandBufferService::SetGetOffset(int32_t get_offset) {
135 DCHECK(get_offset >= 0 && get_offset < num_entries_); 135 DCHECK(get_offset >= 0 && get_offset < num_entries_);
136 get_offset_ = get_offset; 136 get_offset_ = get_offset;
137 } 137 }
138 138
139 scoped_refptr<Buffer> CommandBufferService::CreateTransferBuffer(size_t size, 139 scoped_refptr<Buffer> CommandBufferService::CreateTransferBuffer(size_t size,
140 int32_t* id) { 140 int32_t* id) {
141 *id = -1;
142 static int32_t next_id = 1; 141 static int32_t next_id = 1;
143 *id = next_id++; 142 *id = next_id++;
144 143 auto result = CreateTransferBufferWithId(size, *id);
145 if (!RegisterTransferBuffer(*id, 144 if (!result)
146 base::MakeUnique<MemoryBufferBacking>(size))) {
147 if (error_ == error::kNoError)
148 error_ = gpu::error::kOutOfBounds;
149 *id = -1; 145 *id = -1;
150 return NULL; 146 return result;
151 }
152
153 return GetTransferBuffer(*id);
154 } 147 }
155 148
156 void CommandBufferService::DestroyTransferBuffer(int32_t id) { 149 void CommandBufferService::DestroyTransferBuffer(int32_t id) {
157 transfer_buffer_manager_->DestroyTransferBuffer(id); 150 transfer_buffer_manager_->DestroyTransferBuffer(id);
158 if (id == ring_buffer_id_) { 151 if (id == ring_buffer_id_) {
159 ring_buffer_id_ = -1; 152 ring_buffer_id_ = -1;
160 ring_buffer_ = NULL; 153 ring_buffer_ = NULL;
161 num_entries_ = 0; 154 num_entries_ = 0;
162 get_offset_ = 0; 155 get_offset_ = 0;
163 put_offset_ = 0; 156 put_offset_ = 0;
164 } 157 }
165 } 158 }
166 159
167 scoped_refptr<Buffer> CommandBufferService::GetTransferBuffer(int32_t id) { 160 scoped_refptr<Buffer> CommandBufferService::GetTransferBuffer(int32_t id) {
168 return transfer_buffer_manager_->GetTransferBuffer(id); 161 return transfer_buffer_manager_->GetTransferBuffer(id);
169 } 162 }
170 163
171 bool CommandBufferService::RegisterTransferBuffer( 164 bool CommandBufferService::RegisterTransferBuffer(
172 int32_t id, 165 int32_t id,
173 std::unique_ptr<BufferBacking> buffer) { 166 std::unique_ptr<BufferBacking> buffer) {
174 return transfer_buffer_manager_->RegisterTransferBuffer(id, 167 return transfer_buffer_manager_->RegisterTransferBuffer(id,
175 std::move(buffer)); 168 std::move(buffer));
176 } 169 }
177 170
171 scoped_refptr<Buffer> CommandBufferService::CreateTransferBufferWithId(
172 size_t size,
173 int32_t id) {
174 if (!RegisterTransferBuffer(id,
175 base::MakeUnique<MemoryBufferBacking>(size))) {
176 if (error_ == error::kNoError)
177 error_ = gpu::error::kOutOfBounds;
178 return NULL;
179 }
180
181 return GetTransferBuffer(id);
182 }
183
184
178 void CommandBufferService::SetToken(int32_t token) { 185 void CommandBufferService::SetToken(int32_t token) {
179 token_ = token; 186 token_ = token;
180 UpdateState(); 187 UpdateState();
181 } 188 }
182 189
183 void CommandBufferService::SetParseError(error::Error error) { 190 void CommandBufferService::SetParseError(error::Error error) {
184 if (error_ == error::kNoError) { 191 if (error_ == error::kNoError) {
185 error_ = error; 192 error_ = error;
186 if (!parse_error_callback_.is_null()) 193 if (!parse_error_callback_.is_null())
187 parse_error_callback_.Run(); 194 parse_error_callback_.Run();
(...skipping 18 matching lines...) Expand all
206 const GetBufferChangedCallback& callback) { 213 const GetBufferChangedCallback& callback) {
207 get_buffer_change_callback_ = callback; 214 get_buffer_change_callback_ = callback;
208 } 215 }
209 216
210 void CommandBufferService::SetParseErrorCallback( 217 void CommandBufferService::SetParseErrorCallback(
211 const base::Closure& callback) { 218 const base::Closure& callback) {
212 parse_error_callback_ = callback; 219 parse_error_callback_ = callback;
213 } 220 }
214 221
215 } // namespace gpu 222 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/command_buffer_service.h ('k') | gpu/command_buffer/service/common_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698