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

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

Issue 1883273004: Emulate TEXTURE_IMMUTABLE_LEVELS on GL lower than 4.2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 void DoGetRenderbufferParameteriv( 1552 void DoGetRenderbufferParameteriv(
1553 GLenum target, GLenum pname, GLint* params); 1553 GLenum target, GLenum pname, GLint* params);
1554 1554
1555 // Wrappers for glGetSamplerParameter. 1555 // Wrappers for glGetSamplerParameter.
1556 void DoGetSamplerParameterfv(GLuint client_id, GLenum pname, GLfloat* params); 1556 void DoGetSamplerParameterfv(GLuint client_id, GLenum pname, GLfloat* params);
1557 void DoGetSamplerParameteriv(GLuint client_id, GLenum pname, GLint* params); 1557 void DoGetSamplerParameteriv(GLuint client_id, GLenum pname, GLint* params);
1558 1558
1559 // Wrapper for glGetShaderiv 1559 // Wrapper for glGetShaderiv
1560 void DoGetShaderiv(GLuint shader, GLenum pname, GLint* params); 1560 void DoGetShaderiv(GLuint shader, GLenum pname, GLint* params);
1561 1561
1562 // Helper for DoGetTexParameter{f|i}v.
1563 void GetTexParameterImpl(
1564 GLenum target, GLenum pname, GLfloat* fparams, GLint* iparams,
1565 const char* function_name);
1566
1562 // Wrappers for glGetTexParameter. 1567 // Wrappers for glGetTexParameter.
1563 void DoGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params); 1568 void DoGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params);
1564 void DoGetTexParameteriv(GLenum target, GLenum pname, GLint* params); 1569 void DoGetTexParameteriv(GLenum target, GLenum pname, GLint* params);
1565 void InitTextureMaxAnisotropyIfNeeded(GLenum target, GLenum pname);
1566 1570
1567 // Wrappers for glGetVertexAttrib. 1571 // Wrappers for glGetVertexAttrib.
1568 template <typename T> 1572 template <typename T>
1569 void DoGetVertexAttribImpl(GLuint index, GLenum pname, T* params); 1573 void DoGetVertexAttribImpl(GLuint index, GLenum pname, T* params);
1570 void DoGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params); 1574 void DoGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params);
1571 void DoGetVertexAttribiv(GLuint index, GLenum pname, GLint* params); 1575 void DoGetVertexAttribiv(GLuint index, GLenum pname, GLint* params);
1572 void DoGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params); 1576 void DoGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params);
1573 void DoGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params); 1577 void DoGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params);
1574 1578
1575 // Wrappers for glIsXXX functions. 1579 // Wrappers for glIsXXX functions.
(...skipping 7330 matching lines...) Expand 10 before | Expand all | Expand 10 after
8906 GLuint client_id, GLenum pname, GLint* params) { 8910 GLuint client_id, GLenum pname, GLint* params) {
8907 Sampler* sampler = GetSampler(client_id); 8911 Sampler* sampler = GetSampler(client_id);
8908 if (!sampler) { 8912 if (!sampler) {
8909 LOCAL_SET_GL_ERROR( 8913 LOCAL_SET_GL_ERROR(
8910 GL_INVALID_OPERATION, "glGetSamplerParamteriv", "unknown sampler"); 8914 GL_INVALID_OPERATION, "glGetSamplerParamteriv", "unknown sampler");
8911 return; 8915 return;
8912 } 8916 }
8913 glGetSamplerParameteriv(sampler->service_id(), pname, params); 8917 glGetSamplerParameteriv(sampler->service_id(), pname, params);
8914 } 8918 }
8915 8919
8920 void GLES2DecoderImpl::GetTexParameterImpl(
8921 GLenum target, GLenum pname, GLfloat* fparams, GLint* iparams,
8922 const char* function_name) {
8923 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget(
8924 &state_, target);
8925 if (!texture_ref) {
8926 LOCAL_SET_GL_ERROR(
8927 GL_INVALID_OPERATION, function_name, "unknown texture for target");
8928 return;
8929 }
8930 Texture* texture = texture_ref->texture();
8931 switch (pname) {
8932 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
8933 if (workarounds().init_texture_max_anisotropy) {
8934 texture->InitTextureMaxAnisotropyIfNeeded(target);
8935 }
8936 break;
8937 case GL_TEXTURE_IMMUTABLE_LEVELS:
8938 if (feature_info_->gl_version_info().IsLowerThanGL(4, 2)) {
8939 GLint levels = texture->GetImmutableLevels();
8940 if (fparams) {
8941 fparams[0] = static_cast<GLfloat>(levels);
8942 } else {
8943 iparams[0] = levels;
8944 }
8945 return;
8946 }
8947 break;
8948 default:
8949 break;
8950 }
8951 if (fparams) {
8952 glGetTexParameterfv(target, pname, fparams);
8953 } else {
8954 glGetTexParameteriv(target, pname, iparams);
8955 }
8956 }
8957
8916 void GLES2DecoderImpl::DoGetTexParameterfv( 8958 void GLES2DecoderImpl::DoGetTexParameterfv(
8917 GLenum target, GLenum pname, GLfloat* params) { 8959 GLenum target, GLenum pname, GLfloat* params) {
8918 InitTextureMaxAnisotropyIfNeeded(target, pname); 8960 GetTexParameterImpl(target, pname, params, nullptr, "glGetTexParameterfv");
8919 glGetTexParameterfv(target, pname, params);
8920 } 8961 }
8921 8962
8922 void GLES2DecoderImpl::DoGetTexParameteriv( 8963 void GLES2DecoderImpl::DoGetTexParameteriv(
8923 GLenum target, GLenum pname, GLint* params) { 8964 GLenum target, GLenum pname, GLint* params) {
8924 InitTextureMaxAnisotropyIfNeeded(target, pname); 8965 GetTexParameterImpl(target, pname, nullptr, params, "glGetTexParameteriv");
8925 glGetTexParameteriv(target, pname, params);
8926 }
8927
8928 void GLES2DecoderImpl::InitTextureMaxAnisotropyIfNeeded(
8929 GLenum target, GLenum pname) {
8930 if (!workarounds().init_texture_max_anisotropy)
8931 return;
8932 if (pname != GL_TEXTURE_MAX_ANISOTROPY_EXT ||
8933 !validators_->texture_parameter.IsValid(pname)) {
8934 return;
8935 }
8936
8937 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget(
8938 &state_, target);
8939 if (!texture_ref) {
8940 LOCAL_SET_GL_ERROR(
8941 GL_INVALID_OPERATION,
8942 "glGetTexParamter{fi}v", "unknown texture for target");
8943 return;
8944 }
8945 Texture* texture = texture_ref->texture();
8946 texture->InitTextureMaxAnisotropyIfNeeded(target);
8947 } 8966 }
8948 8967
8949 template <typename T> 8968 template <typename T>
8950 void GLES2DecoderImpl::DoGetVertexAttribImpl( 8969 void GLES2DecoderImpl::DoGetVertexAttribImpl(
8951 GLuint index, GLenum pname, T* params) { 8970 GLuint index, GLenum pname, T* params) {
8952 VertexAttrib* attrib = state_.vertex_attrib_manager->GetVertexAttrib(index); 8971 VertexAttrib* attrib = state_.vertex_attrib_manager->GetVertexAttrib(index);
8953 if (!attrib) { 8972 if (!attrib) {
8954 LOCAL_SET_GL_ERROR( 8973 LOCAL_SET_GL_ERROR(
8955 GL_INVALID_VALUE, "glGetVertexAttrib", "index out of range"); 8974 GL_INVALID_VALUE, "glGetVertexAttrib", "index out of range");
8956 return; 8975 return;
(...skipping 7535 matching lines...) Expand 10 before | Expand all | Expand 10 after
16492 } 16511 }
16493 16512
16494 // Include the auto-generated part of this file. We split this because it means 16513 // Include the auto-generated part of this file. We split this because it means
16495 // we can easily edit the non-auto generated parts right here in this file 16514 // we can easily edit the non-auto generated parts right here in this file
16496 // instead of having to edit some template or the code generator. 16515 // instead of having to edit some template or the code generator.
16497 #include "base/macros.h" 16516 #include "base/macros.h"
16498 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 16517 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
16499 16518
16500 } // namespace gles2 16519 } // namespace gles2
16501 } // namespace gpu 16520 } // namespace gpu
OLDNEW
« no previous file with comments | « content/test/gpu/gpu_tests/webgl2_conformance_expectations.py ('k') | gpu/command_buffer/service/texture_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698