13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES Utilities 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ------------------------------------------------ 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Render context implementation that does no rendering. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuNullRenderContext.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTexture.hpp" 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTextureUtil.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deThreadLocal.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluRenderConfig.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluTextureUtil.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <string> 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector> 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace tcu 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace null 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string; 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector; 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace glw; 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace glu; 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ObjectManager 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ObjectManager (void) 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : m_lastObject(0) 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 allocate (void) 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 object = ++m_lastObject; 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (object == 0) 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry object = ++m_lastObject; // Just ignore overflow. 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return object; 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void free (deUint32 object) 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(object); 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_lastObject; 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Context 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context (ContextType ctxType_); 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~Context (void); 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context (const Context&); 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context& operator= (const Context&); 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void addExtension (const char* name); 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // GL state exposed to implementation functions. 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ContextType ctxType; 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry string vendor; 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry string version; 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry string renderer; 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry string shadingLanguageVersion; 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry string extensions; 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<string> extensionList; 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum lastError; 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int pixelPackRowLength; 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int pixelPackSkipRows; 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int pixelPackSkipPixels; 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int pixelPackAlignment; 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint pixelPackBufferBufferBinding; 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ObjectManager shaders; 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ObjectManager programs; 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ObjectManager textures; 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ObjectManager buffers; 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ObjectManager renderbuffers; 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ObjectManager framebuffers; 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ObjectManager samplers; 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ObjectManager vertexArrays; 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ObjectManager queries; 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ObjectManager transformFeedbacks; 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ObjectManager programPipelines; 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1153c827367444ee418f129b2c238299f49d3264554Jarkko PoyryContext::Context (ContextType ctxType_) 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : ctxType (ctxType_) 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , vendor ("drawElements") 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , renderer ("dummy") 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , lastError (GL_NO_ERROR) 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , pixelPackRowLength (0) 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , pixelPackSkipRows (0) 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , pixelPackSkipPixels (0) 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , pixelPackAlignment (0) 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , pixelPackBufferBufferBinding (0) 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using glu::ApiType; 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (ctxType.getAPI() == ApiType::es(2, 0)) 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry version = "OpenGL ES 2.0"; 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry shadingLanguageVersion = "OpenGL ES GLSL ES 1.0"; 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (ctxType.getAPI() == ApiType::es(3, 0)) 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry version = "OpenGL ES 3.0"; 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry shadingLanguageVersion = "OpenGL ES GLSL ES 3.0"; 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (ctxType.getAPI() == ApiType::es(3, 1)) 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry version = "OpenGL ES 3.1"; 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry shadingLanguageVersion = "OpenGL ES GLSL ES 3.1"; 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addExtension("GL_OES_texture_stencil8"); 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addExtension("GL_OES_sample_shading"); 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addExtension("GL_OES_sample_variables"); 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addExtension("GL_OES_shader_multisample_interpolation"); 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addExtension("GL_OES_shader_image_atomics"); 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addExtension("GL_OES_texture_storage_multisample_2d_array"); 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addExtension("GL_KHR_blend_equation_advanced"); 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addExtension("GL_KHR_blend_equation_advanced_coherent"); 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addExtension("GL_EXT_shader_io_blocks"); 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addExtension("GL_EXT_geometry_shader"); 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addExtension("GL_EXT_geometry_point_size"); 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addExtension("GL_EXT_tessellation_shader"); 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addExtension("GL_EXT_tessellation_point_size"); 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addExtension("GL_EXT_gpu_shader5"); 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (glu::isContextTypeGLCore(ctxType) && ctxType.getMajorVersion() == 3) 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry version = "3.3.0"; 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry shadingLanguageVersion = "3.30"; 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (glu::isContextTypeGLCore(ctxType) && ctxType.getMajorVersion() == 4 && ctxType.getMinorVersion() <= 4) 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry version = "4.4.0"; 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry shadingLanguageVersion = "4.40"; 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError("Unsupported GL version", "", __FILE__, __LINE__); 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (isContextTypeES(ctxType)) 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addExtension("GL_EXT_color_buffer_float"); 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1743c827367444ee418f129b2c238299f49d3264554Jarkko PoyryContext::~Context (void) 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Context::addExtension (const char* name) 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!extensions.empty()) 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry extensions += " "; 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry extensions += name; 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry extensionList.push_back(name); 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic de::ThreadLocal s_currentCtx; 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid setCurrentContext (Context* context) 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry s_currentCtx.set((void*)context); 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1943c827367444ee418f129b2c238299f49d3264554Jarkko PoyryContext* getCurrentContext (void) 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return (Context*)s_currentCtx.get(); 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1993c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL GLenum GLW_APIENTRY glGetError (void) 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context* const ctx = getCurrentContext(); 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLenum lastErr = ctx->lastError; 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx->lastError = GL_NO_ERROR; 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return lastErr; 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2093c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL void GLW_APIENTRY glGetIntegerv (GLenum pname, GLint* params) 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context* const ctx = getCurrentContext(); 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (pname) 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_NUM_EXTENSIONS: 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *params = (int)ctx->extensionList.size(); 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_MAX_VERTEX_ATTRIBS: 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *params = 32; 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_MAX_DRAW_BUFFERS: 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_MAX_COLOR_ATTACHMENTS: 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *params = 8; 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_MAX_TEXTURE_IMAGE_UNITS: 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS: 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS: 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS: 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *params = 16; 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_MAX_TEXTURE_SIZE: 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_MAX_CUBE_MAP_TEXTURE_SIZE: 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_MAX_3D_TEXTURE_SIZE: 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_MAX_RENDERBUFFER_SIZE: 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *params = 2048; 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_MAX_ARRAY_TEXTURE_LAYERS: 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *params = 128; 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_NUM_SHADER_BINARY_FORMATS: 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *params = 0; 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_NUM_COMPRESSED_TEXTURE_FORMATS: 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *params = 0; 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *params = 16; 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_MAX_UNIFORM_BUFFER_BINDINGS: 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *params = 32; 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *params = 16; 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_IMPLEMENTATION_COLOR_READ_FORMAT: 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *params = GL_RGBA; 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_IMPLEMENTATION_COLOR_READ_TYPE: 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *params = GL_UNSIGNED_BYTE; 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_SAMPLE_BUFFERS: 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *params = 0; 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2853c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL void GLW_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params) 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (pname) 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_SHADER_COMPILER: 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *params = GL_TRUE; 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2983c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL void GLW_APIENTRY glGetFloatv (GLenum pname, GLfloat* params) 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (pname) 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_ALIASED_LINE_WIDTH_RANGE: 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_ALIASED_POINT_SIZE_RANGE: 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry params[0] = 0.0f; 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry params[1] = 64.0f; 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3133c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL const glw::GLubyte* GLW_APIENTRY glGetString (GLenum name) 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context* const ctx = getCurrentContext(); 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (name) 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_VENDOR: return (const glw::GLubyte*)ctx->vendor.c_str(); 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_VERSION: return (const glw::GLubyte*)ctx->version.c_str(); 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_RENDERER: return (const glw::GLubyte*)ctx->renderer.c_str(); 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_SHADING_LANGUAGE_VERSION: return (const glw::GLubyte*)ctx->shadingLanguageVersion.c_str(); 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_EXTENSIONS: return (const glw::GLubyte*)ctx->extensions.c_str(); 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx->lastError = GL_INVALID_ENUM; 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return DE_NULL; 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3303c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL const glw::GLubyte* GLW_APIENTRY glGetStringi (GLenum name, GLuint index) 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context* const ctx = getCurrentContext(); 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (name == GL_EXTENSIONS) 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((size_t)index < ctx->extensionList.size()) 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return (const glw::GLubyte*)ctx->extensionList[index].c_str(); 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx->lastError = GL_INVALID_VALUE; 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return DE_NULL; 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx->lastError = GL_INVALID_ENUM; 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return DE_NULL; 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3513c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL GLuint GLW_APIENTRY glCreateProgram () 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context* const ctx = getCurrentContext(); 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return (GLuint)ctx->programs.allocate(); 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3573c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL GLuint GLW_APIENTRY glCreateShader (GLenum type) 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context* const ctx = getCurrentContext(); 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(type); 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return (GLuint)ctx->shaders.allocate(); 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3643c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL void GLW_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params) 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(shader); 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (pname == GL_COMPILE_STATUS) 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *params = GL_TRUE; 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3723c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL void GLW_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params) 3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(program); 3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (pname == GL_LINK_STATUS) 3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *params = GL_TRUE; 3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3803c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL void GLW_APIENTRY glGenTextures (GLsizei n, GLuint* textures) 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context* const ctx = getCurrentContext(); 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (textures) 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < n; ndx++) 3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry textures[ndx] = ctx->textures.allocate(); 3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3913c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL void GLW_APIENTRY glGenQueries (GLsizei n, GLuint* ids) 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context* const ctx = getCurrentContext(); 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (ids) 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < n; ndx++) 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ids[ndx] = ctx->queries.allocate(); 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4023c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL void GLW_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers) 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context* const ctx = getCurrentContext(); 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (buffers) 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < n; ndx++) 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry buffers[ndx] = ctx->buffers.allocate(); 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4133c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL void GLW_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers) 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context* const ctx = getCurrentContext(); 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (renderbuffers) 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < n; ndx++) 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderbuffers[ndx] = ctx->renderbuffers.allocate(); 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4243c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL void GLW_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers) 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context* const ctx = getCurrentContext(); 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (framebuffers) 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < n; ndx++) 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry framebuffers[ndx] = ctx->framebuffers.allocate(); 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4353c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL void GLW_APIENTRY glGenVertexArrays (GLsizei n, GLuint* arrays) 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context* const ctx = getCurrentContext(); 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (arrays) 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < n; ndx++) 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry arrays[ndx] = ctx->vertexArrays.allocate(); 4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4463c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL void GLW_APIENTRY glGenSamplers (GLsizei count, GLuint* samplers) 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context* const ctx = getCurrentContext(); 4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (samplers) 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < count; ndx++) 4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry samplers[ndx] = ctx->samplers.allocate(); 4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4573c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL void GLW_APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint* ids) 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context* const ctx = getCurrentContext(); 4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (ids) 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < n; ndx++) 4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ids[ndx] = ctx->transformFeedbacks.allocate(); 4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4683c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL void GLW_APIENTRY glGenProgramPipelines (GLsizei n, GLuint* pipelines) 4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context* const ctx = getCurrentContext(); 4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (pipelines) 4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < n; ndx++) 4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pipelines[ndx] = ctx->programPipelines.allocate(); 4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4793c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL GLvoid* GLW_APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) 4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context* const ctx = getCurrentContext(); 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(target); 4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(offset); 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(length); 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(access); 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (ctx->lastError == GL_NO_ERROR) 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx->lastError = GL_INVALID_OPERATION; 4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return (GLvoid*)0; 4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4943c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL GLenum GLW_APIENTRY glCheckFramebufferStatus (GLenum target) 4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(target); 4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return GL_FRAMEBUFFER_COMPLETE; 4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5003c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL void GLW_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels) 5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(x); 5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(y); 5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context* const ctx = getCurrentContext(); 5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 clearColor (0.0f, 0.0f, 0.0f, 1.0f); // black 5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::TextureFormat transferFormat = glu::mapGLTransferFormat(format, type); 5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // invalid formats 5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (transferFormat.order == TextureFormat::CHANNELORDER_LAST || transferFormat.type == TextureFormat::CHANNELTYPE_LAST) 5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (ctx->lastError == GL_NO_ERROR) 5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx->lastError = GL_INVALID_ENUM; 5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // unsupported formats 5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!(format == GL_RGBA && type == GL_UNSIGNED_BYTE) && 5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry !(format == GL_RGBA_INTEGER && type == GL_INT) && 5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry !(format == GL_RGBA_INTEGER && type == GL_UNSIGNED_INT) && 5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry !(format == GL_RGBA && type == GL_FLOAT)) 5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (ctx->lastError == GL_NO_ERROR) 5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx->lastError = GL_INVALID_ENUM; 5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // invalid arguments 5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (width < 0 || height < 0) 5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (ctx->lastError == GL_NO_ERROR) 5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx->lastError = GL_INVALID_OPERATION; 5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // read to buffer 5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (ctx->pixelPackBufferBufferBinding) 5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // read to use pointer 5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int targetRowLength = (ctx->pixelPackRowLength != 0) ? (ctx->pixelPackRowLength) : (width); 5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int targetSkipRows = ctx->pixelPackSkipRows; 5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int targetSkipPixels = ctx->pixelPackSkipPixels; 5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int infiniteHeight = targetSkipRows + height; // as much as needed 5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int targetRowPitch = (ctx->pixelPackAlignment == 0) ? (targetRowLength * transferFormat.getPixelSize()) : (deAlign32(targetRowLength * transferFormat.getPixelSize(), ctx->pixelPackAlignment)); 5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Create access to the whole copy target 5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::PixelBufferAccess targetAccess (transferFormat, targetRowLength, infiniteHeight, 1, targetRowPitch, 0, pixels); 5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Select (skip_pixels, skip_rows, width, height) subregion from it. Clip to horizontal boundaries 5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::PixelBufferAccess targetRectAccess = tcu::getSubregion(targetAccess, 5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::clamp(targetSkipPixels, 0, targetAccess.getWidth()-1), 5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry targetSkipRows, 5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::clamp(width, 0, de::max(0, targetAccess.getWidth() - targetSkipPixels)), 5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry height); 5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::clear(targetRectAccess, clearColor); 5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5623c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL void GLW_APIENTRY glBindBuffer (GLenum target, GLuint buffer) 5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context* const ctx = getCurrentContext(); 5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (target == GL_PIXEL_PACK_BUFFER) 5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx->pixelPackBufferBufferBinding = buffer; 5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5703c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLW_APICALL void GLW_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers) 5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Context* const ctx = getCurrentContext(); 5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (GLsizei ndx = 0; ndx < n; ++ndx) 5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (buffers[ndx] && buffers[ndx] == ctx->pixelPackBufferBufferBinding) 5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx->pixelPackBufferBufferBinding = 0; 5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuNullRenderContextFuncs.inl" 5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid initFunctions (glw::Functions* gl) 5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry# include "tcuNullRenderContextInitFuncs.inl" 5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic tcu::RenderTarget toRenderTarget (const RenderConfig& renderCfg) 5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int width = getValueOrDefault(renderCfg, &RenderConfig::width, 256); 5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int height = getValueOrDefault(renderCfg, &RenderConfig::height, 256); 5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int redBits = getValueOrDefault(renderCfg, &RenderConfig::redBits, 8); 5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int greenBits = getValueOrDefault(renderCfg, &RenderConfig::greenBits, 8); 5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int blueBits = getValueOrDefault(renderCfg, &RenderConfig::blueBits, 8); 5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int alphaBits = getValueOrDefault(renderCfg, &RenderConfig::alphaBits, 8); 5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int depthBits = getValueOrDefault(renderCfg, &RenderConfig::depthBits, 24); 5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int stencilBits = getValueOrDefault(renderCfg, &RenderConfig::stencilBits, 8); 5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numSamples = getValueOrDefault(renderCfg, &RenderConfig::numSamples, 0); 5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return tcu::RenderTarget(width, height, tcu::PixelFormat(redBits, greenBits, blueBits, alphaBits), depthBits, stencilBits, numSamples); 5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6013c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRenderContext::RenderContext (const RenderConfig& renderCfg) 6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : m_ctxType (renderCfg.type) 6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderTarget (toRenderTarget(renderCfg)) 6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_context (DE_NULL) 6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context = new Context(m_ctxType); 6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry initFunctions(&m_functions); 6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry setCurrentContext(m_context); 6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6123c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRenderContext::~RenderContext (void) 6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry setCurrentContext(DE_NULL); 6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_context; 6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RenderContext::postIterate (void) 6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // null 6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // tcu 624