23 #include "base/integral_types.h"
52 gm->GetIntegerv(GL_MAX_VERTEX_ATTRIBS, &attrib_count);
54 info->attributes.resize(attrib_count);
55 GLint boolean_value = GL_FALSE;
56 for (GLint i = 0; i < attrib_count; ++i) {
57 gm->GetVertexAttribiv(
58 static_cast<GLuint>(i), GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING,
59 reinterpret_cast<GLint*>(&info->attributes[i].buffer));
60 gm->GetVertexAttribiv(
61 static_cast<GLuint>(i), GL_VERTEX_ATTRIB_ARRAY_ENABLED, &boolean_value);
62 info->attributes[i].enabled =
static_cast<GLboolean
>(boolean_value);
63 gm->GetVertexAttribiv(
64 static_cast<GLuint>(i), GL_VERTEX_ATTRIB_ARRAY_SIZE,
65 reinterpret_cast<GLint*>(&info->attributes[i].size));
66 gm->GetVertexAttribiv(
67 static_cast<GLuint>(i), GL_VERTEX_ATTRIB_ARRAY_STRIDE,
68 reinterpret_cast<GLint*>(&info->attributes[i].stride));
69 gm->GetVertexAttribiv(
70 static_cast<GLuint>(i), GL_VERTEX_ATTRIB_ARRAY_TYPE,
71 reinterpret_cast<GLint*>(&info->attributes[i].type));
72 gm->GetVertexAttribiv(
73 static_cast<GLuint>(i), GL_VERTEX_ATTRIB_ARRAY_NORMALIZED,
75 info->attributes[i].normalized =
static_cast<GLboolean
>(boolean_value);
76 gm->GetVertexAttribfv(
77 static_cast<GLuint>(i), GL_CURRENT_VERTEX_ATTRIB,
78 &info->attributes[i].value[0]);
79 gm->GetVertexAttribPointerv(
80 static_cast<GLuint>(i), GL_VERTEX_ATTRIB_ARRAY_POINTER,
81 &info->attributes[i].pointer);
83 gm->GetVertexAttribiv(
84 static_cast<GLuint>(i), GL_VERTEX_ATTRIB_ARRAY_DIVISOR,
85 reinterpret_cast<GLint*>(&info->attributes[i].divisor));
102 gm->GetBufferParameteriv(info->target, GL_BUFFER_SIZE, &size);
104 gm->GetBufferParameteriv(
105 info->target, GL_BUFFER_USAGE, reinterpret_cast<GLint*>(&info->usage));
108 gm->GetBufferPointerv(info->target, GL_BUFFER_MAP_POINTER, &data);
109 info->mapped_data = data;
120 static void FillFramebufferAttachmentInfo(
122 ResourceManager::FramebufferInfo::Attachment* info,
125 gm->GetFramebufferAttachmentParameteriv(
126 GL_FRAMEBUFFER, attachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
127 reinterpret_cast<GLint*>(&info->type));
132 if ((info->type == GL_RENDERBUFFER) && (rb_info->id == 0U)) {
133 info->type = GL_NONE;
136 if (info->type != GL_NONE)
137 gm->GetFramebufferAttachmentParameteriv(
138 GL_FRAMEBUFFER, attachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
139 reinterpret_cast<GLint*>(&info->value));
140 if (info->type == GL_TEXTURE) {
141 gm->GetFramebufferAttachmentParameteriv(
142 GL_FRAMEBUFFER, attachment, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL,
143 reinterpret_cast<GLint*>(&info->level));
144 gm->GetFramebufferAttachmentParameteriv(
145 GL_FRAMEBUFFER, attachment,
146 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE,
147 reinterpret_cast<GLint*>(&info->cube_face));
151 if (info->type == GL_RENDERBUFFER) {
152 gm->BindRenderbuffer(GL_RENDERBUFFER, rb_info->id);
153 gm->GetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH,
154 reinterpret_cast<GLint*>(&rb_info->width));
155 gm->GetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT,
156 reinterpret_cast<GLint*>(&rb_info->height));
157 gm->GetRenderbufferParameteriv(
158 GL_RENDERBUFFER, GL_RENDERBUFFER_INTERNAL_FORMAT,
159 reinterpret_cast<GLint*>(&rb_info->internal_format));
160 gm->GetRenderbufferParameteriv(
161 GL_RENDERBUFFER, GL_RENDERBUFFER_RED_SIZE,
162 reinterpret_cast<GLint*>(&rb_info->red_size));
163 gm->GetRenderbufferParameteriv(
164 GL_RENDERBUFFER, GL_RENDERBUFFER_GREEN_SIZE,
165 reinterpret_cast<GLint*>(&rb_info->green_size));
166 gm->GetRenderbufferParameteriv(
167 GL_RENDERBUFFER, GL_RENDERBUFFER_BLUE_SIZE,
168 reinterpret_cast<GLint*>(&rb_info->blue_size));
169 gm->GetRenderbufferParameteriv(
170 GL_RENDERBUFFER, GL_RENDERBUFFER_ALPHA_SIZE,
171 reinterpret_cast<GLint*>(&rb_info->alpha_size));
172 gm->GetRenderbufferParameteriv(
173 GL_RENDERBUFFER, GL_RENDERBUFFER_DEPTH_SIZE,
174 reinterpret_cast<GLint*>(&rb_info->depth_size));
175 gm->GetRenderbufferParameteriv(
176 GL_RENDERBUFFER, GL_RENDERBUFFER_STENCIL_SIZE,
177 reinterpret_cast<GLint*>(&rb_info->stencil_size));
184 FillFramebufferAttachmentInfo(
185 gm, &info->color0, &info->color0_renderbuffer, GL_COLOR_ATTACHMENT0);
186 FillFramebufferAttachmentInfo(
187 gm, &info->depth, &info->depth_renderbuffer, GL_DEPTH_ATTACHMENT);
188 FillFramebufferAttachmentInfo(
189 gm, &info->stencil, &info->stencil_renderbuffer, GL_STENCIL_ATTACHMENT);
202 gm->GetSamplerParameteriv(info->id, GL_TEXTURE_COMPARE_FUNC,
203 reinterpret_cast<GLint*>(&info->compare_func));
204 gm->GetSamplerParameteriv(info->id, GL_TEXTURE_COMPARE_MODE,
205 reinterpret_cast<GLint*>(&info->compare_mode));
206 gm->GetSamplerParameterfv(
207 info->id, GL_TEXTURE_MAX_ANISOTROPY_EXT,
208 reinterpret_cast<GLfloat*>(&info->max_anisotropy));
209 gm->GetSamplerParameteriv(info->id, GL_TEXTURE_MAG_FILTER,
210 reinterpret_cast<GLint*>(&info->mag_filter));
211 gm->GetSamplerParameterfv(info->id, GL_TEXTURE_MAX_LOD,
212 reinterpret_cast<GLfloat*>(&info->max_lod));
213 gm->GetSamplerParameteriv(info->id, GL_TEXTURE_MIN_FILTER,
214 reinterpret_cast<GLint*>(&info->min_filter));
215 gm->GetSamplerParameterfv(info->id, GL_TEXTURE_MIN_LOD,
216 reinterpret_cast<GLfloat*>(&info->min_lod));
217 gm->GetSamplerParameteriv(
218 info->id, GL_TEXTURE_WRAP_R, reinterpret_cast<GLint*>(&info->wrap_r));
219 gm->GetSamplerParameteriv(
220 info->id, GL_TEXTURE_WRAP_S, reinterpret_cast<GLint*>(&info->wrap_s));
221 gm->GetSamplerParameteriv(
222 info->id, GL_TEXTURE_WRAP_T, reinterpret_cast<GLint*>(&info->wrap_t));
235 GLint boolean_value = GL_FALSE;
237 info->id, GL_SHADER_TYPE, reinterpret_cast<GLint*>(&info->type));
238 gm->GetShaderiv(info->id, GL_DELETE_STATUS, &boolean_value);
239 info->delete_status =
static_cast<GLboolean
>(boolean_value);
240 gm->GetShaderiv(info->id, GL_COMPILE_STATUS, &boolean_value);
241 info->compile_status =
static_cast<GLboolean
>(boolean_value);
245 gm->GetShaderiv(info->id, GL_SHADER_SOURCE_LENGTH, &length);
246 length = std::max(1, length);
250 gm->GetShaderSource(info->id, length, &length,
buffer.Get());
251 info->source =
buffer.Get();
256 gm->GetShaderiv(info->id, GL_INFO_LOG_LENGTH, &length);
257 length = std::max(1, length);
261 gm->GetShaderInfoLog(info->id, length, &length,
buffer.Get());
262 info->info_log =
buffer.Get();
273 template <
typename T>
274 void FillShaderInputs(
277 const std::function<
void(GLuint, GLuint, GLsizei, GLsizei*, GLint*, GLenum*,
279 const std::function<GLint(GLuint,
const GLchar*)>& GetLocation,
280 std::vector<T>* infos) {
282 gm->GetProgramiv(
id, active_enum, &count);
283 infos->resize(count);
287 for (GLint i = 0; i < count; ++i) {
291 GetInput(
id, static_cast<GLuint>(i), 2047, &length, &(*infos)[i].size,
292 &(*infos)[i].
type, name);
293 (*infos)[i].name =
name;
294 (*infos)[i].index = GetLocation(
id, name);
295 if ((*infos)[i].size > 1) {
296 for (GLint j = 0; j < (*infos)[i].size; ++j) {
297 std::ostringstream
str;
298 str << name <<
"[" << j <<
"]";
299 const std::string array_name = str.str();
300 (*infos)[i].array_indices.push_back(
301 GetLocation(
id, array_name.c_str()));
308 template <
typename T>
309 static void FillUniformValue(
T* values,
310 ResourceManager::ProgramInfo::Uniform* uniform,
312 if (uniform->size > 1) {
313 uniform->value.InitArray<
T>(allocator, uniform->size);
314 for (GLint i = 0; i < uniform->size; i++)
315 uniform->value.SetValueAt(i, values[i]);
317 uniform->value.Set(values[0]);
321 template <
int Dimension,
typename T>
322 static void FillUniformValue(math::Matrix<Dimension, T>* values,
323 ResourceManager::ProgramInfo::Uniform* uniform,
325 if (uniform->size > 1) {
326 uniform->value.InitArray<math::Matrix<Dimension, T>>(allocator,
328 for (GLint i = 0; i < uniform->size; i++)
338 template <
typename T>
341 ResourceManager::ProgramInfo::Uniform* uniform,
342 void (GraphicsManager::*Getv)(GLuint, GLint,
T*),
345 if (uniform->size == 1) {
346 ((*gm).*Getv)(
id, uniform->index, gl_values);
348 uint8* ptr =
reinterpret_cast<uint8*
>(gl_values);
349 for (GLint i = 0; i < uniform->size; ++i) {
350 T* values =
reinterpret_cast<T*
>(&ptr[i * stride]);
351 ((*gm).*Getv)(
id, uniform->array_indices[i], values);
356 template <
typename T>
357 static void FillFloatUniformValue(
359 ResourceManager::ProgramInfo::Uniform* uniform,
T* values,
362 GetGlUniformValue(gm,
id,
sizeof(
T), uniform, &GraphicsManager::GetUniformfv,
364 FillUniformValue(values, uniform, allocator);
367 template <
typename T>
369 ResourceManager::ProgramInfo::Uniform* uniform,
370 T* values, GLint* gl_values,
374 FillUniformValue(values, uniform, allocator);
377 template <
typename T>
379 ResourceManager::ProgramInfo::Uniform* uniform,
380 T* values, GLuint* gl_values,
382 GetGlUniformValue(gm,
id,
sizeof(
T), uniform, &GraphicsManager::GetUniformuiv,
384 FillUniformValue(values, uniform, allocator);
387 static void FillUniformValues(
389 std::vector<ResourceManager::ProgramInfo::Uniform>* uniforms) {
393 const size_t count = uniforms->size();
394 for (
size_t i = 0; i < count; ++i) {
395 ResourceManager::ProgramInfo::Uniform& u = (*uniforms)[i];
398 base::ScopedAllocation<float>
value(allocator, u.size);
399 FillFloatUniformValue<float>(gm,
id, &u,
value.Get(),
value.Get(),
403 case GL_FLOAT_VEC2: {
404 base::ScopedAllocation<math::Vector2f>
value(allocator, u.size);
405 FillFloatUniformValue<math::Vector2f>(gm,
id, &u,
value.Get(),
406 &(*
value.Get())[0], allocator);
409 case GL_FLOAT_VEC3: {
410 base::ScopedAllocation<math::Vector3f>
value(allocator, u.size);
411 FillFloatUniformValue<math::Vector3f>(gm,
id, &u,
value.Get(),
412 &(*
value.Get())[0], allocator);
415 case GL_FLOAT_VEC4: {
416 base::ScopedAllocation<math::Vector4f>
value(allocator, u.size);
417 FillFloatUniformValue<math::Vector4f>(gm,
id, &u,
value.Get(),
418 &(*
value.Get())[0], allocator);
423 case GL_INT_SAMPLER_1D:
424 case GL_INT_SAMPLER_1D_ARRAY:
425 case GL_INT_SAMPLER_2D:
426 case GL_INT_SAMPLER_2D_ARRAY:
427 case GL_INT_SAMPLER_3D:
428 case GL_INT_SAMPLER_CUBE:
429 case GL_INT_SAMPLER_CUBE_MAP_ARRAY:
431 case GL_SAMPLER_1D_ARRAY:
432 case GL_SAMPLER_1D_ARRAY_SHADOW:
433 case GL_SAMPLER_1D_SHADOW:
435 case GL_SAMPLER_2D_ARRAY:
436 case GL_SAMPLER_2D_ARRAY_SHADOW:
437 case GL_SAMPLER_2D_MULTISAMPLE:
438 case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
439 case GL_SAMPLER_2D_SHADOW:
441 case GL_SAMPLER_CUBE:
442 case GL_SAMPLER_CUBE_MAP_ARRAY:
443 case GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW:
444 case GL_SAMPLER_CUBE_SHADOW:
446 case GL_UNSIGNED_INT_SAMPLER_1D:
447 case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY:
448 case GL_UNSIGNED_INT_SAMPLER_2D:
449 case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
450 case GL_UNSIGNED_INT_SAMPLER_3D:
451 case GL_UNSIGNED_INT_SAMPLER_CUBE:
452 case GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY: {
453 base::ScopedAllocation<int>
value(allocator, u.size);
454 FillIntUniformValue<int>(gm,
id, &u,
value.Get(),
value.Get(),
459 base::ScopedAllocation<math::Vector2i>
value(allocator, u.size);
460 FillIntUniformValue<math::Vector2i>(gm,
id, &u,
value.Get(),
461 &(*
value.Get())[0], allocator);
465 base::ScopedAllocation<math::Vector3i>
value(allocator, u.size);
466 FillIntUniformValue<math::Vector3i>(gm,
id, &u,
value.Get(),
467 &(*
value.Get())[0], allocator);
471 base::ScopedAllocation<math::Vector4i>
value(allocator, u.size);
472 FillIntUniformValue<math::Vector4i>(gm,
id, &u,
value.Get(),
473 &(*
value.Get())[0], allocator);
476 case GL_UNSIGNED_INT: {
477 base::ScopedAllocation<uint32>
value(allocator, u.size);
478 FillUintUniformValue<uint32>(gm,
id, &u,
value.Get(),
value.Get(),
482 case GL_UNSIGNED_INT_VEC2: {
483 base::ScopedAllocation<math::Vector2ui>
value(allocator, u.size);
484 FillUintUniformValue<math::Vector2ui>(gm,
id, &u,
value.Get(),
485 &(*
value.Get())[0], allocator);
488 case GL_UNSIGNED_INT_VEC3: {
489 base::ScopedAllocation<math::Vector3ui>
value(allocator, u.size);
490 FillUintUniformValue<math::Vector3ui>(gm,
id, &u,
value.Get(),
491 &(*
value.Get())[0], allocator);
494 case GL_UNSIGNED_INT_VEC4: {
495 base::ScopedAllocation<math::Vector4ui>
value(allocator, u.size);
496 FillUintUniformValue<math::Vector4ui>(gm,
id, &u,
value.Get(),
497 &(*
value.Get())[0], allocator);
500 case GL_FLOAT_MAT2: {
501 base::ScopedAllocation<math::Matrix2f>
value(allocator, u.size);
502 FillFloatUniformValue<math::Matrix2f>(gm,
id, &u,
value.Get(),
503 &(*
value.Get())[0][0], allocator);
506 case GL_FLOAT_MAT3: {
507 base::ScopedAllocation<math::Matrix3f>
value(allocator, u.size);
508 FillFloatUniformValue<math::Matrix3f>(gm,
id, &u,
value.Get(),
509 &(*
value.Get())[0][0], allocator);
512 case GL_FLOAT_MAT4: {
513 base::ScopedAllocation<math::Matrix4f>
value(allocator, u.size);
514 FillFloatUniformValue<math::Matrix4f>(gm,
id, &u,
value.Get(),
515 &(*
value.Get())[0][0], allocator);
518 #if !defined(ION_COVERAGE) // COV_NF_START
529 using std::placeholders::_1;
530 using std::placeholders::_2;
531 using std::placeholders::_3;
532 using std::placeholders::_4;
533 using std::placeholders::_5;
534 using std::placeholders::_6;
535 using std::placeholders::_7;
538 GLint boolean_value = GL_FALSE;
539 gm->GetProgramiv(info->id, GL_DELETE_STATUS, &boolean_value);
540 info->delete_status =
static_cast<GLboolean
>(boolean_value);
541 gm->GetProgramiv(info->id, GL_LINK_STATUS, &boolean_value);
542 info->link_status =
static_cast<GLboolean
>(boolean_value);
543 gm->GetProgramiv(info->id, GL_VALIDATE_STATUS, &boolean_value);
544 info->validate_status =
static_cast<GLboolean
>(boolean_value);
547 GLint info_log_length = 0;
548 gm->GetProgramiv(info->id, GL_INFO_LOG_LENGTH, &info_log_length);
549 info_log_length = std::max(1, info_log_length);
553 gm->GetProgramInfoLog(
554 info->id, info_log_length, &info_log_length,
buffer.Get());
555 info->info_log =
buffer.Get();
557 info->info_log.resize(info_log_length);
561 gm, info->id, GL_ACTIVE_ATTRIBUTES, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH,
563 _1, _2, _3, _4, _5, _6, _7),
564 bind(&GraphicsManager::GetAttribLocation, gm.Get(), _1, _2),
568 gm, info->id, GL_ACTIVE_UNIFORMS, GL_ACTIVE_UNIFORM_MAX_LENGTH,
569 bind(&GraphicsManager::GetActiveUniform, gm.Get(),
570 _1, _2, _3, _4, _5, _6, _7),
571 bind(&GraphicsManager::GetUniformLocation, gm.Get(), _1, _2),
574 FillUniformValues(gm, info->id, &info->uniforms);
585 ResourceManager::PlatformInfo* info) {
586 info->renderer =
reinterpret_cast<const char*
>(gm->GetString(GL_RENDERER));
587 info->vendor =
reinterpret_cast<const char*
>(gm->GetString(GL_VENDOR));
588 info->version_string =
589 reinterpret_cast<const char*
>(gm->GetString(GL_VERSION));
591 const size_t dot_pos = info->version_string.find(
'.');
592 info->major_version = 0;
593 info->minor_version = 0;
594 info->glsl_version = 0;
595 if (dot_pos != std::string::npos && dot_pos > 0 &&
596 dot_pos < info->version_string.length() - 1) {
597 info->major_version = info->version_string[dot_pos - 1] -
'0';
598 info->minor_version = info->version_string[dot_pos + 1] -
'0';
600 const char* glsl_version_string =
601 reinterpret_cast<const char*
>(gm->GetString(GL_SHADING_LANGUAGE_VERSION));
603 glsl_version_string,
" ");
604 const size_t count = strings.size();
605 for (
size_t i = 0; i < count; ++i) {
606 size_t pos = strings[i].find(
".");
607 if (pos != std::string::npos) {
610 if (numbers.size() == 2)
616 if (
const char* extensions =
617 reinterpret_cast<const char*>(gm->GetString(GL_EXTENSIONS))) {
618 info->extensions = extensions;
623 ResourceManager::PlatformInfo* info) {
625 gm->GetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, info->aliased_line_width_range);
627 gm->GetGlVersion() >= 30)
628 gm->GetFloatv(GL_POINT_SIZE_RANGE, info->aliased_point_size_range);
633 info->max_color_attachments = -1;
634 gm->GetIntegerv(GL_MAX_COLOR_ATTACHMENTS,
635 &info->max_color_attachments);
636 info->max_combined_texture_image_units = -1;
637 gm->GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,
638 &info->max_combined_texture_image_units);
639 info->max_combined_texture_image_units = -1;
640 gm->GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,
641 &info->max_combined_texture_image_units);
642 info->max_cube_map_texture_size = -1;
643 gm->GetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE,
644 &info->max_cube_map_texture_size);
645 info->max_draw_buffers = -1;
646 gm->GetIntegerv(GL_MAX_DRAW_BUFFERS,
647 &info->max_draw_buffers);
648 info->max_fragment_uniform_vectors = -1;
649 gm->GetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS,
650 &info->max_fragment_uniform_vectors);
651 info->max_renderbuffer_size = -1;
652 gm->GetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &info->max_renderbuffer_size);
653 info->max_texture_image_units = -1;
654 gm->GetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &info->max_texture_image_units);
655 info->max_texture_size = -1;
656 gm->GetIntegerv(GL_MAX_TEXTURE_SIZE, &info->max_texture_size);
657 info->max_varying_vectors = -1;
658 gm->GetIntegerv(GL_MAX_VARYING_VECTORS, &info->max_varying_vectors);
659 info->max_vertex_attribs = -1;
660 gm->GetIntegerv(GL_MAX_VERTEX_ATTRIBS, &info->max_vertex_attribs);
661 info->max_vertex_texture_image_units = -1;
662 gm->GetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS,
663 &info->max_vertex_texture_image_units);
664 info->max_vertex_uniform_vectors = -1;
665 gm->GetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS,
666 &info->max_vertex_uniform_vectors);
667 info->max_viewport_dims[0] = -1;
668 info->max_viewport_dims[1] = -1;
669 gm->GetIntegerv(GL_MAX_VIEWPORT_DIMS, info->max_viewport_dims);
673 info->max_transform_feedback_buffers = -1;
674 info->max_transform_feedback_interleaved_components = -1;
675 info->max_transform_feedback_separate_attribs = -1;
676 info->max_transform_feedback_separate_components = -1;
677 info->transform_feedback_varying_max_length = -1;
679 gm->GetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_BUFFERS,
680 &info->max_transform_feedback_buffers);
681 gm->GetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS,
682 &info->max_transform_feedback_interleaved_components);
683 gm->GetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS,
684 &info->max_transform_feedback_separate_attribs);
685 gm->GetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS,
686 &info->max_transform_feedback_separate_components);
687 gm->GetIntegerv(GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH,
688 &info->transform_feedback_varying_max_length);
693 gm->GetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &count);
694 info->compressed_texture_formats.resize(count);
697 GL_COMPRESSED_TEXTURE_FORMATS,
698 reinterpret_cast<GLint*>(&info->compressed_texture_formats[0]));
701 gm->GetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &count);
702 info->shader_binary_formats.resize(count);
705 GL_SHADER_BINARY_FORMATS,
706 reinterpret_cast<GLint*>(&info->shader_binary_formats[0]));
708 FillStringsAndVersions(gm, info);
721 gm->ActiveTexture(info->unit);
722 gm->GetTexParameterfv(info->target, GL_TEXTURE_MAX_ANISOTROPY_EXT,
723 reinterpret_cast<GLfloat*>(&info->max_anisotropy));
724 gm->GetTexParameteriv(info->target, GL_TEXTURE_MAG_FILTER,
725 reinterpret_cast<GLint*>(&info->mag_filter));
726 gm->GetTexParameteriv(info->target, GL_TEXTURE_MIN_FILTER,
727 reinterpret_cast<GLint*>(&info->min_filter));
728 gm->GetTexParameteriv(info->target, GL_TEXTURE_WRAP_S,
729 reinterpret_cast<GLint*>(&info->wrap_s));
730 gm->GetTexParameteriv(info->target, GL_TEXTURE_WRAP_T,
731 reinterpret_cast<GLint*>(&info->wrap_t));
732 if (gm->GetGlVersion() > 20) {
733 gm->GetIntegerv(GL_SAMPLER_BINDING,
734 reinterpret_cast<GLint*>(&info->sampler));
735 gm->GetTexParameteriv(info->target, GL_TEXTURE_BASE_LEVEL,
736 reinterpret_cast<GLint*>(&info->base_level));
737 gm->GetTexParameteriv(info->target, GL_TEXTURE_COMPARE_FUNC,
738 reinterpret_cast<GLint*>(&info->compare_func));
739 gm->GetTexParameteriv(info->target, GL_TEXTURE_COMPARE_MODE,
740 reinterpret_cast<GLint*>(&info->compare_mode));
741 gm->GetTexParameteriv(info->target, GL_TEXTURE_MAX_LEVEL,
742 reinterpret_cast<GLint*>(&info->max_level));
743 gm->GetTexParameterfv(info->target, GL_TEXTURE_MAX_LOD,
744 reinterpret_cast<GLfloat*>(&info->max_lod));
745 gm->GetTexParameterfv(info->target, GL_TEXTURE_MIN_LOD,
746 reinterpret_cast<GLfloat*>(&info->min_lod));
747 gm->GetTexParameteriv(info->target, GL_TEXTURE_SWIZZLE_R,
748 reinterpret_cast<GLint*>(&info->swizzle_r));
749 gm->GetTexParameteriv(info->target, GL_TEXTURE_SWIZZLE_G,
750 reinterpret_cast<GLint*>(&info->swizzle_g));
751 gm->GetTexParameteriv(info->target, GL_TEXTURE_SWIZZLE_B,
752 reinterpret_cast<GLint*>(&info->swizzle_b));
753 gm->GetTexParameteriv(info->target, GL_TEXTURE_SWIZZLE_A,
754 reinterpret_cast<GLint*>(&info->swizzle_a));
755 gm->GetTexParameteriv(info->target, GL_TEXTURE_WRAP_R,
756 reinterpret_cast<GLint*>(&info->wrap_r));
759 gm->GetTexParameteriv(info->target, GL_TEXTURE_SAMPLES,
760 reinterpret_cast<GLint*>(&info->samples));
761 gm->GetTexParameteriv(info->target, GL_TEXTURE_FIXED_SAMPLE_LOCATIONS,
762 reinterpret_cast<GLint*>(
763 &info->fixed_sample_locations));
770 : graphics_manager_(gm) {
781 return &array_requests_;
785 std::vector<ResourceManager::ResourceRequest<BufferObject,
789 return &buffer_requests_;
792 template <> ION_API std::vector<
793 ResourceManager::ResourceRequest<FramebufferObject,
797 return &framebuffer_requests_;
801 std::vector<ResourceManager::DataRequest<ResourceManager::PlatformInfo> >*
802 ResourceManager::GetDataRequestVector<ResourceManager::PlatformInfo>() {
803 return &platform_requests_;
807 std::vector<ResourceManager::ResourceRequest<ShaderProgram,
811 return &program_requests_;
814 template <> ION_API std::vector<
815 ResourceManager::ResourceRequest<Sampler, ResourceManager::SamplerInfo> >*
818 return &sampler_requests_;
821 template <> ION_API std::vector<
822 ResourceManager::ResourceRequest<Shader, ResourceManager::ShaderInfo> >*
825 return &shader_requests_;
829 std::vector<ResourceManager::ResourceRequest<TextureBase,
833 return &texture_requests_;
837 std::vector<ResourceManager::DataRequest<ResourceManager::TextureImageInfo> >*
838 ResourceManager::GetDataRequestVector<ResourceManager::TextureImageInfo>() {
839 return &texture_image_requests_;
845 GetDataRequestVector<PlatformInfo>()->push_back(
851 GetDataRequestVector<TextureImageInfo>()->push_back(
857 FillArrayInfo(graphics_manager_, info);
862 FillBufferInfo(graphics_manager_, info);
868 FillFramebufferInfo(graphics_manager_, info);
873 FillProgramInfo(graphics_manager_, info);
878 FillSamplerInfo(graphics_manager_, info);
883 FillShaderInfo(graphics_manager_, info);
888 FillPlatformInfo(graphics_manager_, info);
893 FillTextureInfo(graphics_manager_, info);
kShortTerm is used for objects that are very transient in nature, such as scratch memory used to comp...
A ShaderInfo corresponds to an OpenGL Shader Object.
A SamplerInfo corresponds to an OpenGL Sampler Object.
gfx::BufferInfo< BufferTargetInfo > BufferInfo
ResourceManager(const GraphicsManagerPtr &gm)
A valid GraphicsManagerPtr must be passed to the constructor.
gfx::FramebufferInfo< FramebufferResourceInfo > FramebufferInfo
std::function< void(const std::vector< T > &infos)> Type
void RequestTextureImage(GLuint id, const InfoCallback< TextureImageInfo >::Type &callback)
Executes the callback passing a TextureImageInfo that contains a pointer to the texture that has the ...
std::vector< std::string > ION_API SplitString(const std::string &str, const std::string &delimiters)
Splits a string into a vector of substrings, given a set of delimiter characters (expressed as a stri...
~ResourceManager() override
SharedPtr< Allocator > AllocatorPtr
A LockGuard locks a mutex when created, and unlocks it when destroyed.
gfx::TextureInfo< TextureResourceInfo > TextureInfo
void FillInfoFromOpenGL(InfoType *info)
Performs OpenGL calls to fill in info details, specialized for each type derived from ResourceInfo...
Wrapper struct for resource info requests.
Struct containing information about a texture and its image(s).
gfx::ProgramInfo< ResourceInfo > ProgramInfo
port::Mutex request_mutex_
For locking access to request vectors.
int32 ION_API StringToInt32(const std::string &str)
Extracts and returns an integral value from str.
An AttributeArray represents a collection of Attributes used to describe the vertices of a Shape...
void RequestPlatformInfo(const InfoCallback< PlatformInfo >::Type &callback)
Requests information about the local OpenGL platform.
gfx::SamplerInfo< ResourceInfo > SamplerInfo
std::vector< ResourceRequest< HolderType, InfoType > > * GetResourceRequestVector()
Returns a pointer to the vector of requests for the templated holder and info types.
A ProgramInfo corresponds to an OpenGL Program Object.
Wrapper struct for data requests.
A BufferInfo corresponds to an OpenGL Framebuffer Object.
base::ReferentPtr< GraphicsManager >::Type GraphicsManagerPtr
Convenience typedef for shared pointer to a GraphicsManager.
gfx::RenderbufferInfo< ResourceInfo > RenderbufferInfo
A BufferInfo corresponds to an OpenGL Buffer Object.
gfx::ArrayInfo< ArrayResourceInfo > ArrayInfo
The actual info types.
framebuffer alpha dfactor const GLvoid usage alpha const GLvoid data border const GLuint buffers const GLuint renderbuffers count renderbuffer GLuint framebuffers GLsizei GLint GLenum GLchar name GLsizei GLuint shaders GLint data GLsizei GLchar info_log GLint params GLint GLint precision GLint params GLint params GetUniformiv
The below structs correspond to OpenGL "objects." For example, a BufferObject corresponds to an OpenG...
A TextureInfo corresponds to an OpenGL Texture Object.
A SharedPtr is a smart shared pointer to an instance of some class that implements reference counting...
kMediumTerm is used for objects that don't fall into the kShortTerm or kLongTerm categories.
framebuffer alpha dfactor const GLvoid usage alpha const GLvoid data border const GLuint buffers const GLuint renderbuffers count renderbuffer GLuint framebuffers GetActiveAttrib
Matrix< Dimension, T > Transpose(const Matrix< Dimension, T > &m)
Public functions.
static const AllocatorPtr & GetDefaultAllocatorForLifetime(AllocationLifetime lifetime)
gfx::ShaderInfo< ResourceInfo > ShaderInfo