OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 unsigned int max_vertices = UINT_MAX; | 199 unsigned int max_vertices = UINT_MAX; |
200 for (unsigned int i = 0; i < streams_.size(); ++i) { | 200 for (unsigned int i = 0; i < streams_.size(); ++i) { |
201 const StreamPair &pair = streams_[i]; | 201 const StreamPair &pair = streams_[i]; |
202 VertexBufferD3D9 *vertex_buffer = gapi->GetVertexBuffer(pair.first); | 202 VertexBufferD3D9 *vertex_buffer = gapi->GetVertexBuffer(pair.first); |
203 if (!vertex_buffer) { | 203 if (!vertex_buffer) { |
204 max_vertices = 0; | 204 max_vertices = 0; |
205 continue; | 205 continue; |
206 } | 206 } |
207 HR(d3d_device->SetStreamSource(i, vertex_buffer->d3d_vertex_buffer(), 0, | 207 HR(d3d_device->SetStreamSource(i, vertex_buffer->d3d_vertex_buffer(), 0, |
208 pair.second)); | 208 pair.second)); |
209 max_vertices = std::min(max_vertices, vertex_buffer->size()/pair.second); | 209 |
| 210 // TODO(apatrick): A zero size stride is valid. It means the first element |
| 211 // in the vertex buffer will be used for every vertex. There doesn't seem |
| 212 // to be enough information here to determine whether a zero stride |
| 213 // vertex buffer is big enough to contain a single element. |
| 214 if (pair.second != 0) { |
| 215 max_vertices = std::min(max_vertices, |
| 216 vertex_buffer->size() / pair.second); |
| 217 } |
210 } | 218 } |
211 return max_vertices; | 219 return max_vertices; |
212 } | 220 } |
213 | 221 |
214 // Converts a vertex_struct::Type to a D3DDECLTYPE. | 222 // Converts a vertex_struct::Type to a D3DDECLTYPE. |
215 static D3DDECLTYPE D3DType(vertex_struct::Type type) { | 223 static D3DDECLTYPE D3DType(vertex_struct::Type type) { |
216 switch (type) { | 224 switch (type) { |
217 case vertex_struct::FLOAT1: | 225 case vertex_struct::FLOAT1: |
218 return D3DDECLTYPE_FLOAT1; | 226 return D3DDECLTYPE_FLOAT1; |
219 case vertex_struct::FLOAT2: | 227 case vertex_struct::FLOAT2: |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 VertexStructD3D9 *vertex_struct = vertex_structs_.Get(vertex_struct_id); | 427 VertexStructD3D9 *vertex_struct = vertex_structs_.Get(vertex_struct_id); |
420 if (!vertex_struct || input_index >= vertex_struct->count()) | 428 if (!vertex_struct || input_index >= vertex_struct->count()) |
421 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 429 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; |
422 vertex_struct->SetInput(input_index, vertex_buffer_id, offset, stride, type, | 430 vertex_struct->SetInput(input_index, vertex_buffer_id, offset, stride, type, |
423 semantic, semantic_index); | 431 semantic, semantic_index); |
424 return BufferSyncInterface::PARSE_NO_ERROR; | 432 return BufferSyncInterface::PARSE_NO_ERROR; |
425 } | 433 } |
426 | 434 |
427 } // namespace command_buffer | 435 } // namespace command_buffer |
428 } // namespace o3d | 436 } // namespace o3d |
OLD | NEW |