gles2_cmd_format.h revision f8ee788a64d60abd8f2d742a5fdedde054ecd910
11830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com// Copyright (c) 2012 The Chromium Authors. All rights reserved. 21830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com// Use of this source code is governed by a BSD-style license that can be 31830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com// found in the LICENSE file. 41830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com 51830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com// This file defines the GLES2 command buffer commands. 61830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com 7bf0001d0472d727266762c5967ec0d919a6df083reed@google.com#ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H_ 81830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com#define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H_ 91830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com 101830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com 111830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com#include <KHR/khrplatform.h> 121830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com 131830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com#include <stdint.h> 141830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com#include <string.h> 15796763e0b2c06a7789185322561a1135e5484688djsollen@google.com 161830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com#include "base/atomicops.h" 171830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com#include "base/logging.h" 18770963f23f4fc313db0fa3bac18b1b8aafb55f17robertphillips@google.com#include "base/macros.h" 191830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com#include "gpu/command_buffer/common/bitfield_helpers.h" 201830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com#include "gpu/command_buffer/common/cmd_buffer_common.h" 211830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com#include "gpu/command_buffer/common/gles2_cmd_ids.h" 221830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com 231830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com// GL types are forward declared to avoid including the GL headers. The problem 241830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com// is determining which GL headers to include from code that is common to the 251830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com// client and service sides (GLES2 or one of several GL implementations). 261830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.comtypedef unsigned int GLenum; 271830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.comtypedef unsigned int GLbitfield; 281830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.comtypedef unsigned int GLuint; 291830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.comtypedef int GLint; 30636d87a3f411507020a21c6b0641da795eb5d275reed@google.comtypedef int GLsizei; 311830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.comtypedef unsigned char GLboolean; 321830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.comtypedef signed char GLbyte; 331830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.comtypedef short GLshort; 34bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.orgtypedef unsigned char GLubyte; 35bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.orgtypedef unsigned short GLushort; 36bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.orgtypedef unsigned long GLulong; 37bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.orgtypedef float GLfloat; 38bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.orgtypedef float GLclampf; 399a65e2c22dc3f0d4823520ab3d561f57ff09198cfmalita@google.comtypedef double GLdouble; 40bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.orgtypedef double GLclampd; 41bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.orgtypedef void GLvoid; 42bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.orgtypedef khronos_intptr_t GLintptr; 43bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.orgtypedef khronos_ssize_t GLsizeiptr; 44bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org 459a65e2c22dc3f0d4823520ab3d561f57ff09198cfmalita@google.comnamespace gpu { 46bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.orgnamespace gles2 { 47bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org 48bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org// Command buffer is GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT byte aligned. 49bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org#pragma pack(push, GPU_COMMAND_BUFFER_ENTRY_ALIGNMENT) 50bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org 51bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.orgnamespace id_namespaces { 52bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org 53bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org// These are used when contexts share resources. 54bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.orgenum IdNamespaces { 55bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org kBuffers, 56bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org kFramebuffers, 57bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org kProgramsAndShaders, 58bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org kRenderbuffers, 59bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org kTextures, 60bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org kQueries, 61bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org kVertexArrays, 62bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org kNumIdNamespaces 63bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org}; 64c22d1398089fdb95480fb3459b23e4931e4f5280commit-bot@chromium.org 65c22d1398089fdb95480fb3459b23e4931e4f5280commit-bot@chromium.org// These numbers must not change 66c22d1398089fdb95480fb3459b23e4931e4f5280commit-bot@chromium.orgCOMPILE_ASSERT(kBuffers == 0, kBuffers_is_not_0); 67c22d1398089fdb95480fb3459b23e4931e4f5280commit-bot@chromium.orgCOMPILE_ASSERT(kFramebuffers == 1, kFramebuffers_is_not_1); 68c22d1398089fdb95480fb3459b23e4931e4f5280commit-bot@chromium.orgCOMPILE_ASSERT(kProgramsAndShaders == 2, kProgramsAndShaders_is_not_2); 69c22d1398089fdb95480fb3459b23e4931e4f5280commit-bot@chromium.orgCOMPILE_ASSERT(kRenderbuffers == 3, kRenderbuffers_is_not_3); 70c22d1398089fdb95480fb3459b23e4931e4f5280commit-bot@chromium.orgCOMPILE_ASSERT(kTextures == 4, kTextures_is_not_4); 71c22d1398089fdb95480fb3459b23e4931e4f5280commit-bot@chromium.org 72c22d1398089fdb95480fb3459b23e4931e4f5280commit-bot@chromium.org} // namespace id_namespaces 73c22d1398089fdb95480fb3459b23e4931e4f5280commit-bot@chromium.org 74c22d1398089fdb95480fb3459b23e4931e4f5280commit-bot@chromium.org// Used for some glGetXXX commands that return a result through a pointer. We 75c22d1398089fdb95480fb3459b23e4931e4f5280commit-bot@chromium.org// need to know if the command succeeded or not and the size of the result. If 76c22d1398089fdb95480fb3459b23e4931e4f5280commit-bot@chromium.org// the command failed its result size will 0. 77c22d1398089fdb95480fb3459b23e4931e4f5280commit-bot@chromium.orgtemplate <typename T> 78c22d1398089fdb95480fb3459b23e4931e4f5280commit-bot@chromium.orgstruct SizedResult { 79c22d1398089fdb95480fb3459b23e4931e4f5280commit-bot@chromium.org typedef T Type; 80bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org 81bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org T* GetData() { 82bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org return static_cast<T*>(static_cast<void*>(&data)); 83bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org } 84bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org 85bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org // Returns the total size in bytes of the SizedResult for a given number of 86bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org // results including the size field. 87bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org static size_t ComputeSize(size_t num_results) { 88bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org return sizeof(T) * num_results + sizeof(uint32_t); // NOLINT 89bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org } 90bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org 91bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org // Returns the total size in bytes of the SizedResult for a given size of 92bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org // results. 93bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org static size_t ComputeSizeFromBytes(size_t size_of_result_in_bytes) { 94bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org return size_of_result_in_bytes + sizeof(uint32_t); // NOLINT 95bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org } 968c6f4b3261fde699f17016e289aa6aceee4ea63acommit-bot@chromium.org 97bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org // Returns the maximum number of results for a given buffer size. 98bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org static uint32_t ComputeMaxResults(size_t size_of_buffer) { 99bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org return (size_of_buffer >= sizeof(uint32_t)) ? 100bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org ((size_of_buffer - sizeof(uint32_t)) / sizeof(T)) : 0; // NOLINT 101bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org } 102bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org 1039b14f26d0f3a974f3dd626c8354e1db1cfcd322frobertphillips // Set the size for a given number of results. 104bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org void SetNumResults(size_t num_results) { 105bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org size = sizeof(T) * num_results; // NOLINT 106bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org } 107bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org 108bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org // Get the number of elements in the result 109bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org int32_t GetNumResults() const { 110c22d1398089fdb95480fb3459b23e4931e4f5280commit-bot@chromium.org return size / sizeof(T); // NOLINT 111bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org } 112bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org 113bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org // Copy the result. 114bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org void CopyResult(void* dst) const { 115bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org memcpy(dst, &data, size); 116e6a98d4259532d2f1d899131b72c6c4cd58f2903fmalita@google.com } 117bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org 1181830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com uint32_t size; // in bytes. 119bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org int32_t data; // this is just here to get an offset. 120bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org}; 121bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org 122ae933ce0ea5fd9d21cb6ef2cee7e729d32690aacrmistry@google.comCOMPILE_ASSERT(sizeof(SizedResult<int8_t>) == 8, SizedResult_size_not_8); 123bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.orgCOMPILE_ASSERT(offsetof(SizedResult<int8_t>, size) == 0, 12484b18c7e3e042bf206e1ace3d1b6ea5bb929fe51robertphillips@google.com OffsetOf_SizedResult_size_not_0); 125b196374e6f5b66ba911a2be6ddb31c6692a3615areed@google.comCOMPILE_ASSERT(offsetof(SizedResult<int8_t>, data) == 4, 126b196374e6f5b66ba911a2be6ddb31c6692a3615areed@google.com OffsetOf_SizedResult_data_not_4); 127b196374e6f5b66ba911a2be6ddb31c6692a3615areed@google.com 128b196374e6f5b66ba911a2be6ddb31c6692a3615areed@google.com// The data for one attrib or uniform from GetProgramInfoCHROMIUM. 12984b18c7e3e042bf206e1ace3d1b6ea5bb929fe51robertphillips@google.comstruct ProgramInput { 1305fb2ce38b3dcb8e60e9e112df23c9d42456d7069commit-bot@chromium.org uint32_t type; // The type (GL_VEC3, GL_MAT3, GL_SAMPLER_2D, etc. 131b196374e6f5b66ba911a2be6ddb31c6692a3615areed@google.com int32_t size; // The size (how big the array is for uniforms) 13284b18c7e3e042bf206e1ace3d1b6ea5bb929fe51robertphillips@google.com uint32_t location_offset; // offset from ProgramInfoHeader to 'size' 133b196374e6f5b66ba911a2be6ddb31c6692a3615areed@google.com // locations for uniforms, 1 for attribs. 134b196374e6f5b66ba911a2be6ddb31c6692a3615areed@google.com uint32_t name_offset; // offset from ProgrmaInfoHeader to start of name. 135b196374e6f5b66ba911a2be6ddb31c6692a3615areed@google.com uint32_t name_length; // length of the name. 13684b18c7e3e042bf206e1ace3d1b6ea5bb929fe51robertphillips@google.com}; 137b8b830e012d5009bc2ac195f2ac5309f8ae7bb4areed@google.com 138b8b830e012d5009bc2ac195f2ac5309f8ae7bb4areed@google.com// The format of the bucket filled out by GetProgramInfoCHROMIUM 139b196374e6f5b66ba911a2be6ddb31c6692a3615areed@google.comstruct ProgramInfoHeader { 14011f869277c81a232fd4e40eca41e6f71b95b4b17skia.committer@gmail.com uint32_t link_status; 141636d87a3f411507020a21c6b0641da795eb5d275reed@google.com uint32_t num_attribs; 142636d87a3f411507020a21c6b0641da795eb5d275reed@google.com uint32_t num_uniforms; 1439b14f26d0f3a974f3dd626c8354e1db1cfcd322frobertphillips // ProgramInput inputs[num_attribs + num_uniforms]; 144636d87a3f411507020a21c6b0641da795eb5d275reed@google.com}; 145636d87a3f411507020a21c6b0641da795eb5d275reed@google.com 1460a5c18ba79862ee4a348eff42cd4fbeb5ef12feereed@google.com// The format of QuerySync used by EXT_occlusion_query_boolean 14784b18c7e3e042bf206e1ace3d1b6ea5bb929fe51robertphillips@google.comstruct QuerySync { 1485fb2ce38b3dcb8e60e9e112df23c9d42456d7069commit-bot@chromium.org void Reset() { 14984b18c7e3e042bf206e1ace3d1b6ea5bb929fe51robertphillips@google.com process_count = 0; 15011f869277c81a232fd4e40eca41e6f71b95b4b17skia.committer@gmail.com result = 0; 1510a5c18ba79862ee4a348eff42cd4fbeb5ef12feereed@google.com } 1520a5c18ba79862ee4a348eff42cd4fbeb5ef12feereed@google.com 1530a5c18ba79862ee4a348eff42cd4fbeb5ef12feereed@google.com base::subtle::Atomic32 process_count; 15484b18c7e3e042bf206e1ace3d1b6ea5bb929fe51robertphillips@google.com uint64_t result; 1550a5c18ba79862ee4a348eff42cd4fbeb5ef12feereed@google.com}; 156b196374e6f5b66ba911a2be6ddb31c6692a3615areed@google.com 157796763e0b2c06a7789185322561a1135e5484688djsollen@google.comstruct AsyncUploadSync { 15884b18c7e3e042bf206e1ace3d1b6ea5bb929fe51robertphillips@google.com void Reset() { 159bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org base::subtle::Release_Store(&async_upload_token, 0); 160796763e0b2c06a7789185322561a1135e5484688djsollen@google.com } 161ae933ce0ea5fd9d21cb6ef2cee7e729d32690aacrmistry@google.com 1625fb2ce38b3dcb8e60e9e112df23c9d42456d7069commit-bot@chromium.org void SetAsyncUploadToken(uint32_t token) { 163bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org DCHECK_NE(token, 0u); 164bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org base::subtle::Release_Store(&async_upload_token, token); 165bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org } 16684b18c7e3e042bf206e1ace3d1b6ea5bb929fe51robertphillips@google.com 167bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org bool HasAsyncUploadTokenPassed(uint32_t token) { 1685fb2ce38b3dcb8e60e9e112df23c9d42456d7069commit-bot@chromium.org DCHECK_NE(token, 0u); 169bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org uint32_t current_token = base::subtle::Acquire_Load(&async_upload_token); 170c22d1398089fdb95480fb3459b23e4931e4f5280commit-bot@chromium.org return (current_token - token < 0x80000000); 1715fb2ce38b3dcb8e60e9e112df23c9d42456d7069commit-bot@chromium.org } 172c22d1398089fdb95480fb3459b23e4931e4f5280commit-bot@chromium.org 173bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org base::subtle::Atomic32 async_upload_token; 174bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org}; 1755fb2ce38b3dcb8e60e9e112df23c9d42456d7069commit-bot@chromium.org 176bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.orgCOMPILE_ASSERT(sizeof(ProgramInput) == 20, ProgramInput_size_not_20); 177bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.orgCOMPILE_ASSERT(offsetof(ProgramInput, type) == 0, 178bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org OffsetOf_ProgramInput_type_not_0); 1795fb2ce38b3dcb8e60e9e112df23c9d42456d7069commit-bot@chromium.orgCOMPILE_ASSERT(offsetof(ProgramInput, size) == 4, 18084b18c7e3e042bf206e1ace3d1b6ea5bb929fe51robertphillips@google.com OffsetOf_ProgramInput_size_not_4); 18184b18c7e3e042bf206e1ace3d1b6ea5bb929fe51robertphillips@google.comCOMPILE_ASSERT(offsetof(ProgramInput, location_offset) == 8, 182bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.org OffsetOf_ProgramInput_location_offset_not_8); 183bbe43a9ce0513d37cbd5dca583c391b7b1e39b3acommit-bot@chromium.orgCOMPILE_ASSERT(offsetof(ProgramInput, name_offset) == 12, 1841830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com OffsetOf_ProgramInput_name_offset_not_12); 185ae933ce0ea5fd9d21cb6ef2cee7e729d32690aacrmistry@google.comCOMPILE_ASSERT(offsetof(ProgramInput, name_length) == 16, 1865fb2ce38b3dcb8e60e9e112df23c9d42456d7069commit-bot@chromium.org OffsetOf_ProgramInput_name_length_not_16); 1875fb2ce38b3dcb8e60e9e112df23c9d42456d7069commit-bot@chromium.org 18884b18c7e3e042bf206e1ace3d1b6ea5bb929fe51robertphillips@google.comCOMPILE_ASSERT(sizeof(ProgramInfoHeader) == 12, ProgramInfoHeader_size_not_12); 1891830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.comCOMPILE_ASSERT(offsetof(ProgramInfoHeader, link_status) == 0, 190ae933ce0ea5fd9d21cb6ef2cee7e729d32690aacrmistry@google.com OffsetOf_ProgramInfoHeader_link_status_not_0); 1911830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.comCOMPILE_ASSERT(offsetof(ProgramInfoHeader, num_attribs) == 4, 1921830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com OffsetOf_ProgramInfoHeader_num_attribs_not_4); 1931830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.comCOMPILE_ASSERT(offsetof(ProgramInfoHeader, num_uniforms) == 8, 1941830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com OffsetOf_ProgramInfoHeader_num_uniforms_not_8); 1951830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com 1961830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.comnamespace cmds { 1971830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com 1981830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com#include "../common/gles2_cmd_format_autogen.h" 1991830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com 2001830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com// These are hand written commands. 2011830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com// TODO(gman): Attempt to make these auto-generated. 2021830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.comstruct GetAttribLocation { 2031830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com typedef GetAttribLocation ValueType; 2041830c7aa3c4045af438fb24ee0bd22598f1bfca7reed@google.com static const CommandId kCmdId = kGetAttribLocation; 205 static const cmd::ArgFlags kArgFlags = cmd::kFixed; 206 static const uint8 cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3); 207 208 typedef GLint Result; 209 210 static uint32 ComputeSize() { 211 return static_cast<uint32>(sizeof(ValueType)); // NOLINT 212 } 213 214 void SetHeader() { 215 header.SetCmd<ValueType>(); 216 } 217 218 void Init( 219 GLuint _program, uint32 _name_bucket_id, 220 uint32 _location_shm_id, uint32 _location_shm_offset) { 221 SetHeader(); 222 program = _program; 223 name_bucket_id = _name_bucket_id; 224 location_shm_id = _location_shm_id; 225 location_shm_offset = _location_shm_offset; 226 } 227 228 void* Set( 229 void* cmd, GLuint _program, uint32 _name_bucket_id, 230 uint32 _location_shm_id, uint32 _location_shm_offset) { 231 static_cast<ValueType*>( 232 cmd)->Init( 233 _program, _name_bucket_id, _location_shm_id, 234 _location_shm_offset); 235 return NextCmdAddress<ValueType>(cmd); 236 } 237 238 CommandHeader header; 239 uint32 program; 240 uint32 name_bucket_id; 241 uint32 location_shm_id; 242 uint32 location_shm_offset; 243}; 244 245COMPILE_ASSERT(sizeof(GetAttribLocation) == 20, 246 Sizeof_GetAttribLocation_is_not_24); 247COMPILE_ASSERT(offsetof(GetAttribLocation, header) == 0, 248 OffsetOf_GetAttribLocation_header_not_0); 249COMPILE_ASSERT(offsetof(GetAttribLocation, program) == 4, 250 OffsetOf_GetAttribLocation_program_not_4); 251COMPILE_ASSERT(offsetof(GetAttribLocation, name_bucket_id) == 8, 252 OffsetOf_GetAttribLocation_name_bucket_id_not_8); 253COMPILE_ASSERT(offsetof(GetAttribLocation, location_shm_id) == 12, 254 OffsetOf_GetAttribLocation_location_shm_id_not_12); 255COMPILE_ASSERT(offsetof(GetAttribLocation, location_shm_offset) == 16, 256 OffsetOf_GetAttribLocation_location_shm_offset_not_16); 257 258struct GetUniformLocation { 259 typedef GetUniformLocation ValueType; 260 static const CommandId kCmdId = kGetUniformLocation; 261 static const cmd::ArgFlags kArgFlags = cmd::kFixed; 262 static const uint8 cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3); 263 264 typedef GLint Result; 265 266 static uint32 ComputeSize() { 267 return static_cast<uint32>(sizeof(ValueType)); // NOLINT 268 } 269 270 void SetHeader() { 271 header.SetCmd<ValueType>(); 272 } 273 274 void Init( 275 GLuint _program, uint32 _name_bucket_id, 276 uint32 _location_shm_id, uint32 _location_shm_offset) { 277 SetHeader(); 278 program = _program; 279 name_bucket_id = _name_bucket_id; 280 location_shm_id = _location_shm_id; 281 location_shm_offset = _location_shm_offset; 282 } 283 284 void* Set( 285 void* cmd, GLuint _program, uint32 _name_bucket_id, 286 uint32 _location_shm_id, uint32 _location_shm_offset) { 287 static_cast<ValueType*>( 288 cmd)->Init( 289 _program, _name_bucket_id, _location_shm_id, 290 _location_shm_offset); 291 return NextCmdAddress<ValueType>(cmd); 292 } 293 294 CommandHeader header; 295 uint32 program; 296 uint32 name_bucket_id; 297 uint32 location_shm_id; 298 uint32 location_shm_offset; 299}; 300 301COMPILE_ASSERT(sizeof(GetUniformLocation) == 20, 302 Sizeof_GetUniformLocation_is_not_24); 303COMPILE_ASSERT(offsetof(GetUniformLocation, header) == 0, 304 OffsetOf_GetUniformLocation_header_not_0); 305COMPILE_ASSERT(offsetof(GetUniformLocation, program) == 4, 306 OffsetOf_GetUniformLocation_program_not_4); 307COMPILE_ASSERT(offsetof(GetUniformLocation, name_bucket_id) == 8, 308 OffsetOf_GetUniformLocation_name_bucket_id_not_8); 309COMPILE_ASSERT(offsetof(GetUniformLocation, location_shm_id) == 12, 310 OffsetOf_GetUniformLocation_location_shm_id_not_12); 311COMPILE_ASSERT(offsetof(GetUniformLocation, location_shm_offset) == 16, 312 OffsetOf_GetUniformLocation_location_shm_offset_not_16); 313 314struct GenMailboxCHROMIUM { 315 typedef GenMailboxCHROMIUM ValueType; 316 static const CommandId kCmdId = kGenMailboxCHROMIUM; 317 static const cmd::ArgFlags kArgFlags = cmd::kFixed; 318 static const uint8 cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3); 319 CommandHeader header; 320}; 321 322struct InsertSyncPointCHROMIUM { 323 typedef InsertSyncPointCHROMIUM ValueType; 324 static const CommandId kCmdId = kInsertSyncPointCHROMIUM; 325 static const cmd::ArgFlags kArgFlags = cmd::kFixed; 326 static const uint8 cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3); 327 CommandHeader header; 328}; 329 330struct CreateAndConsumeTextureCHROMIUMImmediate { 331 typedef CreateAndConsumeTextureCHROMIUMImmediate ValueType; 332 static const CommandId kCmdId = kCreateAndConsumeTextureCHROMIUMImmediate; 333 static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; 334 static const uint8 cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(1); 335 336 static uint32_t ComputeDataSize() { 337 return static_cast<uint32_t>(sizeof(GLbyte) * 64); // NOLINT 338 } 339 340 static uint32_t ComputeSize() { 341 return static_cast<uint32_t>(sizeof(ValueType) + 342 ComputeDataSize()); // NOLINT 343 } 344 345 void SetHeader(uint32_t size_in_bytes) { 346 header.SetCmdByTotalSize<ValueType>(size_in_bytes); 347 } 348 349 void Init(GLenum _target, uint32_t _client_id, const GLbyte* _mailbox) { 350 SetHeader(ComputeSize()); 351 target = _target; 352 client_id = _client_id; 353 memcpy(ImmediateDataAddress(this), _mailbox, ComputeDataSize()); 354 } 355 356 void* Set(void* cmd, 357 GLenum _target, 358 uint32_t _client_id, 359 const GLbyte* _mailbox) { 360 static_cast<ValueType*>(cmd)->Init(_target, _client_id, _mailbox); 361 const uint32_t size = ComputeSize(); 362 return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); 363 } 364 365 gpu::CommandHeader header; 366 uint32_t target; 367 uint32_t client_id; 368}; 369 370COMPILE_ASSERT(sizeof(CreateAndConsumeTextureCHROMIUMImmediate) == 12, 371 Sizeof_CreateAndConsumeTextureCHROMIUMImmediate_is_not_12); 372COMPILE_ASSERT(offsetof(CreateAndConsumeTextureCHROMIUMImmediate, header) == 0, 373 OffsetOf_CreateAndConsumeTextureCHROMIUMImmediate_header_not_0); 374COMPILE_ASSERT(offsetof(CreateAndConsumeTextureCHROMIUMImmediate, target) == 4, 375 OffsetOf_CreateAndConsumeTextureCHROMIUMImmediate_target_not_4); 376COMPILE_ASSERT( 377 offsetof(CreateAndConsumeTextureCHROMIUMImmediate, client_id) == 8, 378 OffsetOf_CreateAndConsumeTextureCHROMIUMImmediate_client_id_not_8); 379 380 381#pragma pack(pop) 382 383} // namespace cmd 384} // namespace gles2 385} // namespace gpu 386 387#endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H_ 388