diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2013-01-26 00:46:38 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2013-01-26 11:08:10 +0100 |
commit | 27f6235e8020c511c5cfa931370e7ad8d02c7058 (patch) | |
tree | 1c4e73b5dedc944b27b98a667b5ab9697743fc19 | |
parent | 08711adc2b39e4c89f85b0d33894915df390aeec (diff) |
dove/cubox compatiblity preparation
54 files changed, 17505 insertions, 380 deletions
@@ -23,7 +23,7 @@ ARM-based: - Devices based on Freescale i.MX6 Series (GC2000, GC320, GC355) MIPS-based: -- Devices based on Ingenic JZ4770 MIPS SoC (GC860), JZ4760 (GC200, 2D only) +- Devices based on Ingenic JZ4770 MIPS SoC (GC860), JZ4760 (GC200, 2D only) such as the GCW zero. See also https://en.wikipedia.org/wiki/Vivante_Corporation @@ -223,17 +223,53 @@ Then generate the headers with Building ========= -Install the Android NDK and define a native build environment, for example like this: +Android +--------- + +To build for an Android device, install the Android NDK and define the cross-build environment by setting +environment variables, for example like this: export NDK="/opt/ndk" export TOOLCHAIN="/opt/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86" export SYSROOT="/opt/ndk/platforms/android-14/arch-arm" export PATH="$PATH:$TOOLCHAIN/bin" + export GCCPREFIX="arm-linux-androideabi-" + export CXXABI="armeabi-v7a" + export PLATFORM_CFLAGS="--sysroot=${SYSROOT} -DANDROID" + export PLATFORM_CXXFLAGS="--sysroot=${SYSROOT} -DANDROID -I${NDK}/sources/cxx-stl/gnu-libstdc++/4.6/include -I${NDK}/sources/cxx-stl/gnu-libstdc++/4.6/libs/${CXXABI}/include" + export PLATFORM_LDFLAGS="--sysroot=${SYSROOT} -L${NDK}/sources/cxx-stl/gnu-libstdc++/4.6/libs/${CXXABI} -lgnustl_static" + # Set GC kernel ABI to v2 (important!) + export GCABI="v2" + To build the egl samples, you need to copy `libEGL_VIVANTE.so` `libGLESv2_VIVANTE.so` from the device `/system/lib/egl` to `native/lib/egl`. This is not needed if you just want to build the replay or etna tests, which do not rely in any way on the userspace blob. +Linux +------- + +For Linux ARM cross compile, create a script like this (example for CuBox) to set up the build environment. +Don't forget to also copy the EGL/GLES2/KDR headers from some place and put them in a directory `include` under the location +where the script is installed, and get the `libEGL.so` and `libGLESv2.so` from the device into `lib`: + + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + export GCCPREFIX="arm-linux-gnueabi-" + export PLATFORM_CFLAGS="-I${DIR}/include -D_POSIX_C_SOURCE=200809 -D_GNU_SOURCE" + export PLATFORM_CXXFLAGS="-I${DIR}/include -D_POSIX_C_SOURCE=200809 -D_GNU_SOURCE" + export PLATFORM_LDFLAGS="-ldl -L${DIR}/lib" + export PLATFORM_GL_LIBS="-lEGL -lGLESv2 -L${TOP}/lib/egl -Xlinker --allow-shlib-undefined" + # Set GC kernel ABI to dove (important!) + export GCABI="dove" + +If you haven't got the `arm-linux-gnueabi-` bintools, on an Debian/Ubuntu host they can be installed with + + apt-get install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi + +On hardfloat targets you should use `gcc-arm-linux-gnueabihf-` instead. + +General +-------- Run make in `native/replay` and `native/egl` separately. Compatibility diff --git a/doc/hardware.md b/doc/hardware.md index 44f103e..ba1fdbc 100644 --- a/doc/hardware.md +++ b/doc/hardware.md @@ -246,6 +246,34 @@ so in the end it may be slower. XXX this needs to be tested. Usually, there is more framebuffer memory than that which is used for the current screen, which causes larger virtual resolution to be returned than the physical resolution. Double-buffering is achieved by changing the y-offset within that virtual frame buffer. +Operations +======================== +An attempt to figure out which operations can be triggered in the hardware, and what state is used to specify +their operation. + +- RS: Kick off resolve by writing a value with bit 0 set to `RS_KICKER`. State used: + - `RS_*` + - `TS_*` (if fast clear enabled through `TS_CONFIG`) + +- FE: Kick off 3D rendering by sending command `DRAW_PRIMITIVES` / `DRAW_INDEXED_PRIMITIVES` + - `FE_*` (vertex element layout, vertex streams, index stream, ...) + - `GL_*` (varyings setup, multisampling) + - `TS_*` (to read and update fast clear status for tiles) + - `PA_*` primitive assembly + - `SE_*` setup engine + - `RA_*` rasterizer + - `PE_*` pixel engine + - `VS_*` vertex shader code + uniforms + linking information + - `PS_*` pixel shader code + uniforms + linking information + - `(N)TE_*` texture samplers + - `SH_*` extra shader code + uniforms + +- DE: Kick off 2D rendering by sending command `DRAW_2D` + - `DE_*` 2D state + - `FE_*` `GL_*` possibly + +That's all, folks. + Programming pecularities ========================= diff --git a/doc/kernel_interface.md b/doc/kernel_interface.md index 3fe21cc..027df25 100644 --- a/doc/kernel_interface.md +++ b/doc/kernel_interface.md @@ -259,7 +259,7 @@ Used fields in `struct _gcoCONTEXT` from the kernel: [in] This id is used to determine wether to switch context [out] A unique id for the context is generated the first time a COMMIT is done, with context->id==0 - `hint*` only used when `SECURE_USER` is set -- `logical` and `bufferSize` +- `logical` and `bufferSize` (note: `physical` is not used; the dove version of the driver doesn't even have this field in the default configuration) - `pipe2DIndex`: if this is set, "we have to check pipes", and the pipe is set to initialPipe if needed - `entryPipe`: this is the pipe that has to be active on entering the passed command buffer (and that holds at the end of the context buffer) - `initialPipe`: this is the pipe that has to be active on entering the context command buffer diff --git a/native/Makefile.inc b/native/Makefile.inc index 1cbb1f0..defd8eb 100644 --- a/native/Makefile.inc +++ b/native/Makefile.inc @@ -1,22 +1,12 @@ -TOOLCHAIN ?= ~/android/toolchain -SDK ?= ~/android/android-sdk-linux/ -NDK ?= ~/android/ndk -ANDROID_TARGET ?= android-10 -ANDROID_TARGET_NDK ?= android-9 -SYSROOT ?= $(TOOLCHAIN)/sysroot/ -CXXABI ?= armeabi-v7a +GCABI ?= v2 +PLATFORM_GL_LIBS ?= -lEGL_VIVANTE -lGLESv2_VIVANTE -L$(TOP)/lib/egl -Xlinker --allow-shlib-undefined -CC = $(TOOLCHAIN)/bin/arm-linux-androideabi-gcc -CXX = $(TOOLCHAIN)/bin/arm-linux-androideabi-g++ -LD = $(TOOLCHAIN)/bin/arm-linux-androideabi-ld -AR = $(TOOLCHAIN)/bin/arm-linux-androideabi-ar -ADB = $(SDK)/platform-tools/adb +CC = $(GCCPREFIX)gcc +CXX = $(GCCPREFIX)g++ +LD = $(GCCPREFIX)ld +AR = $(GCCPREFIX)ar -SYSTEM = android -ARCH = arm - -CFLAGS += --sysroot=$(SYSROOT) -O2 -g -Wall -CXXFLAGS += --sysroot=$(SYSROOT) -O2 -g -Wall -LDFLAGS += --sysroot=$(SYSROOT) -#-nodefaultlibs +CFLAGS += $(PLATFORM_CFLAGS) -O2 -g -Wall +CXXFLAGS += $(PLATFORM_CXXFLAGS) -O2 -g -Wall +LDFLAGS += $(PLATFORM_LDFLAGS) diff --git a/native/egl/.gitignore b/native/egl/.gitignore index 515b2d8..5435999 100644 --- a/native/egl/.gitignore +++ b/native/egl/.gitignore @@ -3,4 +3,5 @@ cube_companion ps_sandbox eglinfo cube_companion_idx +cube_x11 diff --git a/native/egl/Makefile b/native/egl/Makefile index 0f5dab1..5e008ea 100644 --- a/native/egl/Makefile +++ b/native/egl/Makefile @@ -2,13 +2,13 @@ TOP=.. include $(TOP)/Makefile.inc -COMMON_FLAGS = -I../lib -I../resources -I$(TOP)/include_v2 -g -std=c99 -fPIC +COMMON_FLAGS = -I../lib -I../resources -I$(TOP)/include_$(GCABI) -g -std=c99 -fPIC CFLAGS += $(COMMON_FLAGS) -CXXFLAGS += $(COMMON_FLAGS) -I$(NDK)/sources/cxx-stl/gnu-libstdc++/4.6/include -I$(NDK)/sources/cxx-stl/gnu-libstdc++/4.6/libs/$(CXXABI)/include -LDFLAGS += -L$(NDK)/sources/cxx-stl/gnu-libstdc++/4.6/libs/$(CXXABI) -lgnustl_static +CXXFLAGS += $(COMMON_FLAGS) +LDFLAGS += -lm +GL_LIBS = $(PLATFORM_GL_LIBS) TARGETS = cube cube_companion ps_sandbox eglinfo cube_companion_idx -GL_LIBS = -lEGL_VIVANTE -lGLESv2_VIVANTE -L$(TOP)/lib -L$(TOP)/lib/egl -Xlinker --allow-shlib-undefined -lm LIB_OBJS = ../lib/esTransform.o ../lib/elf_hook.o ../lib/flightrecorder.o ../lib/viv_hook.o ../lib/write_bmp.o ../lib/dump_gl_screen.o ../lib/eglutil.o COMPANION_OBJS = ../resources/companion_array.o ../resources/companion_mesh.o ../resources/companion_texture.o @@ -16,11 +16,14 @@ all: $(TARGETS) clean: rm -f *.o ../lib/*.o - rm -f $(TARGETS) + rm -f $(TARGETS) ${COMPANION_OBJS} cube: cube.o $(LIB_OBJS) $(CXX) $(CFLAGS) -o $@ $^ $(GL_LIBS) $(LDFLAGS) +cube_x11: cube_x11.o ../lib/esUtil.o $(LIB_OBJS) + $(CXX) $(CFLAGS) -o $@ $^ $(GL_LIBS) $(LDFLAGS) -lX11 + cube_companion: cube_companion.o $(LIB_OBJS) $(COMPANION_OBJS) $(CXX) $(CFLAGS) -o $@ $^ $(GL_LIBS) $(LDFLAGS) diff --git a/native/egl/cube.c b/native/egl/cube.c index f7cebda..3df23be 100644 --- a/native/egl/cube.c +++ b/native/egl/cube.c @@ -20,7 +20,10 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ +#define HOOK + #include <stdio.h> +#include <stdlib.h> #include <unistd.h> #include <stdbool.h> #include <EGL/egl.h> @@ -32,7 +35,8 @@ #include <sys/mman.h> #include <stdarg.h> -#include "esUtil.h" +#include "esTransform.h" +#include "eglutil.h" #include "dump_gl_screen.h" #include "viv_hook.h" @@ -71,8 +75,9 @@ int main(int argc, char *argv[]) GLuint program; GLint ret; GLint width, height; - +#ifdef HOOK the_hook("/mnt/sdcard/egl2.fdr"); +#endif const char *vertex_shader_source = "uniform mat4 modelviewMatrix;\n" @@ -249,6 +254,7 @@ int main(int argc, char *argv[]) return -1; } printf("PBuffer: %dx%d\n", width, height); + printf("GL Extensions \"%s\"\n", glGetString(GL_EXTENSIONS)); /* connect the context to the surface */ if (!eglMakeCurrent(display, surface, surface, context)) { @@ -426,7 +432,9 @@ int main(int argc, char *argv[]) fflush(stdout); dump_gl_screen("/sdcard/egl2.bmp", width, height); +#ifdef HOOK close_hook(); +#endif return 0; } diff --git a/native/egl/cube_companion.c b/native/egl/cube_companion.c index 656f2c1..e88ab8f 100644 --- a/native/egl/cube_companion.c +++ b/native/egl/cube_companion.c @@ -29,7 +29,7 @@ #include <EGL/egl.h> #include <GLES2/gl2.h> -#include "esUtil.h" +#include "esTransform.h" #include "companion.h" #include "dump_gl_screen.h" #include "viv_hook.h" diff --git a/native/egl/cube_companion_idx.c b/native/egl/cube_companion_idx.c index 89c6548..94294e4 100644 --- a/native/egl/cube_companion_idx.c +++ b/native/egl/cube_companion_idx.c @@ -29,7 +29,7 @@ #include <EGL/egl.h> #include <GLES2/gl2.h> -#include "esUtil.h" +#include "esTransform.h" #include "eglutil.h" #include "companion.h" #include "dump_gl_screen.h" diff --git a/native/egl/cube_x11.c b/native/egl/cube_x11.c new file mode 100644 index 0000000..6ab3ca8 --- /dev/null +++ b/native/egl/cube_x11.c @@ -0,0 +1,407 @@ +/* + * Copyright (c) 2011-2012 Luc Verhaegen <libv@codethink.co.uk> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/* Windowed cube... */ +#define HOOK + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <stdbool.h> +#include <EGL/egl.h> +#include <GLES2/gl2.h> +#include <dlfcn.h> +#include <fcntl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/mman.h> +#include <stdarg.h> + +#include "esUtil.h" +#include "esTransform.h" +#include "eglutil.h" +#include "dump_gl_screen.h" +#include "viv_hook.h" + +static EGLint const config_attribute_list[] = { + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_DEPTH_SIZE, 8, + EGL_NONE +}; + +static EGLint const pbuffer_attribute_list[] = { + EGL_WIDTH, 400, + EGL_HEIGHT, 240, + EGL_LARGEST_PBUFFER, EGL_TRUE, + EGL_NONE +}; + +static const EGLint context_attribute_list[] = { + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_NONE +}; + + +typedef struct +{ + GLuint program; + int frames; +} UserData; + +int Init ( ESContext *esContext ) +{ + esContext->userData = malloc(sizeof(UserData)); + + UserData *userData = esContext->userData; + GLuint vertex_shader; + GLuint fragment_shader; + GLuint program; + GLint ret=0; + + userData->frames = 0; + + const char *vertex_shader_source = + "uniform mat4 modelviewMatrix;\n" + "uniform mat4 modelviewprojectionMatrix;\n" + "uniform mat3 normalMatrix;\n" + "\n" + "attribute vec4 in_position; \n" + "attribute vec3 in_normal; \n" + "attribute vec4 in_color; \n" + "\n" + "vec4 lightSource = vec4(2.0, 2.0, 20.0, 0.0);\n" + " \n" + "varying vec4 vVaryingColor; \n" + " \n" + "void main() \n" + "{ \n" + " gl_Position = modelviewprojectionMatrix * in_position;\n" + " vec3 vEyeNormal = normalMatrix * in_normal;\n" + " vec4 vPosition4 = modelviewMatrix * in_position;\n" + " vec3 vPosition3 = vPosition4.xyz / vPosition4.w;\n" + " vec3 vLightDir = normalize(lightSource.xyz - vPosition3);\n" + " float diff = max(0.0, dot(vEyeNormal, vLightDir));\n" + " vVaryingColor = vec4(diff * in_color.rgb, 1.0);\n" + "} \n"; + + const char *fragment_shader_source = + "precision mediump float; \n" + " \n" + "varying vec4 vVaryingColor; \n" + " \n" + "void main() \n" + "{ \n" + " gl_FragColor = vVaryingColor; \n" + "} \n"; + + vertex_shader = glCreateShader(GL_VERTEX_SHADER); + if (!vertex_shader) { + printf("Error: glCreateShader(GL_VERTEX_SHADER) failed: %d (%s)\n", + eglGetError(), eglStrError(eglGetError())); + return -1; + } + + + glShaderSource(vertex_shader, 1, &vertex_shader_source, NULL); + glCompileShader(vertex_shader); + + glGetShaderiv(vertex_shader, GL_COMPILE_STATUS, &ret); + if (!ret) { + char *log; + + printf("Error: vertex shader compilation failed!:\n"); + glGetShaderiv(vertex_shader, GL_INFO_LOG_LENGTH, &ret); + + if (ret > 1) { + log = malloc(ret); + glGetShaderInfoLog(vertex_shader, ret, NULL, log); + printf("%s", log); + } + return -1; + } else + printf("Vertex shader compilation succeeded!\n"); + + fragment_shader = glCreateShader(GL_FRAGMENT_SHADER); + if (!fragment_shader) { + printf("Error: glCreateShader(GL_FRAGMENT_SHADER) failed: %d (%s)\n", + eglGetError(), eglStrError(eglGetError())); + return -1; + } + + + glShaderSource(fragment_shader, 1, &fragment_shader_source, NULL); + glCompileShader(fragment_shader); + + glGetShaderiv(fragment_shader, GL_COMPILE_STATUS, &ret); + if (!ret) { + char *log; + + printf("Error: fragment shader compilation failed!:\n"); + glGetShaderiv(fragment_shader, GL_INFO_LOG_LENGTH, &ret); + + if (ret > 1) { + log = malloc(ret); + glGetShaderInfoLog(fragment_shader, ret, NULL, log); + printf("%s", log); + } + return -1; + } else + printf("Fragment shader compilation succeeded!\n"); + + program = glCreateProgram(); + if (!program) { + printf("Error: failed to create program!\n"); + return -1; + } + + glAttachShader(program, vertex_shader); + glAttachShader(program, fragment_shader); + + glBindAttribLocation(program, 0, "in_position"); + glBindAttribLocation(program, 1, "in_normal"); + glBindAttribLocation(program, 2, "in_color"); + + glLinkProgram(program); + + glGetProgramiv(program, GL_LINK_STATUS, &ret); + if (!ret) { + char *log; + + printf("Error: program linking failed!:\n"); + glGetProgramiv(program, GL_INFO_LOG_LENGTH, &ret); + + if (ret > 1) { + log = malloc(ret); + glGetProgramInfoLog(program, ret, NULL, log); + printf("%s", log); + } + return -1; + } else + printf("program linking succeeded!\n"); + + userData->program = program; +} + +GLfloat vVertices[] = { + // front + -1.0f, -1.0f, +1.0f, // point blue + +1.0f, -1.0f, +1.0f, // point magenta + -1.0f, +1.0f, +1.0f, // point cyan + +1.0f, +1.0f, +1.0f, // point white + // back + +1.0f, -1.0f, -1.0f, // point red + -1.0f, -1.0f, -1.0f, // point black + +1.0f, +1.0f, -1.0f, // point yellow + -1.0f, +1.0f, -1.0f, // point green + // right + +1.0f, -1.0f, +1.0f, // point magenta + +1.0f, -1.0f, -1.0f, // point red + +1.0f, +1.0f, +1.0f, // point white + +1.0f, +1.0f, -1.0f, // point yellow + // left + -1.0f, -1.0f, -1.0f, // point black + -1.0f, -1.0f, +1.0f, // point blue + -1.0f, +1.0f, -1.0f, // point green + -1.0f, +1.0f, +1.0f, // point cyan + // top + -1.0f, +1.0f, +1.0f, // point cyan + +1.0f, +1.0f, +1.0f, // point white + -1.0f, +1.0f, -1.0f, // point green + +1.0f, +1.0f, -1.0f, // point yellow + // bottom + -1.0f, -1.0f, -1.0f, // point black + +1.0f, -1.0f, -1.0f, // point red + -1.0f, -1.0f, +1.0f, // point blue + +1.0f, -1.0f, +1.0f // point magenta +}; + +GLfloat vColors[] = { + // front + 0.0f, 0.0f, 1.0f, // blue + 1.0f, 0.0f, 1.0f, // magenta + 0.0f, 1.0f, 1.0f, // cyan + 1.0f, 1.0f, 1.0f, // white + // back + 1.0f, 0.0f, 0.0f, // red + 0.0f, 0.0f, 0.0f, // black + 1.0f, 1.0f, 0.0f, // yellow + 0.0f, 1.0f, 0.0f, // green + // right + 1.0f, 0.0f, 1.0f, // magenta + 1.0f, 0.0f, 0.0f, // red + 1.0f, 1.0f, 1.0f, // white + 1.0f, 1.0f, 0.0f, // yellow + // left + 0.0f, 0.0f, 0.0f, // black + 0.0f, 0.0f, 1.0f, // blue + 0.0f, 1.0f, 0.0f, // green + 0.0f, 1.0f, 1.0f, // cyan + // top + 0.0f, 1.0f, 1.0f, // cyan + 1.0f, 1.0f, 1.0f, // white + 0.0f, 1.0f, 0.0f, // green + 1.0f, 1.0f, 0.0f, // yellow + // bottom + 0.0f, 0.0f, 0.0f, // black + 1.0f, 0.0f, 0.0f, // red + 0.0f, 0.0f, 1.0f, // blue + 1.0f, 0.0f, 1.0f // magenta +}; + +GLfloat vNormals[] = { + // front + +0.0f, +0.0f, +1.0f, // forward + +0.0f, +0.0f, +1.0f, // forward + +0.0f, +0.0f, +1.0f, // forward + +0.0f, +0.0f, +1.0f, // forward + // back + +0.0f, +0.0f, -1.0f, // backbard + +0.0f, +0.0f, -1.0f, // backbard + +0.0f, +0.0f, -1.0f, // backbard + +0.0f, +0.0f, -1.0f, // backbard + // right + +1.0f, +0.0f, +0.0f, // right + +1.0f, +0.0f, +0.0f, // right + +1.0f, +0.0f, +0.0f, // right + +1.0f, +0.0f, +0.0f, // right + // left + -1.0f, +0.0f, +0.0f, // left + -1.0f, +0.0f, +0.0f, // left + -1.0f, +0.0f, +0.0f, // left + -1.0f, +0.0f, +0.0f, // left + // top + +0.0f, +1.0f, +0.0f, // up + +0.0f, +1.0f, +0.0f, // up + +0.0f, +1.0f, +0.0f, // up + +0.0f, +1.0f, +0.0f, // up + // bottom + +0.0f, -1.0f, +0.0f, // down + +0.0f, -1.0f, +0.0f, // down + +0.0f, -1.0f, +0.0f, // down + +0.0f, -1.0f, +0.0f // down +}; + +void Draw ( ESContext *esContext ) +{ + UserData *userData = esContext->userData; + glViewport(0, 0, esContext->width, esContext->height); + + /* clear the color buffer */ + glClearColor(0.5, 0.5, 0.5, 1.0); + glClear(GL_COLOR_BUFFER_BIT); + + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, vVertices); + glEnableVertexAttribArray(0); + + glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, vNormals); + glEnableVertexAttribArray(1); + + glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0, vColors); + glEnableVertexAttribArray(2); + + glUseProgram(userData->program); + ESMatrix modelview; + esMatrixLoadIdentity(&modelview); + esTranslate(&modelview, 0.0f, 0.0f, -8.0f); + esRotate(&modelview, 45.0f, 1.0f, 0.0f, 0.0f); + esRotate(&modelview, 45.0f, 0.0f, 1.0f, 0.0f); + esRotate(&modelview, 10.0f, 0.0f, 0.0f, 1.0f); + + GLfloat aspect = (GLfloat)(esContext->height) / (GLfloat)(esContext->width); + + ESMatrix projection; + esMatrixLoadIdentity(&projection); + esFrustum(&projection, -2.8f, +2.8f, -2.8f * aspect, +2.8f * aspect, 6.0f, 10.0f); + + ESMatrix modelviewprojection; + esMatrixLoadIdentity(&modelviewprojection); + esMatrixMultiply(&modelviewprojection, &modelview, &projection); + + float normal[9]; + normal[0] = modelview.m[0][0]; + normal[1] = modelview.m[0][1]; + normal[2] = modelview.m[0][2]; + normal[3] = modelview.m[1][0]; + normal[4] = modelview.m[1][1]; + normal[5] = modelview.m[1][2]; + normal[6] = modelview.m[2][0]; + normal[7] = modelview.m[2][1]; + normal[8] = modelview.m[2][2]; + + GLint modelviewmatrix_handle = glGetUniformLocation(userData->program, "modelviewMatrix"); + GLint modelviewprojectionmatrix_handle = glGetUniformLocation(userData->program, "modelviewprojectionMatrix"); + GLint normalmatrix_handle = glGetUniformLocation(userData->program, "normalMatrix"); + + glUniformMatrix4fv(modelviewmatrix_handle, 1, GL_FALSE, &modelview.m[0][0]); + glUniformMatrix4fv(modelviewprojectionmatrix_handle, 1, GL_FALSE, &modelviewprojection.m[0][0]); + glUniformMatrix3fv(normalmatrix_handle, 1, GL_FALSE, normal); + + glEnable(GL_CULL_FACE); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glDrawArrays(GL_TRIANGLE_STRIP, 4, 4); + glDrawArrays(GL_TRIANGLE_STRIP, 8, 4); + glDrawArrays(GL_TRIANGLE_STRIP, 12, 4); + glDrawArrays(GL_TRIANGLE_STRIP, 16, 4); + glDrawArrays(GL_TRIANGLE_STRIP, 20, 4); + + userData->frames ++; +#ifdef HOOK + // If logging, exit mainloop after a few frames + if(userData->frames == 5) + { + esContext->terminate = TRUE; + } +#endif +} + +int main(int argc, char *argv[]) +{ + ESContext esContext; + UserData userData; +#ifdef HOOK + the_hook("/tmp/egl2.fdr"); +#endif + + esInitContext ( &esContext ); + esContext.userData = &userData; + + esCreateWindow ( &esContext, "Cubic fun", 320, 240, ES_WINDOW_RGB ); + + if ( !Init ( &esContext ) ) + return 0; + + esRegisterDrawFunc ( &esContext, Draw ); + + esMainLoop ( &esContext ); + //dump_gl_screen("/sdcard/egl2.bmp", width, height); +#ifdef HOOK + glFinish(); + close_hook(); +#endif + return 0; +} + diff --git a/native/egl/eglinfo.c b/native/egl/eglinfo.c index 14620a9..a0afc08 100644 --- a/native/egl/eglinfo.c +++ b/native/egl/eglinfo.c @@ -43,11 +43,11 @@ static void PrintConfigs(EGLDisplay d) { EGLConfig configs[MAX_CONFIGS]; - EGLint numConfigs, i; + EGLint numConfigs=0, i; eglGetConfigs(d, configs, MAX_CONFIGS, &numConfigs); - printf("Configurations:\n"); + printf("Configurations (%i):\n", numConfigs); printf(" bf lv d st colorbuffer dp st ms vis supported\n"); printf(" id sz l b ro r g b a th cl ns b id surfaces \n"); printf("--------------------------------------------------------\n"); diff --git a/native/egl/ps_sandbox.c b/native/egl/ps_sandbox.c index f84299f..a7fc72c 100644 --- a/native/egl/ps_sandbox.c +++ b/native/egl/ps_sandbox.c @@ -33,7 +33,7 @@ #include <sys/mman.h> #include <stdarg.h> -#include "esUtil.h" +#include "esTransform.h" #include "eglutil.h" #include "dump_gl_screen.h" #include "viv_hook.h" diff --git a/native/fb/Makefile b/native/fb/Makefile index a132794..27b70a7 100644 --- a/native/fb/Makefile +++ b/native/fb/Makefile @@ -2,14 +2,12 @@ TOP=.. include $(TOP)/Makefile.inc -CXXABI = armeabi-v7a -COMMON_FLAGS = -I$(TOP)/lib -I$(TOP)/include_v2 -g -std=c99 -fPIC -I../resources -DANDROID -I../include +COMMON_FLAGS = -I$(TOP)/lib -I$(TOP)/include_$(GCABI) -g -std=c99 -fPIC -I../resources -I../include CFLAGS += $(COMMON_FLAGS) -CXXFLAGS += $(COMMON_FLAGS) -I$(NDK)/sources/cxx-stl/gnu-libstdc++/4.6/include -I$(NDK)/sources/cxx-stl/gnu-libstdc++/4.6/libs/$(CXXABI)/include -LDFLAGS += -L$(NDK)/sources/cxx-stl/gnu-libstdc++/4.6/libs/$(CXXABI) -lgnustl_static +CXXFLAGS += $(COMMON_FLAGS) +LDFLAGS += -lm TARGETS = fbtest etna_test rotate_cube cube_companion mip_cube rstests -GL_LIBS = -L$(TOP)/lib -L$(TOP)/lib/egl -Xlinker --allow-shlib-undefined -lm COMPANION_OBJS = ../resources/companion_array.o ../resources/companion_mesh.o ../resources/companion_texture.o all: $(TARGETS) @@ -19,20 +17,20 @@ clean: rm -f $(TARGETS) fbtest: fbtest.o ../lib/write_bmp.o ../lib/viv.o ../lib/etna_fb.o - $(CC) $(CFLAGS) -o $@ $^ $(GL_LIBS) $(LDFLAGS) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) etna_test: etna_test.o ../lib/write_bmp.o ../lib/viv.o ../lib/etna.o ../lib/etna_rs.o ../lib/etna_fb.o ../lib/etna_mem.o - $(CC) $(CFLAGS) -o $@ $^ $(GL_LIBS) $(LDFLAGS) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) rotate_cube: rotate_cube.o ../lib/write_bmp.o ../lib/viv.o ../lib/etna.o ../lib/etna_rs.o ../lib/etna_fb.o ../lib/etna_mem.o ../lib/esTransform.o - $(CC) $(CFLAGS) -o $@ $^ $(GL_LIBS) $(LDFLAGS) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) -mip_cube: mip_cube.o ../lib/write_bmp.o ../lib/viv.o ../lib/etna.o ../lib/etna_rs.o ../lib/etna_fb.o ../lib/etna_mem.o ../lib/esTransform.o ../lib/dds.o - $(CC) $(CFLAGS) -o $@ $^ $(GL_LIBS) $(LDFLAGS) +mip_cube: mip_cube.o ../lib/write_bmp.o ../lib/viv.o ../lib/etna.o ../lib/etna_rs.o ../lib/etna_fb.o ../lib/etna_mem.o ../lib/esTransform.o ../lib/dds.o ../lib/etna_bswap.o + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) cube_companion: cube_companion.o ../lib/write_bmp.o ../lib/viv.o ../lib/etna.o ../lib/etna_rs.o ../lib/etna_fb.o ../lib/etna_mem.o ../lib/esTransform.o $(COMPANION_OBJS) - $(CC) $(CFLAGS) -o $@ $^ $(GL_LIBS) $(LDFLAGS) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) rstests: rstests.o ../lib/write_bmp.o ../lib/viv.o ../lib/etna.o ../lib/etna_rs.o ../lib/etna_fb.o ../lib/etna_mem.o ../lib/esTransform.o $(COMPANION_OBJS) - $(CC) $(CFLAGS) -o $@ $^ $(GL_LIBS) $(LDFLAGS) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) diff --git a/native/fb/cube_companion.c b/native/fb/cube_companion.c index 7227218..1a2962c 100644 --- a/native/fb/cube_companion.c +++ b/native/fb/cube_companion.c @@ -59,7 +59,7 @@ #include "etna_fb.h" #include "etna_mem.h" -#include "esUtil.h" +#include "esTransform.h" #include "companion.h" diff --git a/native/fb/etna_test.c b/native/fb/etna_test.c index 8dfc267..ef05b53 100644 --- a/native/fb/etna_test.c +++ b/native/fb/etna_test.c @@ -46,7 +46,7 @@ #include "etna_fb.h" #include "etna_mem.h" -#include "esUtil.h" +#include "esTransform.h" GLfloat vVertices[] = { -1.0f, -1.0f, +0.0f, diff --git a/native/fb/mip_cube.c b/native/fb/mip_cube.c index e7a8836..59336cb 100644 --- a/native/fb/mip_cube.c +++ b/native/fb/mip_cube.c @@ -33,7 +33,6 @@ #include <stdarg.h> #include <assert.h> #include <math.h> -#include <pthread.h> #include <errno.h> @@ -46,8 +45,9 @@ #include "etna_rs.h" #include "etna_fb.h" #include "etna_mem.h" +#include "etna_bswap.h" -#include "esUtil.h" +#include "esTransform.h" #include "dds.h" #define RCPLOG2 (1.4426950408889634f) @@ -220,110 +220,6 @@ void tile_texture(void *dest, void *src, unsigned width, unsigned height, unsign } } -#define ETNA_FB_NUM_BUFFERS 2 -struct etna_fb_buffer { - pthread_mutex_t available_mutex; - pthread_cond_t available_cond; - bool is_available; - int sig_id_ready; -}; -struct etna_fb_buffers { - pthread_t thread; - int backbuffer, frontbuffer; - bool terminate; - fb_info *fb; - struct etna_fb_buffer buf[ETNA_FB_NUM_BUFFERS]; -}; - -static void bufferswap_init_buffer(struct etna_fb_buffer *buf) -{ - pthread_mutex_init(&buf->available_mutex, NULL); - pthread_cond_init(&buf->available_cond, NULL); - - buf->is_available = 1; - if(viv_user_signal_create(0, &buf->sig_id_ready) != 0) - { - fprintf(stderr, "Cannot create user signal for framebuffer sync\n"); - exit(1); - } -} - -static void bufferswap_destroy_buffer(struct etna_fb_buffer *buf) -{ - (void)pthread_mutex_destroy(&buf->available_mutex); - (void)pthread_cond_destroy(&buf->available_cond); - (void)viv_user_signal_destroy(buf->sig_id_ready); -} - -static void bufferswap_thread(struct etna_fb_buffers *bufs) -{ - int cur = 0; - while(!bufs->terminate) - { - /* wait for "buffer ready" signal for buffer X (and clear it) */ - if(viv_user_signal_wait(bufs->buf[cur].sig_id_ready, SIG_WAIT_INDEFINITE) != 0) - { - fprintf(stderr, "Error waiting for framebuffer sync signal\n"); - exit(1); - } - /* switch buffers */ - fb_set_buffer(bufs->fb, cur); - bufs->frontbuffer = cur; - /* X = (X+1)%buffers */ - cur = (cur+1) % ETNA_FB_NUM_BUFFERS; - /* set "buffer available" for buffer X, signal condition */ - pthread_mutex_lock(&bufs->buf[cur].available_mutex); - bufs->buf[cur].is_available = 1; - pthread_cond_signal(&bufs->buf[cur].available_cond); - pthread_mutex_unlock(&bufs->buf[cur].available_mutex); - } -} - -void bufferswap_init(struct etna_fb_buffers *bufs, fb_info *fb) -{ - bufs->fb = fb; - bufs->backbuffer = bufs->frontbuffer = 0; - bufs->terminate = false; - for(int idx=0; idx<ETNA_FB_NUM_BUFFERS; ++idx) - bufferswap_init_buffer(&bufs->buf[idx]); - pthread_create(&bufs->thread, NULL, (void * (*)(void *))&bufferswap_thread, bufs); -} - -void bufferswap_exit(struct etna_fb_buffers *bufs) -{ - bufs->terminate = true; - /* signal ready signals, to prevent thread from waiting forever for buffer to become ready */ - for(int idx=0; idx<ETNA_FB_NUM_BUFFERS; ++idx) - (void)viv_user_signal_signal(bufs->buf[idx].sig_id_ready, 1); - (void)pthread_join(bufs->thread, NULL); - for(int idx=0; idx<ETNA_FB_NUM_BUFFERS; ++idx) - bufferswap_destroy_buffer(&bufs->buf[idx]); -} - -/* wait until current backbuffer is available to render to */ -void bufferswap_wait_available(struct etna_fb_buffers *bufs) -{ - struct etna_fb_buffer *buf = &bufs->buf[bufs->backbuffer]; - /* Wait until buffer buf is available */ - pthread_mutex_lock(&buf->available_mutex); - while(!buf->is_available) - { - pthread_cond_wait(&buf->available_cond, &buf->available_mutex); - } - pthread_mutex_unlock(&buf->available_mutex); -} - -/* queue buffer swap when GPU ready with rendering to buf */ -void bufferswap_queue_swap(struct etna_fb_buffers *bufs) -{ - if(viv_event_queue_signal(bufs->buf[bufs->backbuffer].sig_id_ready, gcvKERNEL_PIXEL) != 0) - { - fprintf(stderr, "Unable to queue framebuffer sync signal\n"); - exit(1); - } - bufs->backbuffer = (bufs->backbuffer + 1) % ETNA_FB_NUM_BUFFERS; -} - int main(int argc, char **argv) { int rv; @@ -352,8 +248,12 @@ int main(int argc, char **argv) printf("Succesfully opened device\n"); /* Initialize buffers synchronization structure */ - struct etna_fb_buffers buffers; - bufferswap_init(&buffers, &fb); + etna_bswap_buffers *buffers = 0; + if(etna_bswap_create(&buffers, (int (*)(void *, int))&fb_set_buffer, &fb) < 0) + { + fprintf(stderr, "Error creating buffer swapper\n"); + exit(1); + } /* Allocate video memory */ etna_vidmem *rt = 0; /* main render target */ @@ -741,7 +641,7 @@ int main(int argc, char **argv) etna_stall(ctx, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE); /* copy to screen */ - bufferswap_wait_available(&buffers); + etna_bswap_wait_available(buffers); etna_set_state(ctx, VIVS_GL_FLUSH_CACHE, VIVS_GL_FLUSH_CACHE_COLOR | VIVS_GL_FLUSH_CACHE_DEPTH); etna_set_state(ctx, VIVS_RS_CONFIG, VIVS_RS_CONFIG_SOURCE_FORMAT(RS_FORMAT_X8R8G8B8) | @@ -756,19 +656,19 @@ int main(int argc, char **argv) etna_set_state(ctx, VIVS_RS_EXTRA_CONFIG, 0); /* no AA, no endian switch */ etna_set_state(ctx, VIVS_RS_SOURCE_ADDR, rt->address); /* ADDR_A */ - etna_set_state(ctx, VIVS_RS_DEST_ADDR, fb.physical[buffers.backbuffer]); /* ADDR_J */ + etna_set_state(ctx, VIVS_RS_DEST_ADDR, fb.physical[buffers->backbuffer]); /* ADDR_J */ etna_set_state(ctx, VIVS_RS_WINDOW_SIZE, VIVS_RS_WINDOW_SIZE_HEIGHT(height) | VIVS_RS_WINDOW_SIZE_WIDTH(width)); etna_set_state(ctx, VIVS_RS_KICKER, 0xbeebbeeb); - bufferswap_queue_swap(&buffers); + etna_bswap_queue_swap(buffers); } #ifdef DUMP bmp_dump32(fb.logical[1-backbuffer], width, height, false, "/mnt/sdcard/fb.bmp"); printf("Dump complete\n"); #endif - bufferswap_exit(&buffers); + etna_bswap_free(buffers); etna_free(ctx); viv_close(); return 0; diff --git a/native/fb/rotate_cube.c b/native/fb/rotate_cube.c index 5971217..bbcdc7f 100644 --- a/native/fb/rotate_cube.c +++ b/native/fb/rotate_cube.c @@ -44,7 +44,7 @@ #include "etna_fb.h" #include "etna_mem.h" -#include "esUtil.h" +#include "esTransform.h" #define VERTEX_BUFFER_SIZE 0x60000 diff --git a/native/fb/rstests.c b/native/fb/rstests.c index b0de091..86ca9f4 100644 --- a/native/fb/rstests.c +++ b/native/fb/rstests.c @@ -46,7 +46,7 @@ #include "etna_fb.h" #include "etna_mem.h" -#include "esUtil.h" +#include "esTransform.h" int main(int argc, char **argv) { diff --git a/native/include_dove/gc_hal.h b/native/include_dove/gc_hal.h new file mode 100644 index 0000000..e9ce46f --- /dev/null +++ b/native/include_dove/gc_hal.h @@ -0,0 +1,2071 @@ +/**************************************************************************** +* +* Copyright (C) 2005 - 2010 by Vivante Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the license, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +* +*****************************************************************************/ + + + + +#ifndef __gc_hal_h_ +#define __gc_hal_h_ + +#include "gc_hal_types.h" +#include "gc_hal_enum.h" +#include "gc_hal_base.h" +#include "gc_hal_profiler.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* the number of profiling nodes */ +#define NUM_PROFILE_NODES 100 + +/* temporarily place gralloc defination here, should be moved to android header file later */ +#define GRALLOC_USAGE_GLES20_RENDER 0x10000000 + +/* BSP idle profile Macros */ +#if ENABLE_BSP_IDLE_PROFILE +/* +dev_id: 1 vpu 0 gpu +State: 1 run 0 idle +Start: 2 init 1 start 0 stop +*/ +#define BSP_IDLE_PROFILE(dev_id,state,start) \ +do { \ + if(1) \ + gcmkPRINT("--->%s\t\tstart_profile(0,%d,%d)\t%s\n", \ + __FUNCTION__,state,start,(start==1)?(state?"busy-time":"\tidle-time"):"init"); \ + start_profile(dev_id,state,start); \ +} while(0); +#define BSP_IDLE_PROFILE_INIT BSP_IDLE_PROFILE(0, 0, 2) +#define BSP_IDLE_PROFILE_CALC_BUSY_TIME BSP_IDLE_PROFILE(0, 1, 1) +#define BSP_IDLE_PROFILE_CALC_IDLE_TIME BSP_IDLE_PROFILE(0, 0, 1) +#else /* Disable bsp_idle_profile or OTHER PLATFORMs */ +#define BSP_IDLE_PROFILE_INIT +#define BSP_IDLE_PROFILE_CALC_BUSY_TIME +#define BSP_IDLE_PROFILE_CALC_IDLE_TIME +#endif + +/******************************************************************************\ +******************************* Alignment Macros ******************************* +\******************************************************************************/ +#define GC_NOP_COMMAND 0x18000000 + +#define gcmALIGN(n, align) \ +( \ + ((n) + ((align) - 1)) & ~((align) - 1) \ +) + +/******************************************************************************\ +***************************** Element Count Macro ***************************** +\******************************************************************************/ + +#define gcmSIZEOF(a) \ +( \ + (gctSIZE_T) (sizeof(a)) \ +) + +#define gcmCOUNTOF(a) \ +( \ + sizeof(a) / sizeof(a[0]) \ +) + +/******************************************************************************\ +******************************** gcsOBJECT Object ******************************* +\******************************************************************************/ + +/* Type of objects. */ +typedef enum _gceOBJECT_TYPE +{ + gcvOBJ_UNKNOWN = 0, + gcvOBJ_2D = gcmCC('2','D',' ',' '), + gcvOBJ_3D = gcmCC('3','D',' ',' '), + gcvOBJ_ATTRIBUTE = gcmCC('A','T','T','R'), + gcvOBJ_BRUSHCACHE = gcmCC('B','R','U','$'), + gcvOBJ_BRUSHNODE = gcmCC('B','R','U','n'), + gcvOBJ_BRUSH = gcmCC('B','R','U','o'), + gcvOBJ_BUFFER = gcmCC('B','U','F','R'), + gcvOBJ_COMMAND = gcmCC('C','M','D',' '), + gcvOBJ_COMMANDBUFFER = gcmCC('C','M','D','B'), + gcvOBJ_CONTEXT = gcmCC('C','T','X','T'), + gcvOBJ_CONTEXTBUFFER = gcmCC('C','T','X','B'), + gcvOBJ_DEVICE = gcmCC('D','E','V',' '), + gcvOBJ_DUMP = gcmCC('D','U','M','P'), + gcvOBJ_EVENT = gcmCC('E','V','N','T'), + gcvOBJ_FUNCTION = gcmCC('F','U','N','C'), + gcvOBJ_HAL = gcmCC('H','A','L',' '), + gcvOBJ_HARDWARE = gcmCC('H','A','R','D'), + gcvOBJ_HEAP = gcmCC('H','E','A','P'), + gcvOBJ_INDEX = gcmCC('I','N','D','X'), + gcvOBJ_INTERRUPT = gcmCC('I','N','T','R'), + gcvOBJ_KERNEL = gcmCC('K','E','R','N'), + gcvOBJ_MEMORYBUFFER = gcmCC('M','E','M','B'), + gcvOBJ_MMU = gcmCC('M','M','U',' '), + gcvOBJ_OS = gcmCC('O','S',' ',' '), + gcvOBJ_OUTPUT = gcmCC('O','U','T','P'), + gcvOBJ_PAINT = gcmCC('P','N','T',' '), + gcvOBJ_PATH = gcmCC('P','A','T','H'), + gcvOBJ_QUEUE = gcmCC('Q','U','E',' '), + gcvOBJ_SAMPLER = gcmCC('S','A','M','P'), + gcvOBJ_SHADER = gcmCC('S','H','D','R'), + gcvOBJ_STREAM = gcmCC('S','T','R','M'), + gcvOBJ_SURF = gcmCC('S','U','R','F'), + gcvOBJ_TEXTURE = gcmCC('T','X','T','R'), + gcvOBJ_UNIFORM = gcmCC('U','N','I','F'), + gcvOBJ_VARIABLE = gcmCC('V','A','R','I'), + gcvOBJ_VERTEX = gcmCC('V','R','T','X'), + gcvOBJ_VIDMEM = gcmCC('V','M','E','M'), + gcvOBJ_VG = gcmCC('V','G',' ',' '), +} +gceOBJECT_TYPE; + +/* gcsOBJECT object defintinon. */ +typedef struct _gcsOBJECT +{ + /* Type of an object. */ + gceOBJECT_TYPE type; +} +gcsOBJECT; + +/* Kernel settings. */ +typedef struct _gcsKERNEL_SETTINGS +{ + /* Used RealTime signal between kernel and user. */ + gctINT signal; +} +gcsKERNEL_SETTINGS; + +typedef struct _gckHARDWARE * gckHARDWARE; + +/******************************************************************************* +** +** gcmVERIFY_OBJECT +** +** Assert if an object is invalid or is not of the specified type. If the +** object is invalid or not of the specified type, gcvSTATUS_INVALID_OBJECT +** will be returned from the current function. In retail mode this macro +** does nothing. +** +** ARGUMENTS: +** +** obj Object to test. +** t Expected type of the object. +*/ +#ifndef EGL_API_ANDROID +# define _gcmVERIFY_OBJECT(prefix, obj, t) \ + do \ + { \ + if ((obj) == gcvNULL) \ + { \ + prefix##TRACE(gcvLEVEL_ERROR, \ + #prefix "VERIFY_OBJECT failed: NULL"); \ + prefix##TRACE(gcvLEVEL_ERROR, " expected: %c%c%c%c", \ + gcmCC_PRINT(t)); \ + prefix##ASSERT((obj) != gcvNULL); \ + prefix##FOOTER_ARG("status=%d", gcvSTATUS_INVALID_OBJECT); \ + return gcvSTATUS_INVALID_OBJECT; \ + } \ + else if (((gcsOBJECT*) (obj))->type != t) \ + { \ + prefix##TRACE(gcvLEVEL_ERROR, \ + #prefix "VERIFY_OBJECT failed: %c%c%c%c", \ + gcmCC_PRINT(((gcsOBJECT*) (obj))->type)); \ + prefix##TRACE(gcvLEVEL_ERROR, " expected: %c%c%c%c", \ + gcmCC_PRINT(t)); \ + prefix##ASSERT(((gcsOBJECT*)(obj))->type == t); \ + prefix##FOOTER_ARG("status=%d", gcvSTATUS_INVALID_OBJECT); \ + return gcvSTATUS_INVALID_OBJECT; \ + } \ + } \ + while (gcvFALSE) +# define gcmVERIFY_OBJECT(obj, t) _gcmVERIFY_OBJECT(gcm, obj, t) +# define gcmkVERIFY_OBJECT(obj, t) _gcmVERIFY_OBJECT(gcmk, obj, t) +#else +# define gcmVERIFY_OBJECT(obj, t) do {} while (gcvFALSE) +# define gcmkVERIFY_OBJECT(obj, t) do {} while (gcvFALSE) +#endif + +/******************************************************************************\ +********************************** gckOS Object ********************************* +\******************************************************************************/ + +typedef struct _gckOS * gckOS; + +/*! +********************************************************************* +* \struct _gckRecursiveMutex +* \brief +* Data structure for recursive lock. +********************************************************************* +*/ +typedef struct _gckRecursiveMutex * gckRecursiveMutex; +struct _gckRecursiveMutex +{ + /* Thread lock the mutex. */ + gctINT32 pThread; + /* Lock times. */ + gctUINT32 nReference; + /* Access mutex. */ + gctPOINTER accMutex; + /* Underly mutex. */ + gctPOINTER undMutex; +}; + +/* Construct a new gckOS object. */ +gceSTATUS +gckOS_Construct( + IN gctPOINTER Context, + OUT gckOS * Os + ); + +/* Destroy an gckOS object. */ +gceSTATUS +gckOS_Destroy( + IN gckOS Os + ); + +/* Query the video memory. */ +gceSTATUS +gckOS_QueryVideoMemory( + IN gckOS Os, + OUT gctPHYS_ADDR * InternalAddress, + OUT gctSIZE_T * InternalSize, + OUT gctPHYS_ADDR * ExternalAddress, + OUT gctSIZE_T * ExternalSize, + OUT gctPHYS_ADDR * ContiguousAddress, + OUT gctSIZE_T * ContiguousSize + ); + +/*Simulate allocate memory random fail */ +gctBOOL +gckOS_ForceMemAllocFail(gckOS Os); + +/* Allocate memory from the heap. */ +gceSTATUS +gckOS_Allocate( + IN gckOS Os, + IN gctSIZE_T Bytes, + OUT gctPOINTER * Memory + ); + +/* Free allocated memory. */ +gceSTATUS +gckOS_Free( + IN gckOS Os, + IN gctPOINTER Memory + ); + +/* Wrapper for allocation memory.. */ +gceSTATUS +gckOS_AllocateMemory( + IN gckOS Os, + IN gctSIZE_T Bytes, + OUT gctPOINTER * Memory + ); + +/* Wrapper for freeing memory. */ +gceSTATUS +gckOS_FreeMemory( + IN gckOS Os, + IN gctPOINTER Memory + ); + +/* Allocate paged memory. */ +gceSTATUS +gckOS_AllocatePagedMemory( + IN gckOS Os, + IN gctSIZE_T Bytes, + OUT gctPHYS_ADDR * Physical + ); + +/* Allocate paged memory. */ +gceSTATUS +gckOS_AllocatePagedMemoryEx( + IN gckOS Os, + IN gctBOOL Contiguous, + IN gctSIZE_T Bytes, + OUT gctPHYS_ADDR * Physical + ); + +/* Lock pages. */ +gceSTATUS +gckOS_LockPages( + IN gckOS Os, + IN gctPHYS_ADDR Physical, + IN gctSIZE_T Bytes, +#ifdef __QNXNTO__ + IN gctUINT32 Pid, +#endif + OUT gctPOINTER * Logical, + OUT gctSIZE_T * PageCount + ); + +/* Map pages. */ +gceSTATUS +gckOS_MapPages( + IN gckOS Os, + IN gctPHYS_ADDR Physical, +#ifdef __QNXNTO__ + IN gctPOINTER Logical, +#endif + IN gctSIZE_T PageCount, + IN gctPOINTER PageTable + ); + +/* Unlock pages. */ +gceSTATUS +gckOS_UnlockPages( + IN gckOS Os, + IN gctPHYS_ADDR Physical, +#ifdef __QNXNTO__ + IN gctUINT32 Pid, +#endif + IN gctSIZE_T Bytes, + IN gctPOINTER Logical + ); + +/* Free paged memory. */ +gceSTATUS +gckOS_FreePagedMemory( + IN gckOS Os, + IN gctPHYS_ADDR Physical, + IN gctSIZE_T Bytes + ); + +/* Allocate non-paged memory. */ +gceSTATUS +gckOS_AllocateNonPagedMemory( + IN gckOS Os, + IN gctBOOL InUserSpace, + IN OUT gctSIZE_T * Bytes, + OUT gctPHYS_ADDR * Physical, + OUT gctPOINTER * Logical + ); + +/* Free non-paged memory. */ +gceSTATUS +gckOS_FreeNonPagedMemory( + IN gckOS Os, + IN gctSIZE_T Bytes, + IN gctPHYS_ADDR Physical, + IN gctPOINTER Logical + ); + +/* Allocate contiguous memory. */ +gceSTATUS +gckOS_AllocateContiguous( + IN gckOS Os, + IN gctBOOL InUserSpace, + IN OUT gctSIZE_T * Bytes, + OUT gctPHYS_ADDR * Physical, + OUT gctPOINTER * Logical + ); + +/* Free contiguous memory. */ +gceSTATUS +gckOS_FreeContiguous( + IN gckOS Os, + IN gctPHYS_ADDR Physical, + IN gctPOINTER Logical, + IN gctSIZE_T Bytes + ); + +/* Get the number fo bytes per page. */ +gceSTATUS +gckOS_GetPageSize( + IN gckOS Os, + OUT gctSIZE_T * PageSize + ); + +/* Get the physical address of a corresponding logical address. */ +gceSTATUS +gckOS_GetPhysicalAddress( + IN gckOS Os, + IN gctPOINTER Logical, + OUT gctUINT32 * Address + ); + +/* Map physical memory. */ +gceSTATUS +gckOS_MapPhysical( + IN gckOS Os, + IN gctUINT32 Physical, + IN gctUINT32 OriginalLogical, + IN gctSIZE_T Bytes, + OUT gctPOINTER * Logical + ); + +/* Unmap previously mapped physical memory. */ +gceSTATUS +gckOS_UnmapPhysical( + IN gckOS Os, + IN gctPOINTER Logical, + IN gctSIZE_T Bytes + ); + +/* Read data from a hardware register. */ +gceSTATUS +gckOS_ReadRegister( + IN gckOS Os, + IN gctUINT32 Address, + OUT gctUINT32 * Data + ); + +/* Read data from a register directly without mutex protection. */ +gceSTATUS +gckOS_DirectReadRegister( + IN gckOS Os, + IN gctUINT32 Address, + OUT gctUINT32 * Data + ); + +/* Write data to a hardware register. */ +gceSTATUS +gckOS_WriteRegister( + IN gckOS Os, + IN gctUINT32 Address, + IN gctUINT32 Data + ); + +/* Write data to a 32-bit memory location. */ +gceSTATUS +gckOS_WriteMemory( + IN gckOS Os, + IN gctPOINTER Address, + IN gctUINT32 Data + ); + +/* Map physical memory into the process space. */ +gceSTATUS +gckOS_MapMemory( + IN gckOS Os, + IN gctPHYS_ADDR Physical, + IN gctSIZE_T Bytes, + OUT gctPOINTER * Logical + ); + +/* Unmap physical memory from the process space. */ +gceSTATUS +gckOS_UnmapMemory( + IN gckOS Os, + IN gctPHYS_ADDR Physical, + IN gctSIZE_T Bytes, + IN gctPOINTER Logical + ); + +/* Create a new mutex. */ +gceSTATUS +gckOS_CreateMutex( + IN gckOS Os, + OUT gctPOINTER * Mutex + ); + +/* Delete a mutex. */ +gceSTATUS +gckOS_DeleteMutex( + IN gckOS Os, + IN gctPOINTER Mutex + ); + +/* Acquire a mutex. */ +gceSTATUS +gckOS_AcquireMutex( + IN gckOS Os, + IN gctPOINTER Mutex, + IN gctUINT32 Timeout + ); + +/* Release a mutex. */ +gceSTATUS +gckOS_ReleaseMutex( + IN gckOS Os, + IN gctPOINTER Mutex + ); + +/* Create a new recursive mutex. */ +gceSTATUS +gckOS_CreateRecMutex( + IN gckOS Os, + OUT gckRecursiveMutex *Mutex + ); + +/* Delete a recursive mutex. */ +gceSTATUS +gckOS_DeleteRecMutex( + IN gckOS Os, + IN gckRecursiveMutex Mutex + ); + +/* Acquire a recursive mutex. */ +gceSTATUS +gckOS_AcquireRecMutex( + IN gckOS Os, + IN gckRecursiveMutex Mutex, + IN gctUINT32 Timeout + ); + +/* Release a recursive mutex. */ +gceSTATUS +gckOS_ReleaseRecMutex( + IN gckOS Os, + IN gckRecursiveMutex Mutex + ); + +/* Atomically exchange a pair of 32-bit values. */ +gceSTATUS +gckOS_AtomicExchange( + IN gckOS Os, + IN OUT gctUINT32_PTR Target, + IN gctUINT32 NewValue, + OUT gctUINT32_PTR OldValue + ); + +/* Atomically exchange a pair of pointers. */ +gceSTATUS +gckOS_AtomicExchangePtr( + IN gckOS Os, + IN OUT gctPOINTER * Target, + IN gctPOINTER NewValue, + OUT gctPOINTER * OldValue + ); + +/* Update video memory usage. */ +gceSTATUS +gckOS_UpdateVidMemUsage( + IN gckOS Os, + IN gctBOOL IsAllocated, + IN gctSIZE_T Bytes + ); + +/******************************************************************************* +** +** gckOS_AtomConstruct +** +** Create an atom. +** +** INPUT: +** +** gckOS Os +** Pointer to a gckOS object. +** +** OUTPUT: +** +** gctPOINTER * Atom +** Pointer to a variable receiving the constructed atom. +*/ +gceSTATUS +gckOS_AtomConstruct( + IN gckOS Os, + OUT gctPOINTER * Atom + ); + +/******************************************************************************* +** +** gckOS_AtomDestroy +** +** Destroy an atom. +** +** INPUT: +** +** gckOS Os +** Pointer to a gckOS object. +** +** gctPOINTER Atom +** Pointer to the atom to destroy. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gckOS_AtomDestroy( + IN gckOS Os, + OUT gctPOINTER Atom + ); + +/******************************************************************************* +** +** gckOS_AtomGet +** +** Get the 32-bit value protected by an atom. +** +** INPUT: +** +** gckOS Os +** Pointer to a gckOS object. +** +** gctPOINTER Atom +** Pointer to the atom. +** +** OUTPUT: +** +** gctINT32_PTR Value +** Pointer to a variable the receives the value of the atom. +*/ +gceSTATUS +gckOS_AtomGet( + IN gckOS Os, + IN gctPOINTER Atom, + OUT gctINT32_PTR Value + ); + +/******************************************************************************* +** +** gckOS_AtomIncrement +** +** Atomically increment the 32-bit integer value inside an atom. +** +** INPUT: +** +** gckOS Os +** Pointer to a gckOS object. +** +** gctPOINTER Atom +** Pointer to the atom. +** +** OUTPUT: +** +** gctINT32_PTR Value +** Pointer to a variable the receives the original value of the atom. +*/ +gceSTATUS +gckOS_AtomIncrement( + IN gckOS Os, + IN gctPOINTER Atom, + OUT gctINT32_PTR Value + ); + +/******************************************************************************* +** +** gckOS_AtomDecrement +** +** Atomically decrement the 32-bit integer value inside an atom. +** +** INPUT: +** +** gckOS Os +** Pointer to a gckOS object. +** +** gctPOINTER Atom +** Pointer to the atom. +** +** OUTPUT: +** +** gctINT32_PTR Value +** Pointer to a variable the receives the original value of the atom. +*/ +gceSTATUS +gckOS_AtomDecrement( + IN gckOS Os, + IN gctPOINTER Atom, + OUT gctINT32_PTR Value + ); + +/* Delay a number of microseconds. */ +gceSTATUS +gckOS_Delay( + IN gckOS Os, + IN gctUINT32 Delay + ); + +/* Delay a number of microseconds. */ +gceSTATUS gckOS_Udelay( + IN gckOS Os, + IN gctUINT32 Delay + ); + +/* Memory barrier. */ +gceSTATUS +gckOS_MemoryBarrier( + IN gckOS Os, + IN gctPOINTER Address + ); + +/* Map user pointer. */ +gceSTATUS +gckOS_MapUserPointer( + IN gckOS Os, + IN gctPOINTER Pointer, + IN gctSIZE_T Size, + OUT gctPOINTER * KernelPointer + ); + +/* Unmap user pointer. */ +gceSTATUS +gckOS_UnmapUserPointer( + IN gckOS Os, + IN gctPOINTER Pointer, + IN gctSIZE_T Size, + IN gctPOINTER KernelPointer + ); + +gceSTATUS +gckOS_ClockOff( + IN gckOS Os, + IN gctBOOL disableClk, + IN gctBOOL disablePwr + ); + +gceSTATUS +gckOS_ClockOn( + IN gckOS Os, + IN gctBOOL enableClk, + IN gctBOOL enablePwr, + IN gctUINT64 Frequency + ); + +gceSTATUS +gckOS_PowerOff( + IN gckOS Os + ); + +gceSTATUS +gckOS_PowerOn( + IN gckOS Os + ); + +gceSTATUS +gckOS_PowerOffWhenIdle( + IN gckOS Os, + IN gctBOOL needProfile + ); + +gceSTATUS +gckOS_Reset( + IN gckOS Os + ); + +gceSTATUS +gckOS_SetConstraint( + IN gckOS Os, + IN gctBOOL enableDVFM, + IN gctBOOL enableLPM + ); + +gceSTATUS +gckOS_UnSetConstraint( + IN gckOS Os, + IN gctBOOL enableDVFM, + IN gctBOOL enableLPM + ); + +gceSTATUS +gckOS_NotifyIdle( + IN gckOS Os, + IN gctBOOL Idle + ); + +gctUINT32 +gckOS_GetTicks( + void + ); + +gceSTATUS +gckOS_IdleProfile( + IN gckOS Os, + IN OUT gctUINT32* Timeslice, + OUT gctUINT32* IdleTime, + OUT gctUINT32* StateSwitchTimes + ); + +gceSTATUS gckOS_DumpToFile( + IN gckOS Os, + IN gctCONST_STRING filename, + IN gctPOINTER logical, + IN gctSIZE_T size + ); + +#ifdef __QNXNTO__ +/* Map user physical address. */ +gceSTATUS +gckOS_MapUserPhysical( + IN gckOS Os, + IN gctPHYS_ADDR Phys, + OUT gctPOINTER * KernelPointer + ); + +/* Allocate from user's shared pool. */ +gceSTATUS +gckOS_AllocateNonPagedMemoryShmPool( + IN gckOS Os, + IN gctBOOL InUserSpace, + IN gctUINT32 Pid, + IN gctHANDLE Handle, + IN OUT gctSIZE_T * Bytes, + OUT gctPHYS_ADDR * Physical, + OUT gctPOINTER * Logical + ); +#endif + +gceSTATUS +gckOS_SuspendInterrupt( + IN gckOS Os + ); + +gceSTATUS +gckOS_ResumeInterrupt( + IN gckOS Os + ); + +/* Get the base address for the physical memory. */ +gceSTATUS +gckOS_GetBaseAddress( + IN gckOS Os, + OUT gctUINT32_PTR BaseAddress + ); + +/* Perform a memory copy. */ +gceSTATUS +gckOS_MemCopy( + IN gctPOINTER Destination, + IN gctCONST_POINTER Source, + IN gctSIZE_T Bytes + ); + +/* Zero memory. */ +gceSTATUS +gckOS_ZeroMemory( + IN gctPOINTER Memory, + IN gctSIZE_T Bytes + ); + +/* Device I/O control to the kernel HAL layer. */ +gceSTATUS +gckOS_DeviceControl( + IN gckOS Os, + IN gctBOOL FromUser, + IN gctUINT32 IoControlCode, + IN gctPOINTER InputBuffer, + IN gctSIZE_T InputBufferSize, + OUT gctPOINTER OutputBuffer, + IN gctSIZE_T OutputBufferSize + ); + +gceSTATUS gckOS_FreeProcessResource(IN gckOS os, gctUINT32 pid); + +/******************************************************************************* +** +** gckOS_GetProcessID +** +** Get current process ID. +** +** INPUT: +** +** Nothing. +** +** OUTPUT: +** +** gctUINT32_PTR ProcessID +** Pointer to the variable that receives the process ID. +*/ +gceSTATUS +gckOS_GetProcessID( + OUT gctUINT32_PTR ProcessID + ); + +/******************************************************************************* +** +** gckOS_GetThreadID +** +** Get current thread ID. +** +** INPUT: +** +** Nothing. +** +** OUTPUT: +** +** gctUINT32_PTR ThreadID +** Pointer to the variable that receives the thread ID. +*/ +gceSTATUS +gckOS_GetThreadID( + OUT gctUINT32_PTR ThreadID + ); + +/******************************************************************************\ +********************************** Signal Object ********************************* +\******************************************************************************/ + +/* User signal command codes. */ +typedef enum _gceUSER_SIGNAL_COMMAND_CODES +{ + gcvUSER_SIGNAL_CREATE, + gcvUSER_SIGNAL_DESTROY, + gcvUSER_SIGNAL_SIGNAL, + gcvUSER_SIGNAL_WAIT, +} +gceUSER_SIGNAL_COMMAND_CODES; + +/* Create a signal. */ +gceSTATUS +gckOS_CreateSignal( + IN gckOS Os, + IN gctBOOL ManualReset, + OUT gctSIGNAL * Signal + ); + +/* Destroy a signal. */ +gceSTATUS +gckOS_DestroySignal( + IN gckOS Os, + IN gctSIGNAL Signal + ); + +/* Signal a signal. */ +gceSTATUS +gckOS_Signal( + IN gckOS Os, + IN gctSIGNAL Signal, + IN gctBOOL State + ); + +/* Wait for a signal. */ +gceSTATUS +gckOS_WaitSignal( + IN gckOS Os, + IN gctSIGNAL Signal, + IN gctUINT32 Wait + ); + +/* Wait for a signal. */ +gceSTATUS +gckOS_WaitSignalNoInterruptible( + IN gckOS Os, + IN gctSIGNAL Signal, + IN gctUINT32 Wait + ); + +/* Map a user signal to the kernel space. */ +gceSTATUS +gckOS_MapSignal( + IN gckOS Os, + IN gctSIGNAL Signal, + IN gctHANDLE Process, + OUT gctSIGNAL * MappedSignal + ); + +/* UnMap a user signal */ +gceSTATUS +gckOS_UnMapSignal( + IN gckOS Os, + IN gctSIGNAL MappedSignal + ); + +/* Map user memory. */ +gceSTATUS +gckOS_MapUserMemory( + IN gckOS Os, + IN gctPOINTER Memory, + IN gctSIZE_T Size, + OUT gctPOINTER * Info, + OUT gctUINT32_PTR Address + ); + +/* Unmap user memory. */ +gceSTATUS +gckOS_UnmapUserMemory( + IN gckOS Os, + IN gctPOINTER Memory, + IN gctSIZE_T Size, + IN gctPOINTER Info, + IN gctUINT32 Address + ); + +#ifdef ANDROID_VERSION_ECLAIR +gceSTATUS +gcoOS_FlushCache( + int fd, + int offset, + int size + ); +#endif +#if !USE_NEW_LINUX_SIGNAL +/* Create signal to be used in the user space. */ +gceSTATUS +gckOS_CreateUserSignal( + IN gckOS Os, + IN gctBOOL ManualReset, + IN gceSIGNAL_TYPE SignalType, + OUT gctINT * SignalID + ); + +/* Destroy signal used in the user space. */ +gceSTATUS +gckOS_DestroyUserSignal( + IN gckOS Os, + IN gctINT SignalID + ); + +/* Wait for signal used in the user space. */ +gceSTATUS +gckOS_WaitUserSignal( + IN gckOS Os, + IN gctINT SignalID, + IN gctUINT32 Wait + ); + +/* Signal a signal used in the user space. */ +gceSTATUS +gckOS_SignalUserSignal( + IN gckOS Os, + IN gctINT SignalID, + IN gctBOOL State + ); +#endif /* USE_NEW_LINUX_SIGNAL */ + +/* Set a signal owned by a process. */ +#if defined(__QNXNTO__) +gceSTATUS +gckOS_UserSignal( + IN gckOS Os, + IN gctSIGNAL Signal, + IN gctINT Recvid, + IN gctINT Coid + ); +#else +gceSTATUS +gckOS_UserSignal( + IN gckOS Os, + IN gctSIGNAL Signal, + IN gctHANDLE Process + ); +#endif + +/******************************************************************************\ +** Cache Support +*/ + +gceSTATUS +gckOS_CacheFlush( + gckOS Os, + gctHANDLE ProcessId, + gctPOINTER Logical, + gctSIZE_T Bytes + ); + +gceSTATUS +gckOS_CacheInvalidate( + gckOS Os, + gctHANDLE ProcessId, + gctPOINTER Logical, + gctSIZE_T Bytes + ); + +/******************************************************************************\ +** Debug Support +*/ + +void +gckOS_SetDebugLevel( + IN gctUINT32 Level + ); + +void +gckOS_SetDebugZone( + IN gctUINT32 Zone + ); + +void +gckOS_SetDebugLevelZone( + IN gctUINT32 Level, + IN gctUINT32 Zone + ); + +void +gckOS_SetDebugZones( + IN gctUINT32 Zones, + IN gctBOOL Enable + ); + +void +gckOS_SetDebugFile( + IN gctCONST_STRING FileName + ); + +/******************************************************************************* +** Broadcast interface. +*/ + +typedef enum _gceBROADCAST +{ + /* GPU might be idle. */ + gcvBROADCAST_GPU_IDLE, + + /* A commit is going to happen. */ + gcvBROADCAST_GPU_COMMIT, + + /* GPU seems to be stuck. */ + gcvBROADCAST_GPU_STUCK, + + /* First process gets attached. */ + gcvBROADCAST_FIRST_PROCESS, + + /* Last process gets detached. */ + gcvBROADCAST_LAST_PROCESS, + + /* AXI bus error. */ + gcvBROADCAST_AXI_BUS_ERROR, +} +gceBROADCAST; + +gceSTATUS +gckOS_Broadcast( + IN gckOS Os, + IN gckHARDWARE Hardware, + IN gceBROADCAST Reason + ); + +/******************************************************************************* +** +** gckOS_SetGPUPower +** +** Set the power of the GPU on or off. +** +** INPUT: +** +** gckOS Os +** Pointer to a gckOS object.? +** +** gctBOOL Power +** gcvTRUE to turn on the power, or gcvFALSE to turn off the power. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gckOS_SetGPUPower( + IN gckOS Os, + IN gctBOOL Clock, + IN gctBOOL Power + ); + +/******************************************************************************* +** Semaphores. +*/ + +/* Create a new semaphore. */ +gceSTATUS +gckOS_CreateSemaphore( + IN gckOS Os, + OUT gctPOINTER * Semaphore + ); + +/* Delete a semahore. */ +gceSTATUS +gckOS_DestroySemaphore( + IN gckOS Os, + IN gctPOINTER Semaphore + ); + +/* Acquire a semahore. */ +gceSTATUS +gckOS_AcquireSemaphore( + IN gckOS Os, + IN gctPOINTER Semaphore + ); + +/* Release a semahore. */ +gceSTATUS +gckOS_ReleaseSemaphore( + IN gckOS Os, + IN gctPOINTER Semaphore + ); + +/******************************************************************************\ +********************************* gckHEAP Object ******************************** +\******************************************************************************/ + +typedef struct _gckHEAP * gckHEAP; + +/* Construct a new gckHEAP object. */ +gceSTATUS +gckHEAP_Construct( + IN gckOS Os, + IN gctSIZE_T AllocationSize, + OUT gckHEAP * Heap + ); + +/* Destroy an gckHEAP object. */ +gceSTATUS +gckHEAP_Destroy( + IN gckHEAP Heap + ); + +/* Allocate memory. */ +gceSTATUS +gckHEAP_Allocate( + IN gckHEAP Heap, + IN gctSIZE_T Bytes, + OUT gctPOINTER * Node + ); + +/* Free memory. */ +gceSTATUS +gckHEAP_Free( + IN gckHEAP Heap, + IN gctPOINTER Node + ); + +/* Profile the heap. */ +gceSTATUS +gckHEAP_ProfileStart( + IN gckHEAP Heap + ); + +gceSTATUS +gckHEAP_ProfileEnd( + IN gckHEAP Heap, + IN gctCONST_STRING Title + ); + +#if defined gcdHAL_TEST +gceSTATUS +gckHEAP_Test( + IN gckHEAP Heap, + IN gctSIZE_T Vectors, + IN gctSIZE_T MaxSize + ); +#endif + +/******************************************************************************\ +******************************** gckVIDMEM Object ****************************** +\******************************************************************************/ + +typedef struct _gckVIDMEM * gckVIDMEM; +typedef union _gcuVIDMEM_NODE * gcuVIDMEM_NODE_PTR; +typedef struct _gckKERNEL * gckKERNEL; + +/* Construct a new gckVIDMEM object. */ +gceSTATUS +gckVIDMEM_Construct( + IN gckOS Os, + IN gctUINT32 BaseAddress, + IN gctSIZE_T Bytes, + IN gctSIZE_T Threshold, + IN gctSIZE_T Banking, + OUT gckVIDMEM * Memory + ); + +/* Destroy an gckVDIMEM object. */ +gceSTATUS +gckVIDMEM_Destroy( + IN gckVIDMEM Memory + ); + +/* Allocate rectangular memory. */ +gceSTATUS +gckVIDMEM_Allocate( + IN gckVIDMEM Memory, + IN gctUINT Width, + IN gctUINT Height, + IN gctUINT Depth, + IN gctUINT BytesPerPixel, + IN gctUINT32 Alignment, + IN gceSURF_TYPE Type, +#ifdef __QNXNTO__ + IN gctHANDLE Handle, +#endif + OUT gcuVIDMEM_NODE_PTR * Node + ); + +/* Allocate linear memory. */ +gceSTATUS +gckVIDMEM_AllocateLinear( + IN gckVIDMEM Memory, + IN gctSIZE_T Bytes, + IN gctUINT32 Alignment, + IN gceSURF_TYPE Type, +#ifdef __QNXNTO__ + IN gctHANDLE Handle, +#endif + OUT gcuVIDMEM_NODE_PTR * Node + ); + +/* Free memory. */ +gceSTATUS +gckVIDMEM_Free( + IN gcuVIDMEM_NODE_PTR Node + ); + +/* Lock memory. */ +gceSTATUS +gckVIDMEM_Lock( + IN gcuVIDMEM_NODE_PTR Node, + OUT gctUINT32 * Address + ); + +/* Unlock memory. */ +gceSTATUS +gckVIDMEM_Unlock( + IN gcuVIDMEM_NODE_PTR Node, + IN gceSURF_TYPE Type, + IN OUT gctBOOL * Asynchroneous + ); + +/* Construct a gcuVIDMEM_NODE union for virtual memory. */ +gceSTATUS +gckVIDMEM_ConstructVirtual( + IN gckKERNEL Kernel, + IN gctBOOL Contiguous, + IN gctSIZE_T Bytes, +#ifdef __QNXNTO__ + IN gctHANDLE Handle, +#endif + OUT gcuVIDMEM_NODE_PTR * Node + ); + +/* Destroy a gcuVIDMEM_NODE union for virtual memory. */ +gceSTATUS +gckVIDMEM_DestroyVirtual( + IN gcuVIDMEM_NODE_PTR Node + ); + +#ifdef __QNXNTO__ +/* Set the allocating process' PID for this node. */ +gceSTATUS +gckVIDMEM_SetPID( + IN gcuVIDMEM_NODE_PTR Node, + IN gctUINT32 Pid); +#endif + +/******************************************************************************\ +******************************** gckKERNEL Object ****************************** +\******************************************************************************/ + +struct _gcsHAL_INTERFACE; + +/* Notifications. */ +typedef enum _gceNOTIFY +{ + gcvNOTIFY_INTERRUPT, + gcvNOTIFY_COMMAND_QUEUE, +} +gceNOTIFY; + +/* Event locations. */ +typedef enum _gceKERNEL_WHERE +{ + gcvKERNEL_COMMAND, + gcvKERNEL_VERTEX, + gcvKERNEL_TRIANGLE, + gcvKERNEL_TEXTURE, + gcvKERNEL_PIXEL, +} +gceKERNEL_WHERE; + +/* Flush flags. */ +typedef enum _gceKERNEL_FLUSH +{ + gcvFLUSH_COLOR = 0x01, + gcvFLUSH_DEPTH = 0x02, + gcvFLUSH_TEXTURE = 0x04, + gcvFLUSH_2D = 0x08, + gcvFLUSH_ALL = gcvFLUSH_COLOR + | gcvFLUSH_DEPTH + | gcvFLUSH_TEXTURE + | gcvFLUSH_2D, +} +gceKERNEL_FLUSH; + +/* Construct a new gckKERNEL object. */ +gceSTATUS +gckKERNEL_Construct( + IN gckOS Os, + IN gctPOINTER Context, + OUT gckKERNEL * Kernel + ); + +/* Destroy an gckKERNEL object. */ +gceSTATUS +gckKERNEL_Destroy( + IN gckKERNEL Kernel + ); + +/* Dispatch a user-level command. */ +gceSTATUS +gckKERNEL_Dispatch( + IN gckKERNEL Kernel, + IN gctBOOL FromUser, + IN OUT struct _gcsHAL_INTERFACE * Interface + ); + +/* Query the video memory. */ +gceSTATUS +gckKERNEL_QueryVideoMemory( + IN gckKERNEL Kernel, + OUT struct _gcsHAL_INTERFACE * Interface + ); + +/* Lookup the gckVIDMEM object for a pool. */ +gceSTATUS +gckKERNEL_GetVideoMemoryPool( + IN gckKERNEL Kernel, + IN gcePOOL Pool, + OUT gckVIDMEM * VideoMemory + ); + +/* Map video memory. */ +gceSTATUS +gckKERNEL_MapVideoMemory( + IN gckKERNEL Kernel, + IN gctBOOL InUserSpace, + IN gctUINT32 Address, +#ifdef __QNXNTO__ + IN gctUINT32 Pid, + IN gctUINT32 Bytes, +#endif + OUT gctPOINTER * Logical + ); + +#ifdef __QNXNTO__ +/* Unmap video memory. */ +gceSTATUS +gckKERNEL_UnmapVideoMemory( + IN gckKERNEL Kernel, + IN gctPOINTER Logical, + IN gctUINT32 Pid, + IN gctUINT32 Bytes + ); +#endif + +/* Map memory. */ +gceSTATUS +gckKERNEL_MapMemory( + IN gckKERNEL Kernel, + IN gctPHYS_ADDR Physical, + IN gctSIZE_T Bytes, + OUT gctPOINTER * Logical + ); + +/* Unmap memory. */ +gceSTATUS +gckKERNEL_UnmapMemory( + IN gckKERNEL Kernel, + IN gctPHYS_ADDR Physical, + IN gctSIZE_T Bytes, + IN gctPOINTER Logical + ); + +/* Notification of events. */ +gceSTATUS +gckKERNEL_Notify( + IN gckKERNEL Kernel, + IN gceNOTIFY Notifcation, + IN gctBOOL Data + ); + +gceSTATUS +gckKERNEL_QuerySettings( + IN gckKERNEL Kernel, + OUT gcsKERNEL_SETTINGS * Settings + ); + +/******************************************************************************* +** +** gckKERNEL_Recovery +** +** Try to recover the GPU from a fatal error. +** +** INPUT: +** +** gckKERNEL Kernel +** Pointer to an gckKERNEL object. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gckKERNEL_Recovery( + IN gckKERNEL Kernel + ); + +/******************************************************************************\ +******************************* gckHARDWARE Object ***************************** +\******************************************************************************/ + +/* Construct a new gckHARDWARE object. */ +gceSTATUS +gckHARDWARE_Construct( + IN gckOS Os, + OUT gckHARDWARE * Hardware + ); + +/* Destroy an gckHARDWARE object. */ +gceSTATUS +gckHARDWARE_Destroy( + IN gckHARDWARE Hardware + ); + +/* Query system memory requirements. */ +gceSTATUS +gckHARDWARE_QuerySystemMemory( + IN gckHARDWARE Hardware, + OUT gctSIZE_T * SystemSize, + OUT gctUINT32 * SystemBaseAddress + ); + +/* Build virtual address. */ +gceSTATUS +gckHARDWARE_BuildVirtualAddress( + IN gckHARDWARE Hardware, + IN gctUINT32 Index, + IN gctUINT32 Offset, + OUT gctUINT32 * Address + ); + +/* Query command buffer requirements. */ +gceSTATUS +gckHARDWARE_QueryCommandBuffer( + IN gckHARDWARE Hardware, + OUT gctSIZE_T * Alignment, + OUT gctSIZE_T * ReservedHead, + OUT gctSIZE_T * ReservedTail + ); + +/* Add a WAIT/LINK pair in the command queue. */ +gceSTATUS +gckHARDWARE_WaitLink( + IN gckHARDWARE Hardware, + IN gctPOINTER Logical, + IN gctUINT32 Offset, + IN OUT gctSIZE_T * Bytes, + OUT gctPOINTER * Wait, + OUT gctSIZE_T * WaitBytes + ); + +/* Kickstart the command processor. */ +gceSTATUS +gckHARDWARE_Execute( + IN gckHARDWARE Hardware, + IN gctPOINTER Logical, +#ifdef __QNXNTO__ + IN gctPOINTER Physical, + IN gctBOOL PhysicalAddresses, +#endif + IN gctSIZE_T Bytes + ); + +/* Add an END command in the command queue. */ +gceSTATUS +gckHARDWARE_End( + IN gckHARDWARE Hardware, + IN gctPOINTER Logical, + IN OUT gctSIZE_T * Bytes + ); + +/* Add a NOP command in the command queue. */ +gceSTATUS +gckHARDWARE_Nop( + IN gckHARDWARE Hardware, + IN gctPOINTER Logical, + IN OUT gctSIZE_T * Bytes + ); + +/* Add a WAIT command in the command queue. */ +gceSTATUS +gckHARDWARE_Wait( + IN gckHARDWARE Hardware, + IN gctPOINTER Logical, + IN gctUINT32 Count, + IN OUT gctSIZE_T * Bytes + ); + +/* Add a PIPESELECT command in the command queue. */ +gceSTATUS +gckHARDWARE_PipeSelect( + IN gckHARDWARE Hardware, + IN gctPOINTER Logical, + IN gctUINT32 Pipe, + IN OUT gctSIZE_T * Bytes + ); + +/* Add a LINK command in the command queue. */ +gceSTATUS +gckHARDWARE_Link( + IN gckHARDWARE Hardware, + IN gctPOINTER Logical, + IN gctPOINTER FetchAddress, + IN gctSIZE_T FetchSize, + IN OUT gctSIZE_T * Bytes + ); + +/* Add an EVENT command in the command queue. */ +gceSTATUS +gckHARDWARE_Event( + IN gckHARDWARE Hardware, + IN gctPOINTER Logical, + IN gctUINT8 Event, + IN gceKERNEL_WHERE FromWhere, + IN OUT gctSIZE_T * Bytes + ); + +/* Query the available memory. */ +gceSTATUS +gckHARDWARE_QueryMemory( + IN gckHARDWARE Hardware, + OUT gctSIZE_T * InternalSize, + OUT gctUINT32 * InternalBaseAddress, + OUT gctUINT32 * InternalAlignment, + OUT gctSIZE_T * ExternalSize, + OUT gctUINT32 * ExternalBaseAddress, + OUT gctUINT32 * ExternalAlignment, + OUT gctUINT32 * HorizontalTileSize, + OUT gctUINT32 * VerticalTileSize + ); + +/* Query the identity of the hardware. */ +gceSTATUS +gckHARDWARE_QueryChipIdentity( + IN gckHARDWARE Hardware, + OUT gceCHIPMODEL* ChipModel, + OUT gctUINT32* ChipRevision, + OUT gctUINT32* ChipFeatures, + OUT gctUINT32* ChipMinorFeatures, + OUT gctUINT32* ChipMinorFeatures1 + ); + +/* Query the specifications sof the hardware. */ +gceSTATUS +gckHARDWARE_QueryChipSpecs( + IN gckHARDWARE Hardware, + OUT gctUINT32_PTR StreamCount, + OUT gctUINT32_PTR RegisterMax, + OUT gctUINT32_PTR ThreadCount, + OUT gctUINT32_PTR ShaderCoreCount, + OUT gctUINT32_PTR VertexCacheSize, + OUT gctUINT32_PTR VertexOutputBufferSize + ); + +/* Convert an API format. */ +gceSTATUS +gckHARDWARE_ConvertFormat( + IN gckHARDWARE Hardware, + IN gceSURF_FORMAT Format, + OUT gctUINT32 * BitsPerPixel, + OUT gctUINT32 * BytesPerTile + ); + +/* Split a harwdare specific address into API stuff. */ +gceSTATUS +gckHARDWARE_SplitMemory( + IN gckHARDWARE Hardware, + IN gctUINT32 Address, + OUT gcePOOL * Pool, + OUT gctUINT32 * Offset + ); + +/* Align size to tile boundary. */ +gceSTATUS +gckHARDWARE_AlignToTile( + IN gckHARDWARE Hardware, + IN gceSURF_TYPE Type, + IN OUT gctUINT32_PTR Width, + IN OUT gctUINT32_PTR Height, + OUT gctBOOL_PTR SuperTiled + ); + +/* Update command queue tail pointer. */ +gceSTATUS +gckHARDWARE_UpdateQueueTail( + IN gckHARDWARE Hardware, + IN gctPOINTER Logical, + IN gctUINT32 Offset + ); + +/* Convert logical address to hardware specific address. */ +gceSTATUS +gckHARDWARE_ConvertLogical( + IN gckHARDWARE Hardware, + IN gctPOINTER Logical, + OUT gctUINT32 * Address + ); + +#ifdef __QNXNTO__ +/* Convert physical address to hardware specific address. */ +gceSTATUS +gckHARDWARE_ConvertPhysical( + IN gckHARDWARE Hardware, + IN gctPHYS_ADDR Physical, + OUT gctUINT32 * Address + ); +#endif + +/* Interrupt manager. */ +gceSTATUS +gckHARDWARE_Interrupt( + IN gckHARDWARE Hardware, + IN gctBOOL InterruptValid + ); + +/* Program MMU. */ +gceSTATUS +gckHARDWARE_SetMMU( + IN gckHARDWARE Hardware, + IN gctPOINTER Logical + ); + +/* Flush the MMU. */ +gceSTATUS +gckHARDWARE_FlushMMU( + IN gckHARDWARE Hardware + ); + +/* Get idle register. */ +gceSTATUS +gckHARDWARE_GetIdle( + IN gckHARDWARE Hardware, + IN gctBOOL Wait, + OUT gctUINT32 * Data + ); + +/* Flush the caches. */ +gceSTATUS +gckHARDWARE_Flush( + IN gckHARDWARE Hardware, + IN gceKERNEL_FLUSH Flush, + IN gctPOINTER Logical, + IN OUT gctSIZE_T * Bytes + ); + +/* Enable/disable fast clear. */ +gceSTATUS +gckHARDWARE_SetFastClear( + IN gckHARDWARE Hardware, + IN gctINT Enable, + IN gctINT Compression + ); + +gceSTATUS +gckHARDWARE_ReadInterrupt( + IN gckHARDWARE Hardware, + OUT gctUINT32_PTR IDs + ); + +/* Power management. */ +gceSTATUS +gckHARDWARE_SetPowerManagementState( + IN gckHARDWARE Hardware, + IN gceCHIPPOWERSTATE State + ); + +gceSTATUS +gckHARDWARE_QueryPowerManagementState( + IN gckHARDWARE Hardware, + OUT gceCHIPPOWERSTATE* State + ); + +/* Profile 2D Engine. */ +gceSTATUS +gckHARDWARE_ProfileEngine2D( + IN gckHARDWARE Hardware, + OUT gcs2D_PROFILE_PTR Profile + ); + +gceSTATUS +gckHARDWARE_InitializeHardware( + IN gckHARDWARE Hardware + ); + +gceSTATUS +gckHARDWARE_Reset( + IN gckHARDWARE Hardware + ); + +/******************************************************************************\ +***************************** gckINTERRUPT Object ****************************** +\******************************************************************************/ + +typedef struct _gckINTERRUPT * gckINTERRUPT; + +typedef gceSTATUS (* gctINTERRUPT_HANDLER)( + IN gckKERNEL Kernel + ); + +gceSTATUS +gckINTERRUPT_Construct( + IN gckKERNEL Kernel, + OUT gckINTERRUPT * Interrupt + ); + +gceSTATUS +gckINTERRUPT_Destroy( + IN gckINTERRUPT Interrupt + ); + +gceSTATUS +gckINTERRUPT_SetHandler( + IN gckINTERRUPT Interrupt, + IN OUT gctINT32_PTR Id, + IN gctINTERRUPT_HANDLER Handler + ); + +gceSTATUS +gckINTERRUPT_Notify( + IN gckINTERRUPT Interrupt, + IN gctBOOL Valid + ); + +/******************************************************************************\ +******************************** gckEVENT Object ******************************* +\******************************************************************************/ + +typedef struct _gckEVENT * gckEVENT; + +/* Construct a new gckEVENT object. */ +gceSTATUS +gckEVENT_Construct( + IN gckKERNEL Kernel, + OUT gckEVENT * Event + ); + +/* Destroy an gckEVENT object. */ +gceSTATUS +gckEVENT_Destroy( + IN gckEVENT Event + ); + +/* Schedule a FreeNonPagedMemory event. */ +gceSTATUS +gckEVENT_FreeNonPagedMemory( + IN gckEVENT Event, + IN gctSIZE_T Bytes, + IN gctPHYS_ADDR Physical, + IN gctPOINTER Logical, + IN gceKERNEL_WHERE FromWhere + ); + +/* Schedule a FreeContiguousMemory event. */ +gceSTATUS +gckEVENT_FreeContiguousMemory( + IN gckEVENT Event, + IN gctSIZE_T Bytes, + IN gctPHYS_ADDR Physical, + IN gctPOINTER Logical, + IN gceKERNEL_WHERE FromWhere + ); + +/* Schedule a FreeVideoMemory event. */ +gceSTATUS +gckEVENT_FreeVideoMemory( + IN gckEVENT Event, + IN gcuVIDMEM_NODE_PTR VideoMemory, + IN gceKERNEL_WHERE FromWhere + ); + +/* Schedule a signal event. */ +gceSTATUS +gckEVENT_Signal( + IN gckEVENT Event, + IN gctSIGNAL Signal, + IN gceKERNEL_WHERE FromWhere + ); + +/* Schedule an Unlock event. */ +gceSTATUS +gckEVENT_Unlock( + IN gckEVENT Event, + IN gceKERNEL_WHERE FromWhere, + IN gcuVIDMEM_NODE_PTR Node, + IN gceSURF_TYPE Type + ); + +gceSTATUS +gckEVENT_Submit( + IN gckEVENT Event, + IN gctBOOL Wait + ); + +struct _gcsQUEUE; + +/* Commit an event queue. */ +gceSTATUS +gckEVENT_Commit( + IN gckEVENT Event, + IN struct _gcsQUEUE * Queue + ); + +/* Event callback routine. */ +gceSTATUS +gckEVENT_Notify( + IN gckEVENT Event, + IN gctBOOL IsReset + ); + + +/* Event callback routine. */ +gceSTATUS +gckEVENT_Interrupt( + IN gckEVENT Event, + IN gctUINT32 IDs + ); + +/* Try to set idle */ +gceSTATUS +gckEVENT_TryToSetIdle( + IN gckEVENT Event + ); +/******************************************************************************\ +******************************* gckCOMMAND Object ****************************** +\******************************************************************************/ + +typedef struct _gckCOMMAND * gckCOMMAND; + +/* Construct a new gckCOMMAND object. */ +gceSTATUS +gckCOMMAND_Construct( + IN gckKERNEL Kernel, + OUT gckCOMMAND * Command + ); + +/* Destroy an gckCOMMAND object. */ +gceSTATUS +gckCOMMAND_Destroy( + IN gckCOMMAND Command + ); + +/* Start the command queue. */ +gceSTATUS +gckCOMMAND_Start( + IN gckCOMMAND Command + ); + +/* Stop the command queue. */ +gceSTATUS +gckCOMMAND_Stop( + IN gckCOMMAND Command + ); + +/* Commit a buffer to the command queue. */ +gceSTATUS +gckCOMMAND_Commit( + IN gckCOMMAND Command, + IN gcoCMDBUF CommandBuffer, + IN gcoCONTEXT Context, + IN gctHANDLE Process + ); + +/* Reserve space in the command buffer. */ +gceSTATUS +gckCOMMAND_Reserve( + IN gckCOMMAND Command, + IN gctSIZE_T RequestedBytes, + OUT gctPOINTER * Buffer, + OUT gctSIZE_T * BufferSize + ); + +/* Release reserved space in the command buffer. */ +gceSTATUS +gckCOMMAND_Release( + IN gckCOMMAND Command + ); + +/* Execute reserved space in the command buffer. */ +gceSTATUS +gckCOMMAND_Execute( + IN gckCOMMAND Command, + IN gctSIZE_T RequstedBytes + ); + +/* Stall the command queue. */ +gceSTATUS +gckCOMMAND_Stall( + IN gckCOMMAND Command + ); + +/******************************************************************************\ +********************************* gckMMU Object ******************************** +\******************************************************************************/ + +typedef struct _gckMMU * gckMMU; + +/* Construct a new gckMMU object. */ +gceSTATUS +gckMMU_Construct( + IN gckKERNEL Kernel, + IN gctSIZE_T MmuSize, + OUT gckMMU * Mmu + ); + +/* Destroy an gckMMU object. */ +gceSTATUS +gckMMU_Destroy( + IN gckMMU Mmu + ); + +/* Allocate pages inside the MMU. */ +gceSTATUS +gckMMU_AllocatePages( + IN gckMMU Mmu, + IN gctSIZE_T PageCount, + OUT gctPOINTER * PageTable, + OUT gctUINT32 * Address + ); + +/* Remove a page table from the MMU. */ +gceSTATUS +gckMMU_FreePages( + IN gckMMU Mmu, + IN gctPOINTER PageTable, + IN gctSIZE_T PageCount + ); + +#ifdef __QNXNTO__ +gceSTATUS +gckMMU_InsertNode( + IN gckMMU Mmu, + IN gcuVIDMEM_NODE_PTR Node); + +gceSTATUS +gckMMU_RemoveNode( + IN gckMMU Mmu, + IN gcuVIDMEM_NODE_PTR Node); +#endif + +#ifdef __QNXNTO__ +gceSTATUS +gckMMU_FreeHandleMemory( + IN gckMMU Mmu, + IN gctHANDLE Handle + ); +#endif + +#if defined gcdHAL_TEST +gceSTATUS +gckMMU_Test( + IN gckMMU Mmu, + IN gctSIZE_T Vectors, + IN gctINT MaxSize + ); +#endif + +gceSTATUS +gckHARDWARE_QueryProfileRegisters( + IN gckHARDWARE Hardware, + OUT gcsPROFILER_COUNTERS * Counters + ); + +#ifdef __cplusplus +} +#endif + +#endif /* __gc_hal_h_ */ + diff --git a/native/include_dove/gc_hal_base.h b/native/include_dove/gc_hal_base.h new file mode 100644 index 0000000..c24f8f7 --- /dev/null +++ b/native/include_dove/gc_hal_base.h @@ -0,0 +1,2828 @@ +/**************************************************************************** +* +* Copyright (C) 2005 - 2010 by Vivante Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the license, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +* +*****************************************************************************/ + + + + +#ifndef __gc_hal_base_h_ +#define __gc_hal_base_h_ + +#include "gc_hal_enum.h" +#include "gc_hal_types.h" +#include "gc_hal_dump.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/******************************************************************************\ +****************************** Object Declarations ***************************** +\******************************************************************************/ + +typedef struct _gcoHAL * gcoHAL; +typedef struct _gcoOS * gcoOS; +typedef struct _gco2D * gco2D; +typedef struct _gcoVG * gcoVG; +typedef struct _gco3D * gco3D; +typedef struct _gcoSURF * gcoSURF; +typedef struct _gcsSURF_INFO * gcsSURF_INFO_PTR; +typedef struct _gcsSURF_NODE * gcsSURF_NODE_PTR; +typedef struct _gcsSURF_FORMAT_INFO * gcsSURF_FORMAT_INFO_PTR; +typedef struct _gcsPOINT * gcsPOINT_PTR; +typedef struct _gcsSIZE * gcsSIZE_PTR; +typedef struct _gcsRECT * gcsRECT_PTR; +typedef struct _gcsBOUNDARY * gcsBOUNDARY_PTR; +typedef struct _gcoDUMP * gcoDUMP; +typedef struct _gcoHARDWARE * gcoHARDWARE; + +/******************************************************************************\ +********************************* Enumerations ********************************* +\******************************************************************************/ + +/* Video memory pool type. */ +typedef enum _gcePOOL +{ + gcvPOOL_UNKNOWN, + gcvPOOL_DEFAULT, + gcvPOOL_LOCAL, + gcvPOOL_LOCAL_INTERNAL, + gcvPOOL_LOCAL_EXTERNAL, + gcvPOOL_UNIFIED, + gcvPOOL_SYSTEM, + gcvPOOL_VIRTUAL, + gcvPOOL_USER, + gcvPOOL_CONTIGUOUS +} +gcePOOL; + +/* Blending functions. */ +typedef enum _gceBLEND_FUNCTION +{ + gcvBLEND_ZERO, + gcvBLEND_ONE, + gcvBLEND_SOURCE_COLOR, + gcvBLEND_INV_SOURCE_COLOR, + gcvBLEND_SOURCE_ALPHA, + gcvBLEND_INV_SOURCE_ALPHA, + gcvBLEND_TARGET_COLOR, + gcvBLEND_INV_TARGET_COLOR, + gcvBLEND_TARGET_ALPHA, + gcvBLEND_INV_TARGET_ALPHA, + gcvBLEND_SOURCE_ALPHA_SATURATE, + gcvBLEND_CONST_COLOR, + gcvBLEND_INV_CONST_COLOR, + gcvBLEND_CONST_ALPHA, + gcvBLEND_INV_CONST_ALPHA, +} +gceBLEND_FUNCTION; + +/* Blending modes. */ +typedef enum _gceBLEND_MODE +{ + gcvBLEND_ADD, + gcvBLEND_SUBTRACT, + gcvBLEND_REVERSE_SUBTRACT, + gcvBLEND_MIN, + gcvBLEND_MAX, +} +gceBLEND_MODE; + +/* API flags. */ +typedef enum _gceAPI +{ + gcvAPI_D3D = 0x1, + gcvAPI_OPENGL = 0x2, +} +gceAPI; + +/* Depth modes. */ +typedef enum _gceDEPTH_MODE +{ + gcvDEPTH_NONE, + gcvDEPTH_Z, + gcvDEPTH_W, +} +gceDEPTH_MODE; + +typedef enum _gceWHERE +{ + gcvWHERE_COMMAND, + gcvWHERE_RASTER, + gcvWHERE_PIXEL, +} +gceWHERE; + +typedef enum _gceHOW +{ + gcvHOW_SEMAPHORE = 0x1, + gcvHOW_STALL = 0x2, + gcvHOW_SEMAPHORE_STALL = 0x3, +} +gceHOW; + +typedef enum _gceSIGNAL_TYPE +{ + gcvSIGNAL_NOPE = 0x0, + gcvSIGNAL_CONTEXT_GCU = 0x1, + gcvSIGNAL_CONTEXT = 0x2, + gcvSIGNAL_FENCE_GCU = 0x3, + gcvSIGNAL_FENCE = 0x4, + gcvSIGNAL_DISPLAY_START = 0x5, + gcvSIGNAL_DISPLAY_STOP = 0x6, + gcvSIGNAL_WORKER_THREAD = 0x7, + gcvSIGNAL_SYNC = 0x8, + gcvSIGNAL_SURFACE = 0x9, + gcvSIGNAL_TEXTURE = 0x10, + gcvSIGNAL_STREAM = 0x11, + gcvSIGNAL_INDEX_GROUP = 0x12, + gcvSIGNAL_RESERVE_MEM_GROUP = 0x13, + gcvSIGNAL_CMD_BUFFER = 0x14, + gcvSIGNAL_CONTEXT_BUFFER = 0x15, + gcvSIGNAL_INDEX_DYNAMIC = 0x16, + gcvSIGNAL_STREAM_DYNAMIC = 0x17, + gcvSIGNAL_STALL = 0x18, + gcvSIGNAL_RESERVED +} +gceSIGNAL_TYPE; + +#define gcmSIGNAL_OFFSET 16 + +/******************************************************************************\ +********************************* gcoHAL Object ********************************* +\******************************************************************************/ + +/* Construct a new gcoHAL object. */ +gceSTATUS +gcoHAL_Construct( + IN gctPOINTER Context, + IN gcoOS Os, + OUT gcoHAL * Hal + ); + +/* Destroy an gcoHAL object. */ +gceSTATUS +gcoHAL_Destroy( + IN gcoHAL Hal + ); + +/* Get pointer to gco2D object. */ +gceSTATUS +gcoHAL_Get2DEngine( + IN gcoHAL Hal, + OUT gco2D * Engine + ); + +/* Get pointer to gcoVG object. */ +gceSTATUS +gcoHAL_GetVGEngine( + IN gcoHAL Hal, + OUT gcoVG * Engine + ); + +/* Get pointer to gco3D object. */ +gceSTATUS +gcoHAL_Get3DEngine( + IN gcoHAL Hal, + OUT gco3D * Engine + ); + +/* Verify whether the specified feature is available in hardware. */ +gceSTATUS +gcoHAL_IsFeatureAvailable( + IN gcoHAL Hal, + IN gceFEATURE Feature + ); + +/* Query the identity of the hardware. */ +gceSTATUS +gcoHAL_QueryChipIdentity( + IN gcoHAL Hal, + OUT gceCHIPMODEL* ChipModel, + OUT gctUINT32* ChipRevision, + OUT gctUINT32* ChipFeatures, + OUT gctUINT32* ChipMinorFeatures + ); + +/* Query the amount of video memory. */ +gceSTATUS +gcoHAL_QueryVideoMemory( + IN gcoHAL Hal, + OUT gctPHYS_ADDR * InternalAddress, + OUT gctSIZE_T * InternalSize, + OUT gctPHYS_ADDR * ExternalAddress, + OUT gctSIZE_T * ExternalSize, + OUT gctPHYS_ADDR * ContiguousAddress, + OUT gctSIZE_T * ContiguousSize + ); + +/* Map video memory. */ +gceSTATUS +gcoHAL_MapMemory( + IN gcoHAL Hal, + IN gctPHYS_ADDR Physical, + IN gctSIZE_T NumberOfBytes, + OUT gctPOINTER * Logical + ); + +/* Unmap video memory. */ +gceSTATUS +gcoHAL_UnmapMemory( + IN gcoHAL Hal, + IN gctPHYS_ADDR Physical, + IN gctSIZE_T NumberOfBytes, + IN gctPOINTER Logical + ); + +/* Schedule an unmap of a buffer mapped through its physical address. */ +gceSTATUS +gcoHAL_ScheduleUnmapMemory( + IN gcoHAL Hal, + IN gctPHYS_ADDR Physical, + IN gctSIZE_T NumberOfBytes, + IN gctPOINTER Logical + ); + +/* Schedule an unmap of a user buffer using event mechanism. */ +gceSTATUS +gcoHAL_ScheduleUnmapUserMemory( + IN gcoHAL Hal, + IN gctPOINTER Info, + IN gctSIZE_T Size, + IN gctUINT32 Address, + IN gctPOINTER Memory + ); + +/* Commit the current command buffer. */ +gceSTATUS +gcoHAL_Commit( + IN gcoHAL Hal, + IN gctBOOL Stall + ); + +/* Query the tile capabilities. */ +gceSTATUS +gcoHAL_QueryTiled( + IN gcoHAL Hal, + OUT gctINT32 * TileWidth2D, + OUT gctINT32 * TileHeight2D, + OUT gctINT32 * TileWidth3D, + OUT gctINT32 * TileHeight3D + ); + +gceSTATUS +gcoHAL_Compact( + IN gcoHAL Hal + ); + +gceSTATUS +gcoHAL_ProfileStart( + IN gcoHAL Hal + ); + +gceSTATUS +gcoHAL_ProfileEnd( + IN gcoHAL Hal, + IN gctCONST_STRING Title + ); + +/* Power Management */ +gceSTATUS +gcoHAL_SetPowerManagementState( + IN gcoHAL Hal, + IN gceCHIPPOWERSTATE State + ); + +gceSTATUS +gcoHAL_QueryPowerManagementState( + IN gcoHAL Hal, + OUT gceCHIPPOWERSTATE *State + ); + +/* Set the filter type for filter blit. */ +gceSTATUS +gcoHAL_SetFilterType( + IN gcoHAL Hal, + IN gceFILTER_TYPE FilterType + ); + +gceSTATUS +gcoHAL_GetDump( + IN gcoHAL Hal, + OUT gcoDUMP * Dump + ); + +/* Call the kernel HAL layer. */ +gceSTATUS +gcoHAL_Call( + IN gcoHAL Hal, + IN OUT gcsHAL_INTERFACE_PTR Interface + ); + +/* Schedule an event. */ +gceSTATUS +gcoHAL_ScheduleEvent( + IN gcoHAL Hal, + IN OUT gcsHAL_INTERFACE_PTR Interface + ); + +/* Destroy a surface. */ +gceSTATUS +gcoHAL_DestroySurface( + IN gcoHAL Hal, + IN gcoSURF Surface + ); + +/******************************************************************************\ +********************************** gcoOS Object ********************************* +\******************************************************************************/ + +/* Construct a new gcoOS object. */ +gceSTATUS +gcoOS_Construct( + IN gctPOINTER Context, + OUT gcoOS * Os + ); + +/* Destroy an gcoOS object. */ +gceSTATUS +gcoOS_Destroy( + IN gcoOS Os + ); + +/* Get the base address for the physical memory. */ +gceSTATUS +gcoOS_GetBaseAddress( + IN gcoOS Os, + OUT gctUINT32_PTR BaseAddress + ); + +/* Allocate memory from the heap. */ +gceSTATUS +gcoOS_Allocate( + IN gcoOS Os, + IN gctSIZE_T Bytes, + OUT gctPOINTER * Memory + ); + +/* Free allocated memory. */ +gceSTATUS +gcoOS_Free( + IN gcoOS Os, + IN gctPOINTER Memory + ); + +/* Allocate memory. */ +gceSTATUS +gcoOS_AllocateMemory( + IN gcoOS Os, + IN gctSIZE_T Bytes, + OUT gctPOINTER * Memory + ); + +/* Free memory. */ +gceSTATUS +gcoOS_FreeMemory( + IN gcoOS Os, + IN gctPOINTER Memory + ); + +/* Allocate contiguous memory. */ +gceSTATUS +gcoOS_AllocateContiguous( + IN gcoOS Os, + IN gctBOOL InUserSpace, + IN OUT gctSIZE_T * Bytes, + OUT gctPHYS_ADDR * Physical, + OUT gctPOINTER * Logical + ); + +/* Free contiguous memory. */ +gceSTATUS +gcoOS_FreeContiguous( + IN gcoOS Os, + IN gctPHYS_ADDR Physical, + IN gctPOINTER Logical, + IN gctSIZE_T Bytes + ); + +/* Map user memory. */ +gceSTATUS +gcoOS_MapUserMemory( + IN gcoOS Os, + IN gctPOINTER Memory, + IN gctSIZE_T Size, + OUT gctPOINTER * Info, + OUT gctUINT32_PTR Address + ); + +/* Unmap user memory. */ +gceSTATUS +gcoOS_UnmapUserMemory( + IN gcoOS Os, + IN gctPOINTER Memory, + IN gctSIZE_T Size, + IN gctPOINTER Info, + IN gctUINT32 Address + ); + +/* Device I/O Control call to the kernel HAL layer. */ +gceSTATUS +gcoOS_DeviceControl( + IN gcoOS Os, + IN gctUINT32 IoControlCode, + IN gctPOINTER InputBuffer, + IN gctSIZE_T InputBufferSize, + IN gctPOINTER OutputBuffer, + IN gctSIZE_T OutputBufferSize + ); + +/* Allocate non paged memory. */ +gceSTATUS gcoOS_AllocateNonPagedMemory( + IN gcoOS Os, + IN gctBOOL InUserSpace, + IN OUT gctSIZE_T * Bytes, + OUT gctPHYS_ADDR * Physical, + OUT gctPOINTER * Logical + ); + +/* Free non paged memory. */ +gceSTATUS gcoOS_FreeNonPagedMemory( + IN gcoOS Os, + IN gctSIZE_T Bytes, + IN gctPHYS_ADDR Physical, + IN gctPOINTER Logical + ); + +typedef enum _gceFILE_MODE +{ + gcvFILE_CREATE = 0, + gcvFILE_APPEND, + gcvFILE_READ, + gcvFILE_CREATETEXT, + gcvFILE_APPENDTEXT, + gcvFILE_READTEXT, +} +gceFILE_MODE; + +/* Open a file. */ +gceSTATUS +gcoOS_Open( + IN gcoOS Os, + IN gctCONST_STRING FileName, + IN gceFILE_MODE Mode, + OUT gctFILE * File + ); + +/* Close a file. */ +gceSTATUS +gcoOS_Close( + IN gcoOS Os, + IN gctFILE File + ); + +/* Read data from a file. */ +gceSTATUS +gcoOS_Read( + IN gcoOS Os, + IN gctFILE File, + IN gctSIZE_T ByteCount, + IN gctPOINTER Data, + OUT gctSIZE_T * ByteRead + ); + +/* Write data to a file. */ +gceSTATUS +gcoOS_Write( + IN gcoOS Os, + IN gctFILE File, + IN gctSIZE_T ByteCount, + IN gctCONST_POINTER Data + ); + +typedef enum _gceFILE_WHENCE +{ + gcvFILE_SEEK_SET, + gcvFILE_SEEK_CUR, + gcvFILE_SEEK_END +} +gceFILE_WHENCE; + +/* Set the current position of a file. */ +gceSTATUS +gcoOS_Seek( + IN gcoOS Os, + IN gctFILE File, + IN gctUINT32 Offset, + IN gceFILE_WHENCE Whence + ); + +/* Set the current position of a file. */ +gceSTATUS +gcoOS_SetPos( + IN gcoOS Os, + IN gctFILE File, + IN gctUINT32 Position + ); + +/* Get the current position of a file. */ +gceSTATUS +gcoOS_GetPos( + IN gcoOS Os, + IN gctFILE File, + OUT gctUINT32 * Position + ); + +/* Perform a memory copy. */ +gceSTATUS +gcoOS_MemCopy( + IN gctPOINTER Destination, + IN gctCONST_POINTER Source, + IN gctSIZE_T Bytes + ); + +/* Perform a memory fill. */ +gceSTATUS +gcoOS_MemFill( + IN gctPOINTER Destination, + IN gctUINT8 Filler, + IN gctSIZE_T Bytes + ); + +/* Zero memory. */ +gceSTATUS +gcoOS_ZeroMemory( + IN gctPOINTER Memory, + IN gctSIZE_T Bytes + ); + +/* Find the last occurance of a character inside a string. */ +gceSTATUS +gcoOS_StrFindReverse( + IN gctCONST_STRING String, + IN gctINT8 Character, + OUT gctSTRING * Output + ); + +gceSTATUS +gcoOS_StrLen( + IN gctCONST_STRING String, + OUT gctSIZE_T * Length + ); + +gceSTATUS +gcoOS_StrDup( + IN gcoOS Os, + IN gctCONST_STRING String, + OUT gctSTRING * Target + ); + +/* Copy a string. */ +gceSTATUS +gcoOS_StrCopySafe( + IN gctSTRING Destination, + IN gctSIZE_T DestinationSize, + IN gctCONST_STRING Source + ); + +/* Append a string. */ +gceSTATUS +gcoOS_StrCatSafe( + IN gctSTRING Destination, + IN gctSIZE_T DestinationSize, + IN gctCONST_STRING Source + ); + +/* Compare two strings. */ +gceSTATUS +gcoOS_StrCmp( + IN gctCONST_STRING String1, + IN gctCONST_STRING String2 + ); + +/* Compare characters of two strings. */ +gceSTATUS +gcoOS_StrNCmp( + IN gctCONST_STRING String1, + IN gctCONST_STRING String2, + IN gctSIZE_T Count + ); + +/* Convert string to float. */ +gceSTATUS +gcoOS_StrToFloat( + IN gctCONST_STRING String, + OUT gctFLOAT * Float + ); + +/* Convert string to integer. */ +gceSTATUS +gcoOS_StrToInt( + IN gctCONST_STRING String, + OUT gctINT * Int + ); + +gceSTATUS +gcoOS_MemCmp( + IN gctCONST_POINTER Memory1, + IN gctCONST_POINTER Memory2, + IN gctSIZE_T Bytes + ); + +gceSTATUS +gcoOS_PrintStrSafe( + OUT gctSTRING String, + IN gctSIZE_T StringSize, + IN OUT gctUINT * Offset, + IN gctCONST_STRING Format, + ... + ); + +gceSTATUS +gcoOS_PrintStrVSafe( + OUT gctSTRING String, + IN gctSIZE_T StringSize, + IN OUT gctUINT * Offset, + IN gctCONST_STRING Format, + IN gctPOINTER Arguments + ); + +gceSTATUS +gcoOS_LoadLibrary( + IN gcoOS Os, + IN gctCONST_STRING Library, + OUT gctHANDLE * Handle + ); + +gceSTATUS +gcoOS_FreeLibrary( + IN gcoOS Os, + IN gctHANDLE Handle + ); + +gceSTATUS +gcoOS_GetProcAddress( + IN gcoOS Os, + IN gctHANDLE Handle, + IN gctCONST_STRING Name, + OUT gctPOINTER * Function + ); + +gceSTATUS +gcoOS_Compact( + IN gcoOS Os + ); + +gceSTATUS +gcoOS_ProfileStart( + IN gcoOS Os + ); + +gceSTATUS +gcoOS_ProfileEnd( + IN gcoOS Os, + IN gctCONST_STRING Title + ); + +gceSTATUS +gcoOS_SetProfileSetting( + IN gcoOS Os, + IN gctBOOL Enable, + IN gctCONST_STRING FileName + ); +gctINT32 +gcoOS_GetMilliTime( + void + ); + +char* gcoOS_GetProgramName(char* buf, int size); + +/* return non-NULL means success. null-terminate guarantee! */ +gctSTRING gcoOS_GetProgramNameWithoutPath( + OUT gctSTRING buf, + IN const gctSIZE_T size + ); +#if MRVL_BENCH + +/* +** Check point for timer. +** To add new profiling point, modify below two members: +gceSTATUS +gcoOS_SetProfileSetting( + IN gcoOS Os, + IN gctBOOL Enable, + IN gctCONST_STRING FileName + ); + +*/ +typedef enum _apiBenchIndex { + APIBENCH_INDEX_FRAME, + APIBENCH_INDEX_DRAWARRAY, + APIBENCH_INDEX_DRAWELEMENTS, + APIBENCH_INDEX_BUILDSTREAM, + APIBENCH_INDEX_INDEXBUFFER, + APIBENCH_INDEX_DRAWARRAY_UPDATESTATE, + APIBENCH_INDEX_DRAWARRAY_UPDATESTATE1, + APIBENCH_INDEX_UPDATESTATE, + APIBENCH_INDEX_UPDATESTATE1, + APIBENCH_INDEX_SWAPBUFFERS, + APIBENCH_INDEX_DRAWIMAGE, + APIBENCH_INDEX_SWTEXTUREUPLOAD, + APIBENCH_INDEX_DIRECTTEXTURE, + APIBENCH_INDEX_GLEGLIMAGETEXTURE, + APIBENCH_INDEX_DRAWTEX, + APIBENCH_INDEX_BUFFERDATA, + APIBENCH_INDEX_BUFFERSUBDATA, + APIBENCH_INDEX_COMPILER_FRONTEND, + APIBENCH_INDEX_COMPILER_OPTIMIZING, + APIBENCH_INDEX_COMPILER_BACKEND, /* i.e. LINKER */ + APIBENCH_INDEX_MAX +}apiBenchIndex; + +#define APIBENCHNAME { \ + "Frame", \ + "DrawArray", \ + "DrawElement", \ + "_buildStream", \ + "IndexBuffer", \ + "DrawArray_UpdateState", \ + "DrawArray_UpdateState1", \ + "UpdateState", \ + "UpdateState1", \ + "eglSwapBuffers", \ + "DrawImage", \ + "SWTextureUpload", \ + "uploadDirectTexture", \ + "glEGLImageTexture2D", \ + "glDrawTex", \ + "glBufferData", \ + "glBufferSubData", \ + "_glshCompileShader_frontEnd", \ + "_glshCompileShader_optimizing",\ + "_glshLinkShaders", \ +} + +/* +** Check point for state update +** +*/ +typedef enum _apiBenchStateIndex { + APIBENCH_STATE_INDEX_FRAME, + APIBENCH_STATE_INDEX_TEXTURE, + APIBENCH_STATE_INDEX_SHADER, + APIBENCH_STATE_INDEX_MAX +}apiBenchStateIndex; + +#define APIBENCHSTATENAME { \ + "Frame", \ + "Texture", \ + "Shader", \ +} + + /* Timer structure to store the profile result */ +typedef struct _gcoTIMER +{ + gctUINT32 start; + gctUINT32 end; + gctUINT32 totalTime; + gctUINT32 count; +}gcoTIMER; + + /* global structure for api bench */ +typedef struct _gcoAPIBENCH +{ + gctFILE file; + /* frame count */ + gctUINT32 frameCount; + + /* timer object for bench mark */ + gcoTIMER timer[APIBENCH_INDEX_MAX]; + + /* total sent command size */ + gctUINT32 commandSize; + + /* commit times */ + gctUINT32 commitNumber; + + /* profile the state update, use same structure of timer */ + gcoTIMER stateCounter[APIBENCH_STATE_INDEX_MAX]; + +}gcoAPIBENCH; + + /* Frame count to print */ +#define PROFILE_DRIVER_FRAME_PRINT 10 + + +void gcoDUMP_APIBenchStart( + IN gcoHAL Hal, + IN gctUINT32 timerIndex + ); + +void gcoDUMP_APIBenchEnd( + IN gcoHAL Hal, + IN gctUINT32 timerIndex + ); + +void gcoDUMP_APIBenchPrint( + IN gcoHAL Hal + ); + +void gcoDUMP_APIBenchInit( + IN gcoHAL Hal + ); + +void gcoDUMP_APIBenchDestroy( + IN gcoHAL Hal + ); + +void gcoDUMP_APIBenchFrame( + IN gcoHAL Hal + ); + +void gcoDUMP_APIBenchCommand( + IN gcoHAL Hal, + IN gctUINT32 size + ); + +void gcoDUMP_APIBenchCommit( + IN gcoHAL Hal + ); + +void gcoDUMP_APIBenchStateEnd( + IN gcoHAL Hal, + IN gctUINT32 stateIndex + ); + +void gcoDUMP_APIBenchStateStart( + IN gcoHAL Hal, + IN gctUINT32 stateIndex + ); + +#else + + +#endif + +/* Query the video memory. */ +gceSTATUS +gcoOS_QueryVideoMemory( + IN gcoOS Os, + OUT gctPHYS_ADDR * InternalAddress, + OUT gctSIZE_T * InternalSize, + OUT gctPHYS_ADDR * ExternalAddress, + OUT gctSIZE_T * ExternalSize, + OUT gctPHYS_ADDR * ContiguousAddress, + OUT gctSIZE_T * ContiguousSize + ); + +/*----------------------------------------------------------------------------*/ +/*----- Atoms ----------------------------------------------------------------*/ + +typedef struct gcsATOM * gcsATOM_PTR; + +/* Construct an atom. */ +gceSTATUS +gcoOS_AtomConstruct( + IN gcoOS Os, + OUT gcsATOM_PTR * Atom + ); + +/* Destroy an atom. */ +gceSTATUS +gcoOS_AtomDestroy( + IN gcoOS Os, + IN gcsATOM_PTR Atom + ); + +/* Increment an atom. */ +gceSTATUS +gcoOS_AtomIncrement( + IN gcoOS Os, + IN gcsATOM_PTR Atom, + OUT gctINT32_PTR OldValue + ); + +/* Decrement an atom. */ +gceSTATUS +gcoOS_AtomDecrement( + IN gcoOS Os, + IN gcsATOM_PTR Atom, + OUT gctINT32_PTR OldValue + ); + +gctHANDLE +gcoOS_GetCurrentProcessID( + void + ); + +/*----------------------------------------------------------------------------*/ +/*----- Time -----------------------------------------------------------------*/ + +/* Get the number of milliseconds since the system started. */ +gctUINT32 +gcoOS_GetTicks( + void + ); + +/* Get time in microseconds. */ +gceSTATUS +gcoOS_GetTime( + gctUINT64_PTR Time + ); + +/* Get CPU usage in microseconds. */ +gceSTATUS +gcoOS_GetCPUTime( + gctUINT64_PTR CPUTime + ); + +/* Get memory usage. */ +gceSTATUS +gcoOS_GetMemoryUsage( + gctUINT32_PTR MaxRSS, + gctUINT32_PTR IxRSS, + gctUINT32_PTR IdRSS, + gctUINT32_PTR IsRSS + ); + +/* Delay a number of microseconds. */ +gceSTATUS +gcoOS_Delay( + IN gcoOS Os, + IN gctUINT32 Delay + ); + +/*----------------------------------------------------------------------------*/ +/*----- Mutexes --------------------------------------------------------------*/ + +/* Create a new mutex. */ +gceSTATUS +gcoOS_CreateMutex( + IN gcoOS Os, + OUT gctPOINTER * Mutex + ); + +/* Delete a mutex. */ +gceSTATUS +gcoOS_DeleteMutex( + IN gcoOS Os, + IN gctPOINTER Mutex + ); + +/* Acquire a mutex. */ +gceSTATUS +gcoOS_AcquireMutex( + IN gcoOS Os, + IN gctPOINTER Mutex, + IN gctUINT32 Timeout + ); + +/* Release a mutex. */ +gceSTATUS +gcoOS_ReleaseMutex( + IN gcoOS Os, + IN gctPOINTER Mutex + ); + +/*----------------------------------------------------------------------------*/ +/*----- Signals --------------------------------------------------------------*/ + +/* Create a signal. */ +gceSTATUS +gcoOS_CreateSignal( + IN gcoOS Os, + IN gctBOOL ManualReset, + IN gceSIGNAL_TYPE SignalType, + OUT gctSIGNAL * Signal + ); + +/* Destroy a signal. */ +gceSTATUS +gcoOS_DestroySignal( + IN gcoOS Os, + IN gctSIGNAL Signal + ); + +/* Signal a signal. */ +gceSTATUS +gcoOS_Signal( + IN gcoOS Os, + IN gctSIGNAL Signal, + IN gctBOOL State + ); + +/* Wait for a signal. */ +gceSTATUS +gcoOS_WaitSignal( + IN gcoOS Os, + IN gctSIGNAL Signal, + IN gctUINT32 Wait + ); + +/* Write a register. */ +gceSTATUS +gcoOS_WriteRegister( + IN gcoOS Os, + IN gctUINT32 Address, + IN gctUINT32 Data + ); + +/* Read a register. */ +gceSTATUS +gcoOS_ReadRegister( + IN gcoOS Os, + IN gctUINT32 Address, + OUT gctUINT32 * Data + ); + +gceSTATUS +gcoOS_CacheFlush( + IN gcoOS Os, + IN gctPOINTER Logical, + IN gctSIZE_T Bytes + ); + +gceSTATUS +gcoOS_CacheInvalidate( + IN gcoOS Os, + IN gctPOINTER Logical, + IN gctSIZE_T Bytes + ); + +/******************************************************************************* +** gcoMATH object +*/ + +#define gcdPI 3.14159265358979323846f + +gctUINT32 +gcoMATH_Log2in5dot5( + IN gctINT X + ); + +gctFLOAT +gcoMATH_Sine( + IN gctFLOAT X + ); + +gctFLOAT +gcoMATH_Cosine( + IN gctFLOAT X + ); + +gctFLOAT +gcoMATH_Floor( + IN gctFLOAT X + ); + +gctFLOAT +gcoMATH_Ceiling( + IN gctFLOAT X + ); + +gctFLOAT +gcoMATH_SquareRoot( + IN gctFLOAT X + ); + +gctFLOAT +gcoMATH_Log2( + IN gctFLOAT X + ); + +gctFLOAT +gcoMATH_Power( + IN gctFLOAT X, + IN gctFLOAT Y + ); + +gctFLOAT +gcoMATH_Modulo( + IN gctFLOAT X, + IN gctFLOAT Y + ); + +gctFLOAT +gcoMATH_Exp( + IN gctFLOAT X + ); + +gctFLOAT +gcoMATH_Absolute( + IN gctFLOAT X + ); + +gctFLOAT +gcoMATH_ArcCosine( + IN gctFLOAT X + ); + +gctFLOAT +gcoMATH_Tangent( + IN gctFLOAT X + ); + +gctFLOAT +gcoMATH_UInt2Float( + IN gctUINT X + ); + +gctUINT +gcoMATH_Float2UInt( + IN gctFLOAT X + ); + +gctFLOAT +gcoMATH_Multiply( + IN gctFLOAT X, + IN gctFLOAT Y + ); + +/******************************************************************************\ +**************************** Coordinate Structures ***************************** +\******************************************************************************/ + +typedef struct _gcsPOINT +{ + gctINT32 x; + gctINT32 y; +} +gcsPOINT; + +typedef struct _gcsSIZE +{ + gctINT32 width; + gctINT32 height; +} +gcsSIZE; + +typedef struct _gcsRECT +{ + gctINT32 left; + gctINT32 top; + gctINT32 right; + gctINT32 bottom; +} +gcsRECT; + + +/******************************************************************************\ +********************************* gcoSURF Object ******************************** +\******************************************************************************/ + +/*----------------------------------------------------------------------------*/ +/*------------------------------- gcoSURF Common ------------------------------*/ + +/* Color format classes. */ +typedef enum _gceFORMAT_CLASS +{ + gcvFORMAT_CLASS_RGBA = 4500, + gcvFORMAT_CLASS_YUV, + gcvFORMAT_CLASS_INDEX, + gcvFORMAT_CLASS_LUMINANCE, + gcvFORMAT_CLASS_BUMP, + gcvFORMAT_CLASS_DEPTH, +} +gceFORMAT_CLASS; + +/* Special enums for width field in gcsFORMAT_COMPONENT. */ +typedef enum _gceCOMPONENT_CONTROL +{ + gcvCOMPONENT_NOTPRESENT = 0x00, + gcvCOMPONENT_DONTCARE = 0x80, + gcvCOMPONENT_WIDTHMASK = 0x7F, + gcvCOMPONENT_ODD = 0x80 +} +gceCOMPONENT_CONTROL; + +/* Color format component parameters. */ +typedef struct _gcsFORMAT_COMPONENT +{ + gctUINT8 start; + gctUINT8 width; +} +gcsFORMAT_COMPONENT; + +/* RGBA color format class. */ +typedef struct _gcsFORMAT_CLASS_TYPE_RGBA +{ + gcsFORMAT_COMPONENT alpha; + gcsFORMAT_COMPONENT red; + gcsFORMAT_COMPONENT green; + gcsFORMAT_COMPONENT blue; +} +gcsFORMAT_CLASS_TYPE_RGBA; + +/* YUV color format class. */ +typedef struct _gcsFORMAT_CLASS_TYPE_YUV +{ + gcsFORMAT_COMPONENT y; + gcsFORMAT_COMPONENT u; + gcsFORMAT_COMPONENT v; +} +gcsFORMAT_CLASS_TYPE_YUV; + +/* Index color format class. */ +typedef struct _gcsFORMAT_CLASS_TYPE_INDEX +{ + gcsFORMAT_COMPONENT value; +} +gcsFORMAT_CLASS_TYPE_INDEX; + +/* Luminance color format class. */ +typedef struct _gcsFORMAT_CLASS_TYPE_LUMINANCE +{ + gcsFORMAT_COMPONENT alpha; + gcsFORMAT_COMPONENT value; +} +gcsFORMAT_CLASS_TYPE_LUMINANCE; + +/* Bump map color format class. */ +typedef struct _gcsFORMAT_CLASS_TYPE_BUMP +{ + gcsFORMAT_COMPONENT alpha; + gcsFORMAT_COMPONENT l; + gcsFORMAT_COMPONENT v; + gcsFORMAT_COMPONENT u; + gcsFORMAT_COMPONENT q; + gcsFORMAT_COMPONENT w; +} +gcsFORMAT_CLASS_TYPE_BUMP; + +/* Depth and stencil format class. */ +typedef struct _gcsFORMAT_CLASS_TYPE_DEPTH +{ + gcsFORMAT_COMPONENT depth; + gcsFORMAT_COMPONENT stencil; +} +gcsFORMAT_CLASS_TYPE_DEPTH; + +/* Format parameters. */ +typedef struct _gcsSURF_FORMAT_INFO +{ + /* Format code and class. */ + gceSURF_FORMAT format; + gceFORMAT_CLASS fmtClass; + + /* The size of one pixel in bits. */ + gctUINT8 bitsPerPixel; + + /* Component swizzle. */ + gceSURF_SWIZZLE swizzle; + + /* Some formats have two neighbour pixels interleaved together. */ + /* To describe such format, set the flag to 1 and add another */ + /* like this one describing the odd pixel format. */ + gctUINT8 interleaved; + + /* Format components. */ + union + { + gcsFORMAT_CLASS_TYPE_BUMP bump; + gcsFORMAT_CLASS_TYPE_RGBA rgba; + gcsFORMAT_CLASS_TYPE_YUV yuv; + gcsFORMAT_CLASS_TYPE_LUMINANCE lum; + gcsFORMAT_CLASS_TYPE_INDEX index; + gcsFORMAT_CLASS_TYPE_DEPTH depth; + } u; +} +gcsSURF_FORMAT_INFO; + +/* Frame buffer information. */ +typedef struct _gcsSURF_FRAMEBUFFER +{ + gctPOINTER logical; + gctUINT width, height; + gctINT stride; + gceSURF_FORMAT format; +} +gcsSURF_FRAMEBUFFER; + +/* Generic pixel component descriptors. */ +extern gcsFORMAT_COMPONENT gcvPIXEL_COMP_XXX8; +extern gcsFORMAT_COMPONENT gcvPIXEL_COMP_XX8X; +extern gcsFORMAT_COMPONENT gcvPIXEL_COMP_X8XX; +extern gcsFORMAT_COMPONENT gcvPIXEL_COMP_8XXX; + +typedef enum _gceORIENTATION +{ + gcvORIENTATION_TOP_BOTTOM, + gcvORIENTATION_BOTTOM_TOP, +} +gceORIENTATION; + + +/* Construct a new gcoSURF object. */ +gceSTATUS +gcoSURF_Construct( + IN gcoHAL Hal, + IN gctUINT Width, + IN gctUINT Height, + IN gctUINT Depth, + IN gceSURF_TYPE Type, + IN gceSURF_FORMAT Format, + IN gcePOOL Pool, + OUT gcoSURF * Surface + ); + +/* Destroy an gcoSURF object. */ +gceSTATUS +gcoSURF_Destroy( + IN gcoSURF Surface + ); + +/* Map user-allocated surface. */ +gceSTATUS +gcoSURF_MapUserSurface( + IN gcoSURF Surface, + IN gctUINT Alignment, + IN gctPOINTER Logical, + IN gctUINT32 Physical + ); + +/* Set the color type of the surface. */ +gceSTATUS +gcoSURF_SetColorType( + IN gcoSURF Surface, + IN gceSURF_COLOR_TYPE ColorType + ); + +/* Get the color type of the surface. */ +gceSTATUS +gcoSURF_GetColorType( + IN gcoSURF Surface, + OUT gceSURF_COLOR_TYPE *ColorType + ); + +/* Set the surface ration angle. */ +gceSTATUS +gcoSURF_SetRotation( + IN gcoSURF Surface, + IN gceSURF_ROTATION Rotation + ); + +/* Verify and return the state of the tile status mechanism. */ +gceSTATUS +gcoSURF_IsTileStatusSupported( + IN gcoSURF Surface + ); + +/* Enable tile status for the specified surface. */ +gceSTATUS +gcoSURF_EnableTileStatus( + IN gcoSURF Surface + ); + +/* Disable tile status for the specified surface. */ +gceSTATUS +gcoSURF_DisableTileStatus( + IN gcoSURF Surface, + IN gctBOOL Decompress + ); + +/* Get surface size. */ +gceSTATUS +gcoSURF_GetSize( + IN gcoSURF Surface, + OUT gctUINT * Width, + OUT gctUINT * Height, + OUT gctUINT * Depth + ); + +/* Get surface aligned sizes. */ +gceSTATUS +gcoSURF_GetAlignedSize( + IN gcoSURF Surface, + OUT gctUINT * Width, + OUT gctUINT * Height, + OUT gctINT * Stride + ); + +/* Get surface type and format. */ +gceSTATUS +gcoSURF_GetFormat( + IN gcoSURF Surface, + OUT gceSURF_TYPE * Type, + OUT gceSURF_FORMAT * Format + ); + +/* Lock the surface. */ +gceSTATUS +gcoSURF_Lock( + IN gcoSURF Surface, + IN OUT gctUINT32 * Address, + IN OUT gctPOINTER * Memory + ); + +/* Unlock the surface. */ +gceSTATUS +gcoSURF_Unlock( + IN gcoSURF Surface, + IN gctPOINTER Memory + ); + +/* Return pixel format parameters. */ +gceSTATUS +gcoSURF_QueryFormat( + IN gceSURF_FORMAT Format, + OUT gcsSURF_FORMAT_INFO_PTR * Info + ); + +/* Compute the color pixel mask. */ +gceSTATUS +gcoSURF_ComputeColorMask( + IN gcsSURF_FORMAT_INFO_PTR Format, + OUT gctUINT32_PTR ColorMask + ); + +/* Check the surface is renderable or not. */ +gceSTATUS +gcoSURF_IsRenderable( + IN gcoSURF Surface + ); + +/* Flush the surface. */ +gceSTATUS +gcoSURF_Flush( + IN gcoSURF Surface + ); + +/* Fill surface with a value. */ +gceSTATUS +gcoSURF_Fill( + IN gcoSURF Surface, + IN gcsPOINT_PTR Origin, + IN gcsSIZE_PTR Size, + IN gctUINT32 Value, + IN gctUINT32 Mask + ); + +/* Alpha blend two surfaces together. */ +gceSTATUS +gcoSURF_Blend( + IN gcoSURF SrcSurface, + IN gcoSURF DestSurface, + IN gcsPOINT_PTR SrcOrig, + IN gcsPOINT_PTR DestOrigin, + IN gcsSIZE_PTR Size, + IN gceSURF_BLEND_MODE Mode + ); + +/* Create a new gcoSURF wrapper object. */ +gceSTATUS +gcoSURF_ConstructWrapper( + IN gcoHAL Hal, + OUT gcoSURF * Surface + ); + +/* Set the underlying buffer for the surface wrapper. */ +gceSTATUS +gcoSURF_SetBuffer( + IN gcoSURF Surface, + IN gceSURF_TYPE Type, + IN gceSURF_FORMAT Format, + IN gctUINT Stride, + IN gctPOINTER Logical, + IN gctUINT32 Physical + ); + +/* Set the size of the surface in pixels and map the underlying buffer. */ +gceSTATUS +gcoSURF_SetWindow( + IN gcoSURF Surface, + IN gctUINT X, + IN gctUINT Y, + IN gctUINT Width, + IN gctUINT Height + ); + +/* Increase reference count of the surface. */ +gceSTATUS +gcoSURF_ReferenceSurface( + IN gcoSURF Surface + ); + +/* Decrease reference count of the surface. */ +gceSTATUS +gcoSURF_DereferenceSurface( + IN gcoSURF Surface + ); + + +/* Get surface reference count. */ +gceSTATUS +gcoSURF_QueryReferenceCount( + IN gcoSURF Surface, + OUT gctINT32 * ReferenceCount + ); + +/* Set surface orientation. */ +gceSTATUS +gcoSURF_SetOrientation( + IN gcoSURF Surface, + IN gceORIENTATION Orientation + ); + +/* Set surface resolve offset */ +gceSTATUS +gcoSURF_SetFace( + IN gcoSURF Surface, + IN gctUINT Face + ); + +/* Query surface orientation. */ +gceSTATUS +gcoSURF_QueryOrientation( + IN gcoSURF Surface, + OUT gceORIENTATION * Orientation + ); + /* #define DUMP_SURFACE 0 */ + +/* Dump a buffer to a BMP file */ +int gcoOS_DumpBMP( + IN gctPOINTER dumpBase, + IN gctINT dumpWidth, + IN gctINT dumpHeight, + IN gctINT dumpStride, + IN gceSURF_FORMAT format, + IN gceORIENTATION orientation, + IN gctCONST_STRING fileName + ); + + +/* Dump surface to a BMP file. */ +gceSTATUS +gcoSURF_DumpSurface( + IN gcoSURF Surface, + IN gctBOOL bCheckOrientation, + IN gctCONST_STRING fileName + ); + +/******************************************************************************\ +********************************* gcoDUMP Object ******************************** +\******************************************************************************/ + +/* Construct a new gcoDUMP object. */ +gceSTATUS +gcoDUMP_Construct( + IN gcoOS Os, + IN gcoHAL Hal, + OUT gcoDUMP * Dump + ); + +/* Destroy a gcoDUMP object. */ +gceSTATUS +gcoDUMP_Destroy( + IN gcoDUMP Dump + ); + +/* Enable/disable dumping. */ +gceSTATUS +gcoDUMP_Control( + IN gcoDUMP Dump, + IN gctSTRING FileName + ); + +gceSTATUS +gcoDUMP_IsEnabled( + IN gcoDUMP Dump, + OUT gctBOOL * Enabled + ); + +/* Add surface. */ +gceSTATUS +gcoDUMP_AddSurface( + IN gcoDUMP Dump, + IN gctINT32 Width, + IN gctINT32 Height, + IN gceSURF_FORMAT PixelFormat, + IN gctUINT32 Address, + IN gctSIZE_T ByteCount + ); + +/* Mark the beginning of a frame. */ +gceSTATUS +gcoDUMP_FrameBegin( + IN gcoDUMP Dump + ); + +/* Mark the end of a frame. */ +gceSTATUS +gcoDUMP_FrameEnd( + IN gcoDUMP Dump + ); + +/* Dump data. */ +gceSTATUS +gcoDUMP_DumpData( + IN gcoDUMP Dump, + IN gceDUMP_TAG Type, + IN gctUINT32 Address, + IN gctSIZE_T ByteCount, + IN gctCONST_POINTER Data + ); + +/* Delete an address. */ +gceSTATUS +gcoDUMP_Delete( + IN gcoDUMP Dump, + IN gctUINT32 Address + ); + +/******************************************************************************\ +******************************* gcsRECT Structure ****************************** +\******************************************************************************/ + +/* Initialize rectangle structure. */ +gceSTATUS +gcsRECT_Set( + OUT gcsRECT_PTR Rect, + IN gctINT32 Left, + IN gctINT32 Top, + IN gctINT32 Right, + IN gctINT32 Bottom + ); + +/* Return the width of the rectangle. */ +gceSTATUS +gcsRECT_Width( + IN gcsRECT_PTR Rect, + OUT gctINT32 * Width + ); + +/* Return the height of the rectangle. */ +gceSTATUS +gcsRECT_Height( + IN gcsRECT_PTR Rect, + OUT gctINT32 * Height + ); + +/* Ensure that top left corner is to the left and above the right bottom. */ +gceSTATUS +gcsRECT_Normalize( + IN OUT gcsRECT_PTR Rect + ); + +/* Compare two rectangles. */ +gceSTATUS +gcsRECT_IsEqual( + IN gcsRECT_PTR Rect1, + IN gcsRECT_PTR Rect2, + OUT gctBOOL * Equal + ); + +/* Compare the sizes of two rectangles. */ +gceSTATUS +gcsRECT_IsOfEqualSize( + IN gcsRECT_PTR Rect1, + IN gcsRECT_PTR Rect2, + OUT gctBOOL * EqualSize + ); + + +/******************************************************************************\ +**************************** gcsBOUNDARY Structure ***************************** +\******************************************************************************/ + +typedef struct _gcsBOUNDARY +{ + gctINT x; + gctINT y; + gctINT width; + gctINT height; +} +gcsBOUNDARY; + +/******************************************************************************\ +********************************* gcoHEAP Object ******************************** +\******************************************************************************/ + +typedef struct _gcoHEAP * gcoHEAP; + +/* Construct a new gcoHEAP object. */ +gceSTATUS +gcoHEAP_Construct( + IN gcoOS Os, + IN gctSIZE_T AllocationSize, + OUT gcoHEAP * Heap + ); + +/* Destroy an gcoHEAP object. */ +gceSTATUS +gcoHEAP_Destroy( + IN gcoHEAP Heap + ); + +/* Allocate memory. */ +gceSTATUS +gcoHEAP_Allocate( + IN gcoHEAP Heap, + IN gctSIZE_T Bytes, + OUT gctPOINTER * Node + ); + +/* Free memory. */ +gceSTATUS +gcoHEAP_Free( + IN gcoHEAP Heap, + IN gctPOINTER Node + ); + +/* Profile the heap. */ +gceSTATUS +gcoHEAP_ProfileStart( + IN gcoHEAP Heap + ); + +gceSTATUS +gcoHEAP_ProfileEnd( + IN gcoHEAP Heap, + IN gctCONST_STRING Title + ); + +#if defined gcdHAL_TEST +gceSTATUS +gcoHEAP_Test( + IN gcoHEAP Heap, + IN gctSIZE_T Vectors, + IN gctSIZE_T MaxSize + ); +#endif + +/******************************************************************************\ +******************************* Debugging Macros ******************************* +\******************************************************************************/ + +void +gcoOS_SetDebugLevel( + IN gctUINT32 Level + ); + +void +gcoOS_SetDebugZone( + IN gctUINT32 Zone + ); + +void +gcoOS_SetDebugLevelZone( + IN gctUINT32 Level, + IN gctUINT32 Zone + ); + +void +gcoOS_SetDebugZones( + IN gctUINT32 Zones, + IN gctBOOL Enable + ); + +void +gcoOS_SetDebugFile( + IN gctCONST_STRING FileName + ); + +/******************************************************************************* +** +** gcmFATAL +** +** Print a message to the debugger and execute a break point. +** +** ARGUMENTS: +** +** message Message. +** ... Optional arguments. +*/ + +void +gckOS_DebugFatal( + IN gctCONST_STRING Message, + ... + ); + +void +gcoOS_DebugFatal( + IN gctCONST_STRING Message, + ... + ); + +#if gcdDEBUG +# define gcmFATAL gcoOS_DebugFatal +# define gcmkFATAL gckOS_DebugFatal +#elif gcdHAS_ELLIPSES +# define gcmFATAL(...) +# define gcmkFATAL(...) +#else + gcmINLINE static void + __dummy_fatal( + IN gctCONST_STRING Message, + ... + ) + { + } +# define gcmFATAL __dummy_fatal +# define gcmkFATAL __dummy_fatal +#endif + +#define gcmENUM2TEXT(e) case e: return #e + +/******************************************************************************* +** +** gcmTRACE +** +** Print a message to the debugfer if the correct level has been set. In +** retail mode this macro does nothing. +** +** ARGUMENTS: +** +** level Level of message. +** message Message. +** ... Optional arguments. +*/ +#define gcvLEVEL_NONE -1 +#define gcvLEVEL_ERROR 0 +#define gcvLEVEL_WARNING 1 +#define gcvLEVEL_INFO 2 +#define gcvLEVEL_VERBOSE 3 + +void +gckOS_DebugTrace( + IN gctUINT32 Level, + IN gctCONST_STRING Message, + ... + ); +void + +gcoOS_DebugTrace( + IN gctUINT32 Level, + IN gctCONST_STRING Message, + ... + ); + +#if gcdDEBUG +# define gcmTRACE gcoOS_DebugTrace +# define gcmkTRACE gckOS_DebugTrace +#elif gcdHAS_ELLIPSES +# define gcmTRACE(...) +# define gcmkTRACE(...) +#else + gcmINLINE static void + __dummy_trace( + IN gctUINT32 Level, + IN gctCONST_STRING Message, + ... + ) + { + } +# define gcmTRACE __dummy_trace +# define gcmkTRACE __dummy_trace +#endif + +/* Debug zones. */ +#define gcvZONE_OS (1 << 0) +#define gcvZONE_HARDWARE (1 << 1) +#define gcvZONE_HEAP (1 << 2) + +/* Kernel zones. */ +#define gcvZONE_KERNEL (1 << 3) +#define gcvZONE_VIDMEM (1 << 4) +#define gcvZONE_COMMAND (1 << 5) +#define gcvZONE_DRIVER (1 << 6) +#define gcvZONE_CMODEL (1 << 7) +#define gcvZONE_MMU (1 << 8) +#define gcvZONE_EVENT (1 << 9) +#define gcvZONE_DEVICE (1 << 10) + +/* User zones. */ +#define gcvZONE_HAL (1 << 3) +#define gcvZONE_BUFFER (1 << 4) +#define gcvZONE_CONTEXT (1 << 5) +#define gcvZONE_SURFACE (1 << 6) +#define gcvZONE_INDEX (1 << 7) +#define gcvZONE_STREAM (1 << 8) +#define gcvZONE_TEXTURE (1 << 9) +#define gcvZONE_2D (1 << 10) +#define gcvZONE_3D (1 << 11) +#define gcvZONE_COMPILER (1 << 12) +#define gcvZONE_MEMORY (1 << 13) +#define gcvZONE_STATE (1 << 14) +#define gcvZONE_AUX (1 << 15) + +/* API definitions. */ +#define gcvZONE_API_HAL (0 << 28) +#define gcvZONE_API_EGL (1 << 28) +#define gcvZONE_API_ES11 (2 << 28) +#define gcvZONE_API_ES20 (3 << 28) +#define gcvZONE_API_VG11 (4 << 28) +#define gcvZONE_API_GL (5 << 28) +#define gcvZONE_API_DFB (6 << 28) +#define gcvZONE_API_GDI (7 << 28) +#define gcvZONE_API_D3D (8 << 28) + +#define gcmZONE_GET_API(zone) ((zone) >> 28) +#define gcdZONE_MASK 0x0FFFFFFF + +/* Handy zones. */ +#define gcvZONE_NONE 0 +#define gcvZONE_ALL gcdZONE_MASK + +/******************************************************************************* +** +** gcmTRACE_ZONE +** +** Print a message to the debugger if the correct level and zone has been +** set. In retail mode this macro does nothing. +** +** ARGUMENTS: +** +** Level Level of message. +** Zone Zone of message. +** Message Message. +** ... Optional arguments. +*/ + +void +gckOS_DebugTraceZone( + IN gctUINT32 Level, + IN gctUINT32 Zone, + IN gctCONST_STRING Message, + ... + ); + +void +gcoOS_DebugTraceZone( + IN gctUINT32 Level, + IN gctUINT32 Zone, + IN gctCONST_STRING Message, + ... + ); + +#if gcdDEBUG +# define gcmTRACE_ZONE gcoOS_DebugTraceZone +# define gcmkTRACE_ZONE gckOS_DebugTraceZone +#elif gcdHAS_ELLIPSES +# define gcmTRACE_ZONE(...) +# define gcmkTRACE_ZONE(...) +#else + gcmINLINE static void + __dummy_trace_zone( + IN gctUINT32 Level, + IN gctUINT32 Zone, + IN gctCONST_STRING Message, + ... + ) + { + } +# define gcmTRACE_ZONE __dummy_trace_zone +# define gcmkTRACE_ZONE __dummy_trace_zone +#endif + +/******************************************************************************\ +******************************** Logging Macros ******************************** +\******************************************************************************/ + +#define gcdHEADER_LEVEL gcvLEVEL_VERBOSE + +#define gcmHEADER() \ + gcmTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \ + "++%s(%d)", __FUNCTION__, __LINE__) + +#if gcdHAS_ELLIPSES +# define gcmHEADER_ARG(Text, ...) \ + gcmTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \ + "++%s(%d): " Text, __FUNCTION__, __LINE__, __VA_ARGS__) +#else + gcmINLINE static void + __dummy_header_arg( + IN gctCONST_STRING Text, + ... + ) + { + } +# define gcmHEADER_ARG __dummy_header_arg +#endif + +#define gcmFOOTER() \ + gcmTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \ + "--%s(%d): status=%d", \ + __FUNCTION__, __LINE__, status) + +#define gcmFOOTER_NO() \ + gcmTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \ + "--%s(%d)", __FUNCTION__, __LINE__) + +#if gcdHAS_ELLIPSES +# define gcmFOOTER_ARG(Text, ...) \ + gcmTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \ + "--%s(%d): " Text, \ + __FUNCTION__, __LINE__, __VA_ARGS__) +#else + gcmINLINE static void + __dummy_footer_arg( + IN gctCONST_STRING Text, + ... + ) + { + } +# define gcmFOOTER_ARG __dummy_footer_arg +#endif + +#define gcmkHEADER() \ + gcmkTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \ + "++%s(%d)", __FUNCTION__, __LINE__) + +#if gcdHAS_ELLIPSES +# define gcmkHEADER_ARG(Text, ...) \ + gcmkTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \ + "++%s(%d): " Text, __FUNCTION__, __LINE__, __VA_ARGS__) +#else + gcmINLINE static void + __dummy_kheader_arg( + IN gctCONST_STRING Text, + ... + ) + { + } +# define gcmkHEADER_ARG __dummy_kheader_arg +#endif + +#define gcmkFOOTER() \ + gcmkTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \ + "--%s(%d): status=%d", \ + __FUNCTION__, __LINE__, status) + +#define gcmkFOOTER_NO() \ + gcmkTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \ + "--%s(%d)", __FUNCTION__, __LINE__) + +#if gcdHAS_ELLIPSES +# define gcmkFOOTER_ARG(Text, ...) \ + gcmkTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \ + "--%s(%d): " Text, \ + __FUNCTION__, __LINE__, __VA_ARGS__) +#else + gcmINLINE static void + __dummy_kfooter_arg( + IN gctCONST_STRING Text, + ... + ) + { + } +# define gcmkFOOTER_ARG __dummy_kfooter_arg +#endif + +#define gcmOPT_VALUE(ptr) (((ptr) == gcvNULL) ? 0 : *(ptr)) +#define gcmOPT_POINTER(ptr) (((ptr) == gcvNULL) ? gcvNULL : *(ptr)) + +void +gcoOS_Print( + IN gctCONST_STRING Message, + ... + ); +void +gckOS_Print( + IN gctCONST_STRING Message, + ... + ); +#define gcmPRINT gcoOS_Print +#define gcmkPRINT gckOS_Print + +/******************************************************************************* +** +** gcmDUMP +** +** Print a dump message. +** +** ARGUMENTS: +** +** gctSTRING Message. +** +** ... Optional arguments. +*/ +#if gcdDUMP + gceSTATUS + gcfDump( + IN gcoOS Os, + IN gctCONST_STRING String, + ... + ); +# define gcmDUMP gcfDump +#elif gcdHAS_ELLIPSES +# define gcmDUMP(...) +#else + gcmINLINE static void + __dummy_dump( + IN gcoOS Os, + IN gctCONST_STRING Message, + ... + ) + { + } +# define gcmDUMP __dummy_dump +#endif + +/******************************************************************************* +** +** gcmDUMP_DATA +** +** Add data to the dump. +** +** ARGUMENTS: +** +** gctSTRING Tag +** Tag for dump. +** +** gctPOINTER Logical +** Logical address of buffer. +** +** gctSIZE_T Bytes +** Number of bytes. +*/ + +#if gcdDUMP + gceSTATUS + gcfDumpData( + IN gcoOS Os, + IN gctSTRING Tag, + IN gctPOINTER Logical, + IN gctSIZE_T Bytes + ); +# define gcmDUMP_DATA gcfDumpData +#elif gcdHAS_ELLIPSES +# define gcmDUMP_DATA(...) +#else + gcmINLINE static void + __dummy_dump_data( + IN gcoOS Os, + IN gctSTRING Tag, + IN gctPOINTER Logical, + IN gctSIZE_T Bytes + ) + { + } +# define gcmDUMP_DATA __dummy_dump_data +#endif + +/******************************************************************************* +** +** gcmDUMP_BUFFER +** +** Print a buffer to the dump. +** +** ARGUMENTS: +** +** gctSTRING Tag +** Tag for dump. +** +** gctUINT32 Physical +** Physical address of buffer. +** +** gctPOINTER Logical +** Logical address of buffer. +** +** gctUINT32 Offset +** Offset into buffer. +** +** gctSIZE_T Bytes +** Number of bytes. +*/ + +#if gcdDUMP +gceSTATUS +gcfDumpBuffer( + IN gcoOS Os, + IN gctSTRING Tag, + IN gctUINT32 Physical, + IN gctPOINTER Logical, + IN gctUINT32 Offset, + IN gctSIZE_T Bytes + ); +# define gcmDUMP_BUFFER gcfDumpBuffer +#elif gcdHAS_ELLIPSES +# define gcmDUMP_BUFFER(...) +#else + gcmINLINE static void + __dummy_dump_buffer( + IN gcoOS Os, + IN gctSTRING Tag, + IN gctUINT32 Physical, + IN gctPOINTER Logical, + IN gctUINT32 Offset, + IN gctSIZE_T Bytes + ) + { + } +# define gcmDUMP_BUFFER __dummy_dump_buffer +#endif + +/******************************************************************************* +** +** gcmDUMP_API +** +** Print a dump message for a high level API prefixed by the function name. +** +** ARGUMENTS: +** +** gctSTRING Message. +** +** ... Optional arguments. +*/ +#if gcdDUMP_API + gceSTATUS + gcfDumpApi( + IN gctCONST_STRING String, + ... + ); +# define gcmDUMP_API gcfDumpApi +#elif gcdHAS_ELLIPSES +# define gcmDUMP_API(...) +#else + gcmINLINE static void + __dummy_dump_api( + IN gctCONST_STRING Message, + ... + ) + { + } +# define gcmDUMP_API __dummy_dump_api +#endif + +/******************************************************************************* +** +** gcmDUMP_API_ARRAY +** +** Print an array of data. +** +** ARGUMENTS: +** +** gctUINT32_PTR Pointer to array. +** gctUINT32 Size. +*/ +#if gcdDUMP_API + gceSTATUS + gcfDumpArray( + IN gctCONST_POINTER Data, + IN gctUINT32 Size + ); +# define gcmDUMP_API_ARRAY gcfDumpArray +#elif gcdHAS_ELLIPSES +# define gcmDUMP_API_ARRAY(...) +#else + gcmINLINE static void + __dummy_dump_api_array( + IN gctCONST_POINTER Data, + IN gctUINT32 Size + ) + { + } +# define gcmDUMP_API_ARRAY __dummy_dump_api_array +#endif + +/******************************************************************************* +** +** gcmDUMP_API_ARRAY_TOKEN +** +** Print an array of data terminated by a token. +** +** ARGUMENTS: +** +** gctUINT32_PTR Pointer to array. +** gctUINT32 Termination. +*/ +#if gcdDUMP_API + gceSTATUS + gcfDumpArrayToken( + IN gctCONST_POINTER Data, + IN gctUINT32 Termination + ); +# define gcmDUMP_API_ARRAY_TOKEN gcfDumpArrayToken +#elif gcdHAS_ELLIPSES +# define gcmDUMP_API_ARRAY_TOKEN(...) +#else + gcmINLINE static void + __dummy_dump_api_array_token( + IN gctCONST_POINTER Data, + IN gctUINT32 Termination + ) + { + } +# define gcmDUMP_API_ARRAY_TOKEN __dummy_dump_api_array_token +#endif + +/******************************************************************************* +** +** gcmTRACE_RELEASE +** +** Print a message to the shader debugger. +** +** ARGUMENTS: +** +** message Message. +** ... Optional arguments. +*/ + +#define gcmTRACE_RELEASE gcoOS_DebugShaderTrace + +void +gcoOS_DebugShaderTrace( + IN gctCONST_STRING Message, + ... + ); + +void +gcoOS_SetDebugShaderFiles( + IN gctCONST_STRING VSFileName, + IN gctCONST_STRING FSFileName + ); + +void +gcoOS_SetDebugShaderFileType( + IN gctUINT32 ShaderType + ); + +/******************************************************************************* +** +** gcmBREAK +** +** Break into the debugger. In retail mode this macro does nothing. +** +** ARGUMENTS: +** +** None. +*/ + +void +gcoOS_DebugBreak( + void + ); + +void +gckOS_DebugBreak( + void + ); + +#if gcdDEBUG +# define gcmBREAK gcoOS_DebugBreak +# define gcmkBREAK gckOS_DebugBreak +#else +# define gcmBREAK() +# define gcmkBREAK() +#endif + +/******************************************************************************* +** +** gcmASSERT +** +** Evaluate an expression and break into the debugger if the expression +** evaluates to false. In retail mode this macro does nothing. +** +** ARGUMENTS: +** +** exp Expression to evaluate. +*/ +#if gcdDEBUG +# define _gcmASSERT(prefix, exp) \ + do \ + { \ + if (!(exp)) \ + { \ + prefix##TRACE(gcvLEVEL_ERROR, \ + #prefix "ASSERT at %s(%d) in " __FILE__, \ + __FUNCTION__, __LINE__); \ + prefix##TRACE(gcvLEVEL_ERROR, \ + "(%s)", #exp); \ + prefix##BREAK(); \ + } \ + } \ + while (gcvFALSE) +# define gcmASSERT(exp) _gcmASSERT(gcm, exp) +# define gcmkASSERT(exp) _gcmASSERT(gcmk, exp) +#else +# define gcmASSERT(exp) +# define gcmkASSERT(exp) +#endif + +/******************************************************************************* +** +** gcmVERIFY +** +** Verify if an expression returns true. If the expression does not +** evaluates to true, an assertion will happen in debug mode. +** +** ARGUMENTS: +** +** exp Expression to evaluate. +*/ +#if gcdDEBUG +# define gcmVERIFY(exp) gcmASSERT(exp) +# define gcmkVERIFY(exp) gcmkASSERT(exp) +#else +# define gcmVERIFY(exp) exp +# define gcmkVERIFY(exp) exp +#endif + +/******************************************************************************* +** +** gcmVERIFY_OK +** +** Verify a fucntion returns gcvSTATUS_OK. If the function does not return +** gcvSTATUS_OK, an assertion will happen in debug mode. +** +** ARGUMENTS: +** +** func Function to evaluate. +*/ + +void +gcoOS_Verify( + IN gceSTATUS Status + ); + +void +gckOS_Verify( + IN gceSTATUS Status + ); + +#if gcdDEBUG +# define gcmVERIFY_OK(func) \ + do \ + { \ + gceSTATUS verifyStatus = func; \ + gcoOS_Verify(verifyStatus); \ + gcmASSERT(verifyStatus == gcvSTATUS_OK); \ + } \ + while (gcvFALSE) +# define gcmkVERIFY_OK(func) \ + do \ + { \ + gceSTATUS verifyStatus = func; \ + gckOS_Verify(verifyStatus); \ + gcmkASSERT(verifyStatus == gcvSTATUS_OK); \ + } \ + while (gcvFALSE) +#else +# define gcmVERIFY_OK(func) func + +# define gcmkVERIFY_OK(func) func +#endif + +/******************************************************************************* +** +** gcmERR_BREAK +** +** Executes a break statement on error. +** +** ASSUMPTIONS: +** +** 'status' variable of gceSTATUS type must be defined. +** +** ARGUMENTS: +** +** func Function to evaluate. +*/ +#define _gcmERR_BREAK(prefix, func) \ + status = func; \ + if (gcmIS_ERROR(status)) \ + { \ + prefix##TRACE(gcvLEVEL_ERROR, \ + #prefix "ERR_BREAK: status=%d @ %s(%d) in " __FILE__, \ + status, __FUNCTION__, __LINE__); \ + break; \ + } \ + do { } while (gcvFALSE) +#define gcmERR_BREAK(func) _gcmERR_BREAK(gcm, func) +#define gcmkERR_BREAK(func) _gcmERR_BREAK(gcmk, func) + +/******************************************************************************* +** +** gcmERR_RETURN +** +** Executes a return on error. +** +** ASSUMPTIONS: +** +** 'status' variable of gceSTATUS type must be defined. +** +** ARGUMENTS: +** +** func Function to evaluate. +*/ +#define _gcmERR_RETURN(prefix, func) \ + status = func; \ + if (gcmIS_ERROR(status)) \ + { \ + prefix##TRACE(gcvLEVEL_ERROR, \ + #prefix "ERR_RETURN: status=%d @ %s(%d) in " __FILE__, \ + status, __FUNCTION__, __LINE__); \ + return status; \ + } \ + do { } while (gcvFALSE) +#define gcmERR_RETURN(func) _gcmERR_RETURN(gcm, func) +#define gcmkERR_RETURN(func) _gcmERR_RETURN(gcmk, func) + +/******************************************************************************* +** +** gcmONERROR +** +** Jump to the error handler in case there is an error. +** +** ASSUMPTIONS: +** +** 'status' variable of gceSTATUS type must be defined. +** +** ARGUMENTS: +** +** func Function to evaluate. +*/ +#define _gcmONERROR(prefix, func) \ + do \ + { \ + status = func; \ + if (gcmIS_ERROR(status)) \ + { \ + prefix##LOG(_GFX_LOG_ERROR_, \ + "[GC_" #prefix "ONERROR\t] %s(%d): status=%d", \ + __FUNCTION__, __LINE__, status); \ + goto OnError; \ + } \ + } \ + while (gcvFALSE) +#define gcmONERROR(func) _gcmONERROR(gcm, func) +#define gcmkONERROR(func) _gcmONERROR(gcmk, func) + + +/******************************************************************************* +** +** gcmVERIFY_LOCK +** +** Verifies whether the surface is locked. +** +** ARGUMENTS: +** +** surfaceInfo Pointer to the surface iniformational structure. +*/ +#define gcmVERIFY_LOCK(surfaceInfo) \ + if (!surfaceInfo->node.valid) \ + { \ + status = gcvSTATUS_MEMORY_UNLOCKED; \ + break; \ + } \ + do { } while (gcvFALSE) + +/******************************************************************************* +** +** gcmVERIFY_NODE_LOCK +** +** Verifies whether the surface node is locked. +** +** ARGUMENTS: +** +** surfaceInfo Pointer to the surface iniformational structure. +*/ +#define gcmVERIFY_NODE_LOCK(surfaceNode) \ + if (!surfaceNode->valid) \ + { \ + status = gcvSTATUS_MEMORY_UNLOCKED; \ + break; \ + } \ + do { } while (gcvFALSE) + +/******************************************************************************* +** +** gcmBADOBJECT_BREAK +** +** Executes a break statement on bad object. +** +** ARGUMENTS: +** +** obj Object to test. +** t Expected type of the object. +*/ +#define gcmBADOBJECT_BREAK(obj, t) \ + if ((obj == gcvNULL) \ + || (((gcsOBJECT *)(obj))->type != t) \ + ) \ + { \ + status = gcvSTATUS_INVALID_OBJECT; \ + break; \ + } \ + do { } while (gcvFALSE) + +/******************************************************************************* +** +** gcmCHECK_STATUS +** +** Executes a break statement on error. +** +** ASSUMPTIONS: +** +** 'status' variable of gceSTATUS type must be defined. +** +** ARGUMENTS: +** +** func Function to evaluate. +*/ +#define _gcmCHECK_STATUS(prefix, func) \ + do \ + { \ + last = func; \ + if (gcmIS_ERROR(last)) \ + { \ + prefix##TRACE(gcvLEVEL_ERROR, \ + #prefix "CHECK_STATUS: status=%d @ %s(%d) in " __FILE__, \ + last, __FUNCTION__, __LINE__); \ + status = last; \ + } \ + } \ + while (gcvFALSE) +#define gcmCHECK_STATUS(func) _gcmCHECK_STATUS(gcm, func) +#define gcmkCHECK_STATUS(func) _gcmCHECK_STATUS(gcmk, func) + +/******************************************************************************* +** +** gcmVERIFY_ARGUMENT +** +** Assert if an argument does not apply to the specified expression. If +** the argument evaluates to false, gcvSTATUS_INVALID_ARGUMENT will be +** returned from the current function. In retail mode this macro does +** nothing. +** +** ARGUMENTS: +** +** arg Argument to evaluate. +*/ +#ifndef EGL_API_ANDROID +# define _gcmVERIFY_ARGUMENT(prefix, arg) \ + do \ + { \ + if (!(arg)) \ + { \ + prefix##TRACE(gcvLEVEL_ERROR, #prefix "VERIFY_ARGUMENT failed:"); \ + prefix##ASSERT(arg); \ + prefix##FOOTER_ARG("status=%d", gcvSTATUS_INVALID_ARGUMENT); \ + return gcvSTATUS_INVALID_ARGUMENT; \ + } \ + } \ + while (gcvFALSE) +# define gcmVERIFY_ARGUMENT(arg) _gcmVERIFY_ARGUMENT(gcm, arg) +# define gcmkVERIFY_ARGUMENT(arg) _gcmVERIFY_ARGUMENT(gcmk, arg) +#else +# define gcmVERIFY_ARGUMENT(arg) +# define gcmkVERIFY_ARGUMENT(arg) +#endif + +/******************************************************************************* +** +** gcmVERIFY_ARGUMENT_RETURN +** +** Assert if an argument does not apply to the specified expression. If +** the argument evaluates to false, gcvSTATUS_INVALID_ARGUMENT will be +** returned from the current function. In retail mode this macro does +** nothing. +** +** ARGUMENTS: +** +** arg Argument to evaluate. +*/ +#ifndef EGL_API_ANDROID +# define _gcmVERIFY_ARGUMENT_RETURN(prefix, arg, value) \ + do \ + { \ + if (!(arg)) \ + { \ + prefix##TRACE(gcvLEVEL_ERROR, \ + #prefix "gcmVERIFY_ARGUMENT_RETURN failed:"); \ + prefix##ASSERT(arg); \ + prefix##FOOTER_ARG("value=%d", value); \ + return value; \ + } \ + } \ + while (gcvFALSE) +# define gcmVERIFY_ARGUMENT_RETURN(arg, value) \ + _gcmVERIFY_ARGUMENT_RETURN(gcm, arg, value) +# define gcmkVERIFY_ARGUMENT_RETURN(arg, value) \ + _gcmVERIFY_ARGUMENT_RETURN(gcmk, arg, value) +#else +# define gcmVERIFY_ARGUMENT_RETURN(arg, value) +# define gcmkVERIFY_ARGUMENT_RETURN(arg, value) +#endif +void gcoOS_Log(IN unsigned int filter, IN const char* msg, + ... + ); + +void gckOS_Log(IN unsigned int filter, IN const char* msg, + ... + ); + +void gcoOS_SetLogFilter(IN unsigned int filter); + +void gckOS_SetLogFilter(IN unsigned int filter); + +#define gcmLOG gcoOS_Log +#define gcmkLOG gckOS_Log + +#define _gcmLOG_STATUS(prefix, tag, filter) \ + do \ + { \ + prefix##LOG(filter, \ + "[GC_" #tag "\t] %s@%d: status=%d\n", \ + __FUNCTION__, __LINE__, status); \ + } \ + while (gcvFALSE) + +#define gcmLOG_WARNING_STATUS() _gcmLOG_STATUS(gcm, WARNING, _GFX_LOG_WARNING_) +#define gcmLOG_ERROR_STATUS() _gcmLOG_STATUS(gcm, ERR_RETURN, _GFX_LOG_ERROR_) + +#define gcmkLOG_WARNING_STATUS() _gcmLOG_STATUS(gcmk, WARNING, _GFX_LOG_WARNING_) +#define gcmkLOG_ERROR_STATUS() _gcmLOG_STATUS(gcmk, ERR_RETURN, _GFX_LOG_ERROR_) + +#if gcdHAS_ELLIPSES +#define _gcmLOG_ARGS(prefix, tag, filter, TEXT, ...) \ + do \ + { \ + prefix##LOG(filter, \ + "[GC_" #tag "\t] %s@%d: " TEXT "\n", \ + __FUNCTION__, __LINE__, ##__VA_ARGS__); \ + } \ + while (gcvFALSE) + +#define gcmLOG_WARNING_ARGS(TEXT, ...) _gcmLOG_ARGS(gcm, WARNING, _GFX_LOG_WARNING_, TEXT, ##__VA_ARGS__) +#define gcmLOG_ERROR_ARGS(TEXT, ...) _gcmLOG_ARGS(gcm, ERR_RETURN, _GFX_LOG_ERROR_, TEXT, ##__VA_ARGS__) + +#define gcmkLOG_WARNING_ARGS(TEXT, ...) _gcmLOG_ARGS(gcmk, WARNING, _GFX_LOG_WARNING_, TEXT, ##__VA_ARGS__) +#define gcmkLOG_ERROR_ARGS(TEXT, ...) _gcmLOG_ARGS(gcmk, ERR_RETURN, _GFX_LOG_ERROR_, TEXT, ##__VA_ARGS__) +#else + gcmINLINE static void + __dummy_log_args( + IN gctCONST_STRING Text, + ... + ) + { + } +#define gcmLOG_WARNING_ARGS __dummy_log_args +#define gcmLOG_ERROR_ARGS __dummy_log_args +#define gcmkLOG_WARNING_ARGS __dummy_log_args +#define gcmkLOG_ERROR_ARGS __dummy_log_args +#endif + + /* Logging service */ +#define _GFX_LOG_NONE_ 0x00000000 +#define _GFX_LOG_ERROR_ 0x00000001 +#define _GFX_LOG_WARNING_ 0x00000002 +#define _GFX_LOG_EGL_API_ 0x00000004 +#define _GFX_LOG_NATIVE_API_ 0x00000008 +#define _GFX_LOG_OES_API_ 0x00000010 +#define _GFX_LOG_VG_API_ 0x00000020 +#define _GFX_LOG_CONFIG_ 0x00000040 +#define _GFX_LOG_INFO_ 0x00000080 +#define _GFX_LOG_NOTIFY_ 0x00000100 +#define _GFX_LOG_ALL_ 0xffffffff + + +#if MRVL_ENABLE_EGL_API_LOG +#define EGL_API_LOG(x) gcoOS_Log x +#else +#define EGL_API_LOG(x) +#endif +#define EGL_LOG(x) gcoOS_Log x + + +#if MRVL_ENABLE_OES1_API_LOG +#define OES11_API_LOG(x) gcoOS_Log x +#else +#define OES11_API_LOG(x) +#endif +#define OES11_LOG(x) gcoOS_Log x + +#if MRVL_ENABLE_OES2_API_LOG +#define OES20_API_LOG(x) gcoOS_Log x +#else +#define OES20_API_LOG(x) +#endif +#define OES20_LOG(x) gcoOS_Log x + +#if MRVL_ENABLE_OVG_API_LOG +#define OVG_API_LOG(x) gcoOS_Log x +#else +#define OVG_API_LOG(x) +#endif +#define OVG_LOG(x) gcoOS_Log x +#ifdef __cplusplus +} +#endif + +#endif /* __gc_hal_base_h_ */ diff --git a/native/include_dove/gc_hal_compiler.h b/native/include_dove/gc_hal_compiler.h new file mode 100644 index 0000000..6bc96b2 --- /dev/null +++ b/native/include_dove/gc_hal_compiler.h @@ -0,0 +1,1841 @@ +/**************************************************************************** +* +* Copyright (C) 2005 - 2010 by Vivante Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the license, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +* +*****************************************************************************/ + + + + +/* +** Include file the defines the front- and back-end compilers, as well as the +** objects they use. +*/ + +#ifndef __gc_hal_compiler_h_ +#define __gc_hal_compiler_h_ + +#include "gc_hal_types.h" +#include "gc_hal_engine.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/******************************************************************************\ +|******************************* SHADER LANGUAGE ******************************| +\******************************************************************************/ + +/* Possible shader language opcodes. */ +typedef enum _gcSL_OPCODE +{ + gcSL_NOP, /* 0x00 */ + gcSL_MOV, /* 0x01 */ + gcSL_SAT, /* 0x02 */ + gcSL_DP3, /* 0x03 */ + gcSL_DP4, /* 0x04 */ + gcSL_ABS, /* 0x05 */ + gcSL_JMP, /* 0x06 */ + gcSL_ADD, /* 0x07 */ + gcSL_MUL, /* 0x08 */ + gcSL_RCP, /* 0x09 */ + gcSL_SUB, /* 0x0A */ + gcSL_KILL, /* 0x0B */ + gcSL_TEXLD, /* 0x0C */ + gcSL_CALL, /* 0x0D */ + gcSL_RET, /* 0x0E */ + gcSL_NORM, /* 0x0F */ + gcSL_MAX, /* 0x10 */ + gcSL_MIN, /* 0x11 */ + gcSL_POW, /* 0x12 */ + gcSL_RSQ, /* 0x13 */ + gcSL_LOG, /* 0x14 */ + gcSL_FRAC, /* 0x15 */ + gcSL_FLOOR, /* 0x16 */ + gcSL_CEIL, /* 0x17 */ + gcSL_CROSS, /* 0x18 */ + gcSL_TEXLDP, /* 0x19 */ + gcSL_TEXBIAS, /* 0x1A */ + gcSL_TEXGRAD, /* 0x1B */ + gcSL_TEXLOD, /* 0x1C */ + gcSL_SIN, /* 0x1D */ + gcSL_COS, /* 0x1E */ + gcSL_TAN, /* 0x1F */ + gcSL_EXP, /* 0x20 */ + gcSL_SIGN, /* 0x21 */ + gcSL_STEP, /* 0x22 */ + gcSL_SQRT, /* 0x23 */ + gcSL_ACOS, /* 0x24 */ + gcSL_ASIN, /* 0x25 */ + gcSL_ATAN, /* 0x26 */ + gcSL_SET, /* 0x27 */ + gcSL_DSX, /* 0x28 */ + gcSL_DSY, /* 0x29 */ + gcSL_FWIDTH, /* 0x2A */ +} +gcSL_OPCODE; + +typedef enum _gcSL_FORMAT +{ + gcSL_FLOAT, /* 0 */ + gcSL_INTEGER, /* 1 */ + gcSL_BOOLEAN, /* 2 */ +} +gcSL_FORMAT; + +/* Destination write enable bits. */ +typedef enum _gcSL_ENABLE +{ + gcSL_ENABLE_X = 0x1, + gcSL_ENABLE_Y = 0x2, + gcSL_ENABLE_Z = 0x4, + gcSL_ENABLE_W = 0x8, + /* Combinations. */ + gcSL_ENABLE_XY = gcSL_ENABLE_X | gcSL_ENABLE_Y, + gcSL_ENABLE_XYZ = gcSL_ENABLE_X | gcSL_ENABLE_Y | gcSL_ENABLE_Z, + gcSL_ENABLE_XYZW = gcSL_ENABLE_X | gcSL_ENABLE_Y | gcSL_ENABLE_Z | gcSL_ENABLE_W, + gcSL_ENABLE_XYW = gcSL_ENABLE_X | gcSL_ENABLE_Y | gcSL_ENABLE_W, + gcSL_ENABLE_XZ = gcSL_ENABLE_X | gcSL_ENABLE_Z, + gcSL_ENABLE_XZW = gcSL_ENABLE_X | gcSL_ENABLE_Z | gcSL_ENABLE_W, + gcSL_ENABLE_XW = gcSL_ENABLE_X | gcSL_ENABLE_W, + gcSL_ENABLE_YZ = gcSL_ENABLE_Y | gcSL_ENABLE_Z, + gcSL_ENABLE_YZW = gcSL_ENABLE_Y | gcSL_ENABLE_Z | gcSL_ENABLE_W, + gcSL_ENABLE_YW = gcSL_ENABLE_Y | gcSL_ENABLE_W, + gcSL_ENABLE_ZW = gcSL_ENABLE_Z | gcSL_ENABLE_W, +} +gcSL_ENABLE; + +/* Possible indices. */ +typedef enum _gcSL_INDEXED +{ + gcSL_NOT_INDEXED, /* 0 */ + gcSL_INDEXED_X, /* 1 */ + gcSL_INDEXED_Y, /* 2 */ + gcSL_INDEXED_Z, /* 3 */ + gcSL_INDEXED_W, /* 4 */ +} +gcSL_INDEXED; + +/* Opcode conditions. */ +typedef enum _gcSL_CONDITION +{ + gcSL_ALWAYS, /* 0x0 */ + gcSL_NOT_EQUAL, /* 0x1 */ + gcSL_LESS_OR_EQUAL, /* 0x2 */ + gcSL_LESS, /* 0x3 */ + gcSL_EQUAL, /* 0x4 */ + gcSL_GREATER, /* 0x5 */ + gcSL_GREATER_OR_EQUAL, /* 0x6 */ + gcSL_AND, /* 0x7 */ + gcSL_OR, /* 0x8 */ + gcSL_XOR, /* 0x9 */ +} +gcSL_CONDITION; + +/* Possible source operand types. */ +typedef enum _gcSL_TYPE +{ + gcSL_NONE, /* 0x0 */ + gcSL_TEMP, /* 0x1 */ + gcSL_ATTRIBUTE, /* 0x2 */ + gcSL_UNIFORM, /* 0x3 */ + gcSL_SAMPLER, /* 0x4 */ + gcSL_CONSTANT, /* 0x5 */ + gcSL_OUTPUT, /* 0x6 */ + gcSL_PHYSICAL, /* 0x7 */ +} +gcSL_TYPE; + +/* Swizzle generator macro. */ +#define gcmSWIZZLE(Component1, Component2, Component3, Component4) \ +( \ + (gcSL_SWIZZLE_ ## Component1 << 0) | \ + (gcSL_SWIZZLE_ ## Component2 << 2) | \ + (gcSL_SWIZZLE_ ## Component3 << 4) | \ + (gcSL_SWIZZLE_ ## Component4 << 6) \ +) + +/* Possible swizzle values. */ +typedef enum _gcSL_SWIZZLE +{ + gcSL_SWIZZLE_X, /* 0x0 */ + gcSL_SWIZZLE_Y, /* 0x1 */ + gcSL_SWIZZLE_Z, /* 0x2 */ + gcSL_SWIZZLE_W, /* 0x3 */ + /* Combinations. */ + gcSL_SWIZZLE_XXXX = gcmSWIZZLE(X, X, X, X), + gcSL_SWIZZLE_YYYY = gcmSWIZZLE(Y, Y, Y, Y), + gcSL_SWIZZLE_ZZZZ = gcmSWIZZLE(Z, Z, Z, Z), + gcSL_SWIZZLE_WWWW = gcmSWIZZLE(W, W, W, W), + gcSL_SWIZZLE_XYYY = gcmSWIZZLE(X, Y, Y, Y), + gcSL_SWIZZLE_XZZZ = gcmSWIZZLE(X, Z, Z, Z), + gcSL_SWIZZLE_XWWW = gcmSWIZZLE(X, W, W, W), + gcSL_SWIZZLE_YZZZ = gcmSWIZZLE(Y, Z, Z, Z), + gcSL_SWIZZLE_YWWW = gcmSWIZZLE(Y, W, W, W), + gcSL_SWIZZLE_ZWWW = gcmSWIZZLE(Z, W, W, W), + gcSL_SWIZZLE_XYZZ = gcmSWIZZLE(X, Y, Z, Z), + gcSL_SWIZZLE_XYWW = gcmSWIZZLE(X, Y, W, W), + gcSL_SWIZZLE_XZWW = gcmSWIZZLE(X, Z, W, W), + gcSL_SWIZZLE_YZWW = gcmSWIZZLE(Y, Z, W, W), + gcSL_SWIZZLE_XXYZ = gcmSWIZZLE(X, X, Y, Z), + gcSL_SWIZZLE_XYZW = gcmSWIZZLE(X, Y, Z, W), + gcSL_SWIZZLE_XYXY = gcmSWIZZLE(X, Y, X, Y), +} +gcSL_SWIZZLE; + + +/******************************************************************************\ +|*********************************** SHADERS **********************************| +\******************************************************************************/ + +/* Shader types. */ +#define gcSHADER_TYPE_UNKNOWN 0 +#define gcSHADER_TYPE_VERTEX 1 +#define gcSHADER_TYPE_FRAGMENT 2 + +/* gcSHADER objects. */ +typedef struct _gcSHADER * gcSHADER; +typedef struct _gcATTRIBUTE * gcATTRIBUTE; +typedef struct _gcUNIFORM * gcUNIFORM; +typedef struct _gcOUTPUT * gcOUTPUT; +typedef struct _gcsFUNCTION * gcFUNCTION; +typedef struct _gcsHINT * gcsHINT_PTR; +typedef struct _gcSHADER_PROFILER * gcSHADER_PROFILER; +typedef struct _gcVARIABLE * gcVARIABLE; + +/* gcSHADER_TYPE enumeration. */ +typedef enum _gcSHADER_TYPE +{ + gcSHADER_FLOAT_X1, /* 0x00 */ + gcSHADER_FLOAT_X2, /* 0x01 */ + gcSHADER_FLOAT_X3, /* 0x02 */ + gcSHADER_FLOAT_X4, /* 0x03 */ + gcSHADER_FLOAT_2X2, /* 0x04 */ + gcSHADER_FLOAT_3X3, /* 0x05 */ + gcSHADER_FLOAT_4X4, /* 0x06 */ + gcSHADER_BOOLEAN_X1, /* 0x07 */ + gcSHADER_BOOLEAN_X2, /* 0x08 */ + gcSHADER_BOOLEAN_X3, /* 0x09 */ + gcSHADER_BOOLEAN_X4, /* 0x0A */ + gcSHADER_INTEGER_X1, /* 0x0B */ + gcSHADER_INTEGER_X2, /* 0x0C */ + gcSHADER_INTEGER_X3, /* 0x0D */ + gcSHADER_INTEGER_X4, /* 0x0E */ + gcSHADER_SAMPLER_1D, /* 0x0F */ + gcSHADER_SAMPLER_2D, /* 0x10 */ + gcSHADER_SAMPLER_3D, /* 0x11 */ + gcSHADER_SAMPLER_CUBIC, /* 0x12 */ + gcSHADER_FIXED_X1, /* 0x13 */ + gcSHADER_FIXED_X2, /* 0x14 */ + gcSHADER_FIXED_X3, /* 0x15 */ + gcSHADER_FIXED_X4, /* 0x16 */ +} +gcSHADER_TYPE; + +/* Shader flags. */ +typedef enum _gceSHADER_FLAGS +{ + gcvSHADER_DEAD_CODE = 0x01, + gcvSHADER_RESOURCE_USAGE = 0x02, + gcvSHADER_OPTIMIZER = 0x04, + gcvSHADER_USE_GL_Z = 0x08, + gcvSHADER_USE_GL_POSITION = 0x10, + gcvSHADER_USE_GL_FACE = 0x20, + gcvSHADER_USE_GL_POINT_COORD = 0x40, +} +gceSHADER_FLAGS; + +/* Function argument qualifier */ +typedef enum _gceINPUT_OUTPUT +{ + gcvFUNCTION_INPUT, + gcvFUNCTION_OUTPUT, + gcvFUNCTION_INOUT +} +gceINPUT_OUTPUT; + +/******************************************************************************* +** gcSHADER_Construct +******************************************************************************** +** +** Construct a new gcSHADER object. +** +** INPUT: +** +** gcoOS Hal +** Pointer to an gcoHAL object. +** +** gctINT ShaderType +** Type of gcSHADER object to cerate. 'ShaderType' can be one of the +** following: +** +** gcSHADER_TYPE_VERTEX Vertex shader. +** gcSHADER_TYPE_FRAGMENT Fragment shader. +** +** OUTPUT: +** +** gcSHADER * Shader +** Pointer to a variable receiving the gcSHADER object pointer. +*/ +gceSTATUS +gcSHADER_Construct( + IN gcoHAL Hal, + IN gctINT ShaderType, + OUT gcSHADER * Shader + ); + +/******************************************************************************* +** gcSHADER_Destroy +******************************************************************************** +** +** Destroy a gcSHADER object. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gcSHADER_Destroy( + IN gcSHADER Shader + ); + +/******************************************************************************* +** gcSHADER_Load +******************************************************************************** +** +** Load a gcSHADER object from a binary buffer. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gctPOINTER Buffer +** Pointer to a binary buffer containg the shader data to load. +** +** gctSIZE_T BufferSize +** Number of bytes inside the binary buffer pointed to by 'Buffer'. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gcSHADER_Load( + IN gcSHADER Shader, + IN gctPOINTER Buffer, + IN gctSIZE_T BufferSize + ); + +/******************************************************************************* +** gcSHADER_Save +******************************************************************************** +** +** Save a gcSHADER object to a binary buffer. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gctPOINTER Buffer +** Pointer to a binary buffer to be used as storage for the gcSHADER +** object. If 'Buffer' is gcvNULL, the gcSHADER object will not be saved, +** but the number of bytes required to hold the binary output for the +** gcSHADER object will be returned. +** +** gctSIZE_T * BufferSize +** Pointer to a variable holding the number of bytes allocated in +** 'Buffer'. Only valid if 'Buffer' is not gcvNULL. +** +** OUTPUT: +** +** gctSIZE_T * BufferSize +** Pointer to a variable receiving the number of bytes required to hold +** the binary form of the gcSHADER object. +*/ +gceSTATUS +gcSHADER_Save( + IN gcSHADER Shader, + IN gctPOINTER Buffer, + IN OUT gctSIZE_T * BufferSize + ); + +/******************************************************************************* +** gcSHADER_AddAttribute +******************************************************************************** +** +** Add an attribute to a gcSHADER object. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gctCONST_STRING Name +** Name of the attribute to add. +** +** gcSHADER_TYPE Type +** Type of the attribute to add. +** +** gctSIZE_T Length +** Array length of the attribute to add. 'Length' must be at least 1. +** +** gctBOOL IsTexture +** gcvTRUE if the attribute is used as a texture coordinate, gcvFALSE if not. +** +** OUTPUT: +** +** gcATTRIBUTE * Attribute +** Pointer to a variable receiving the gcATTRIBUTE object pointer. +*/ +gceSTATUS +gcSHADER_AddAttribute( + IN gcSHADER Shader, + IN gctCONST_STRING Name, + IN gcSHADER_TYPE Type, + IN gctSIZE_T Length, + IN gctBOOL IsTexture, + OUT gcATTRIBUTE * Attribute + ); + +/******************************************************************************* +** gcSHADER_GetAttributeCount +******************************************************************************** +** +** Get the number of attributes for this shader. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** OUTPUT: +** +** gctSIZE_T * Count +** Pointer to a variable receiving the number of attributes. +*/ +gceSTATUS +gcSHADER_GetAttributeCount( + IN gcSHADER Shader, + OUT gctSIZE_T * Count + ); + +/******************************************************************************* +** gcSHADER_GetAttribute +******************************************************************************** +** +** Get the gcATTRIBUTE object poniter for an indexed attribute for this shader. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gctUINT Index +** Index of the attribute to retrieve. +** +** OUTPUT: +** +** gcATTRIBUTE * Attribute +** Pointer to a variable receiving the gcATTRIBUTE object pointer. +*/ +gceSTATUS +gcSHADER_GetAttribute( + IN gcSHADER Shader, + IN gctUINT Index, + OUT gcATTRIBUTE * Attribute + ); + +/******************************************************************************* +** gcSHADER_GetPositionAttribute +******************************************************************************** +** +** Get the gcATTRIBUTE object pointer for the attribute that defines the +** position. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** OUTPUT: +** +** gctUINT * Index +** Pointer to a variable receiving the index of te gcATTRIBUTE object +** used as a position. +** +** gcATTRIBUTE * Attribute +** Pointer to a variable receiving the gcATTRIBUTE object pointer. +*/ +gceSTATUS +gcSHADER_GetPositionAttribute( + IN gcSHADER Shader, + OUT gctUINT * Index, + OUT gcATTRIBUTE * Attribute + ); + +/******************************************************************************* +** gcSHADER_AddUniform +******************************************************************************** +** +** Add an uniform to a gcSHADER object. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gctCONST_STRING Name +** Name of the uniform to add. +** +** gcSHADER_TYPE Type +** Type of the uniform to add. +** +** gctSIZE_T Length +** Array length of the uniform to add. 'Length' must be at least 1. +** +** OUTPUT: +** +** gcUNIFORM * Uniform +** Pointer to a variable receiving the gcUNIFORM object pointer. +*/ +gceSTATUS +gcSHADER_AddUniform( + IN gcSHADER Shader, + IN gctCONST_STRING Name, + IN gcSHADER_TYPE Type, + IN gctSIZE_T Length, + OUT gcUNIFORM * Uniform + ); + +/******************************************************************************* +** gcSHADER_GetUniformCount +******************************************************************************** +** +** Get the number of uniforms for this shader. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** OUTPUT: +** +** gctSIZE_T * Count +** Pointer to a variable receiving the number of uniforms. +*/ +gceSTATUS +gcSHADER_GetUniformCount( + IN gcSHADER Shader, + OUT gctSIZE_T * Count + ); + +/******************************************************************************* +** gcSHADER_GetUniform +******************************************************************************** +** +** Get the gcUNIFORM object pointer for an indexed uniform for this shader. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gctUINT Index +** Index of the uniform to retrieve. +** +** OUTPUT: +** +** gcUNIFORM * Uniform +** Pointer to a variable receiving the gcUNIFORM object pointer. +*/ +gceSTATUS +gcSHADER_GetUniform( + IN gcSHADER Shader, + IN gctUINT Index, + OUT gcUNIFORM * Uniform + ); + +/******************************************************************************* +** gcSHADER_AddOutput +******************************************************************************** +** +** Add an output to a gcSHADER object. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gctCONST_STRING Name +** Name of the output to add. +** +** gcSHADER_TYPE Type +** Type of the output to add. +** +** gctSIZE_T Length +** Array length of the output to add. 'Length' must be at least 1. +** +** gctUINT16 TempRegister +** Temporary register index that holds the output value. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gcSHADER_AddOutput( + IN gcSHADER Shader, + IN gctCONST_STRING Name, + IN gcSHADER_TYPE Type, + IN gctSIZE_T Length, + IN gctUINT16 TempRegister + ); + +gceSTATUS +gcSHADER_AddOutputIndexed( + IN gcSHADER Shader, + IN gctCONST_STRING Name, + IN gctSIZE_T Index, + IN gctUINT16 TempIndex + ); + +/******************************************************************************* +** gcSHADER_GetOutputCount +******************************************************************************** +** +** Get the number of outputs for this shader. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** OUTPUT: +** +** gctSIZE_T * Count +** Pointer to a variable receiving the number of outputs. +*/ +gceSTATUS +gcSHADER_GetOutputCount( + IN gcSHADER Shader, + OUT gctSIZE_T * Count + ); + +/******************************************************************************* +** gcSHADER_GetOutput +******************************************************************************** +** +** Get the gcOUTPUT object pointer for an indexed output for this shader. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gctUINT Index +** Index of output to retrieve. +** +** OUTPUT: +** +** gcOUTPUT * Output +** Pointer to a variable receiving the gcOUTPUT object pointer. +*/ +gceSTATUS +gcSHADER_GetOutput( + IN gcSHADER Shader, + IN gctUINT Index, + OUT gcOUTPUT * Output + ); + +/******************************************************************************* +** gcSHADER_AddVariable +******************************************************************************** +** +** Add a variable to a gcSHADER object. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gctCONST_STRING Name +** Name of the variable to add. +** +** gcSHADER_TYPE Type +** Type of the variable to add. +** +** gctSIZE_T Length +** Array length of the variable to add. 'Length' must be at least 1. +** +** gctUINT16 TempRegister +** Temporary register index that holds the variable value. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gcSHADER_AddVariable( + IN gcSHADER Shader, + IN gctCONST_STRING Name, + IN gcSHADER_TYPE Type, + IN gctSIZE_T Length, + IN gctUINT16 TempRegister + ); + +/******************************************************************************* +** gcSHADER_GetVariableCount +******************************************************************************** +** +** Get the number of variables for this shader. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** OUTPUT: +** +** gctSIZE_T * Count +** Pointer to a variable receiving the number of variables. +*/ +gceSTATUS +gcSHADER_GetVariableCount( + IN gcSHADER Shader, + OUT gctSIZE_T * Count + ); + +/******************************************************************************* +** gcSHADER_GetVariable +******************************************************************************** +** +** Get the gcVARIABLE object pointer for an indexed variable for this shader. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gctUINT Index +** Index of variable to retrieve. +** +** OUTPUT: +** +** gcVARIABLE * Variable +** Pointer to a variable receiving the gcVARIABLE object pointer. +*/ +gceSTATUS +gcSHADER_GetVariable( + IN gcSHADER Shader, + IN gctUINT Index, + OUT gcVARIABLE * Variable + ); + +/******************************************************************************* +** gcSHADER_AddOpcode +******************************************************************************** +** +** Add an opcode to a gcSHADER object. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gcSL_OPCODE Opcode +** Opcode to add. +** +** gctUINT16 TempRegister +** Temporary register index that acts as the target of the opcode. +** +** gctUINT8 Enable +** Write enable bits for the temporary register that acts as the target +** of the opcode. +** +** gcSL_FORMAT Format +** Format of the temporary register. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gcSHADER_AddOpcode( + IN gcSHADER Shader, + IN gcSL_OPCODE Opcode, + IN gctUINT16 TempRegister, + IN gctUINT8 Enable, + IN gcSL_FORMAT Format + ); + +gceSTATUS +gcSHADER_AddOpcode2( + IN gcSHADER Shader, + IN gcSL_OPCODE Opcode, + IN gcSL_CONDITION Condition, + IN gctUINT16 TempRegister, + IN gctUINT8 Enable, + IN gcSL_FORMAT Format + ); + +/******************************************************************************* +** gcSHADER_AddOpcodeIndexed +******************************************************************************** +** +** Add an opcode to a gcSHADER object that writes to an dynamically indexed +** target. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gcSL_OPCODE Opcode +** Opcode to add. +** +** gctUINT16 TempRegister +** Temporary register index that acts as the target of the opcode. +** +** gctUINT8 Enable +** Write enable bits for the temporary register that acts as the +** target of the opcode. +** +** gcSL_INDEXED Mode +** Location of the dynamic index inside the temporary register. Valid +** values can be: +** +** gcSL_INDEXED_X - Use x component of the temporary register. +** gcSL_INDEXED_Y - Use y component of the temporary register. +** gcSL_INDEXED_Z - Use z component of the temporary register. +** gcSL_INDEXED_W - Use w component of the temporary register. +** +** gctUINT16 IndexRegister +** Temporary register index that holds the dynamic index. +** +** gcSL_FORMAT Format +** Format of the temporary register. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gcSHADER_AddOpcodeIndexed( + IN gcSHADER Shader, + IN gcSL_OPCODE Opcode, + IN gctUINT16 TempRegister, + IN gctUINT8 Enable, + IN gcSL_INDEXED Mode, + IN gctUINT16 IndexRegister, + IN gcSL_FORMAT Format + ); + +/******************************************************************************* +** gcSHADER_AddOpcodeConditional +******************************************************************************** +** +** Add an conditional opcode to a gcSHADER object. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gcSL_OPCODE Opcode +** Opcode to add. +** +** gcSL_CONDITION Condition +** Condition that needs to evaluate to gcvTRUE in order for the opcode to +** execute. +** +** gctUINT Label +** Target label if 'Condition' evaluates to gcvTRUE. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gcSHADER_AddOpcodeConditional( + IN gcSHADER Shader, + IN gcSL_OPCODE Opcode, + IN gcSL_CONDITION Condition, + IN gctUINT Label + ); + +/******************************************************************************* +** gcSHADER_AddLabel +******************************************************************************** +** +** Define a label at the current instruction of a gcSHADER object. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gctUINT Label +** Label to define. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gcSHADER_AddLabel( + IN gcSHADER Shader, + IN gctUINT Label + ); + +/******************************************************************************* +** gcSHADER_AddSource +******************************************************************************** +** +** Add a source operand to a gcSHADER object. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gcSL_TYPE Type +** Type of the source operand. +** +** gctUINT16 SourceIndex +** Index of the source operand. +** +** gctUINT8 Swizzle +** x, y, z, and w swizzle values packed into one 8-bit value. +** +** gcSL_FORMAT Format +** Format of the source operand. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gcSHADER_AddSource( + IN gcSHADER Shader, + IN gcSL_TYPE Type, + IN gctUINT16 SourceIndex, + IN gctUINT8 Swizzle, + IN gcSL_FORMAT Format + ); + +/******************************************************************************* +** gcSHADER_AddSourceIndexed +******************************************************************************** +** +** Add a dynamically indexed source operand to a gcSHADER object. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gcSL_TYPE Type +** Type of the source operand. +** +** gctUINT16 SourceIndex +** Index of the source operand. +** +** gctUINT8 Swizzle +** x, y, z, and w swizzle values packed into one 8-bit value. +** +** gcSL_INDEXED Mode +** Addressing mode for the index. +** +** gctUINT16 IndexRegister +** Temporary register index that holds the dynamic index. +** +** gcSL_FORMAT Format +** Format of the source operand. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gcSHADER_AddSourceIndexed( + IN gcSHADER Shader, + IN gcSL_TYPE Type, + IN gctUINT16 SourceIndex, + IN gctUINT8 Swizzle, + IN gcSL_INDEXED Mode, + IN gctUINT16 IndexRegister, + IN gcSL_FORMAT Format + ); + +/******************************************************************************* +** gcSHADER_AddSourceAttribute +******************************************************************************** +** +** Add an attribute as a source operand to a gcSHADER object. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gcATTRIBUTE Attribute +** Pointer to a gcATTRIBUTE object. +** +** gctUINT8 Swizzle +** x, y, z, and w swizzle values packed into one 8-bit value. +** +** gctINT Index +** Static index into the attribute in case the attribute is a matrix +** or array. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gcSHADER_AddSourceAttribute( + IN gcSHADER Shader, + IN gcATTRIBUTE Attribute, + IN gctUINT8 Swizzle, + IN gctINT Index + ); + +/******************************************************************************* +** gcSHADER_AddSourceAttributeIndexed +******************************************************************************** +** +** Add an indexed attribute as a source operand to a gcSHADER object. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gcATTRIBUTE Attribute +** Pointer to a gcATTRIBUTE object. +** +** gctUINT8 Swizzle +** x, y, z, and w swizzle values packed into one 8-bit value. +** +** gctINT Index +** Static index into the attribute in case the attribute is a matrix +** or array. +** +** gcSL_INDEXED Mode +** Addressing mode of the dynamic index. +** +** gctUINT16 IndexRegister +** Temporary register index that holds the dynamic index. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gcSHADER_AddSourceAttributeIndexed( + IN gcSHADER Shader, + IN gcATTRIBUTE Attribute, + IN gctUINT8 Swizzle, + IN gctINT Index, + IN gcSL_INDEXED Mode, + IN gctUINT16 IndexRegister + ); + +/******************************************************************************* +** gcSHADER_AddSourceUniform +******************************************************************************** +** +** Add a uniform as a source operand to a gcSHADER object. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gcUNIFORM Uniform +** Pointer to a gcUNIFORM object. +** +** gctUINT8 Swizzle +** x, y, z, and w swizzle values packed into one 8-bit value. +** +** gctINT Index +** Static index into the uniform in case the uniform is a matrix or +** array. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gcSHADER_AddSourceUniform( + IN gcSHADER Shader, + IN gcUNIFORM Uniform, + IN gctUINT8 Swizzle, + IN gctINT Index + ); + +/******************************************************************************* +** gcSHADER_AddSourceUniformIndexed +******************************************************************************** +** +** Add an indexed uniform as a source operand to a gcSHADER object. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gcUNIFORM Uniform +** Pointer to a gcUNIFORM object. +** +** gctUINT8 Swizzle +** x, y, z, and w swizzle values packed into one 8-bit value. +** +** gctINT Index +** Static index into the uniform in case the uniform is a matrix or +** array. +** +** gcSL_INDEXED Mode +** Addressing mode of the dynamic index. +** +** gctUINT16 IndexRegister +** Temporary register index that holds the dynamic index. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gcSHADER_AddSourceUniformIndexed( + IN gcSHADER Shader, + IN gcUNIFORM Uniform, + IN gctUINT8 Swizzle, + IN gctINT Index, + IN gcSL_INDEXED Mode, + IN gctUINT16 IndexRegister + ); + +gceSTATUS +gcSHADER_AddSourceSamplerIndexed( + IN gcSHADER Shader, + IN gctUINT8 Swizzle, + IN gcSL_INDEXED Mode, + IN gctUINT16 IndexRegister + ); + +/******************************************************************************* +** gcSHADER_AddSourceConstant +******************************************************************************** +** +** Add a constant floating pointer value as a source operand to a gcSHADER +** object. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gctFLOAT Constant +** Floating pointer constant. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gcSHADER_AddSourceConstant( + IN gcSHADER Shader, + IN gctFLOAT Constant + ); + +/******************************************************************************* +** gcSHADER_Pack +******************************************************************************** +** +** Pack a dynamically created gcSHADER object by trimming the allocated arrays +** and resolving all the labeling. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gcSHADER_Pack( + IN gcSHADER Shader + ); + +/******************************************************************************* +** gcSHADER_SetOptimizationOption +******************************************************************************** +** +** Set optimization option of a gcSHADER object. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object. +** +** gctUINT OptimizationOption +** Optimization option. Can be one of the following: +** +** 0 - No optimization. +** 1 - Full optimization. +** Other value - For optimizer testing. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gcSHADER_SetOptimizationOption( + IN gcSHADER Shader, + IN gctUINT OptimizationOption + ); + +gceSTATUS +gcSHADER_AddFunction( + IN gcSHADER Shader, + IN gctCONST_STRING Name, + OUT gcFUNCTION * Function + ); + +gceSTATUS +gcSHADER_BeginFunction( + IN gcSHADER Shader, + IN gcFUNCTION Function + ); + +gceSTATUS +gcSHADER_EndFunction( + IN gcSHADER Shader, + IN gcFUNCTION Function + ); + +/******************************************************************************* +** gcATTRIBUTE_GetType +******************************************************************************** +** +** Get the type and array length of a gcATTRIBUTE object. +** +** INPUT: +** +** gcATTRIBUTE Attribute +** Pointer to a gcATTRIBUTE object. +** +** OUTPUT: +** +** gcSHADER_TYPE * Type +** Pointer to a variable receiving the type of the attribute. 'Type' +** can be gcvNULL, in which case no type will be returned. +** +** gctSIZE_T * ArrayLength +** Pointer to a variable receiving the length of the array if the +** attribute was declared as an array. If the attribute was not +** declared as an array, the array length will be 1. 'ArrayLength' can +** be gcvNULL, in which case no array length will be returned. +*/ +gceSTATUS +gcATTRIBUTE_GetType( + IN gcATTRIBUTE Attribute, + OUT gcSHADER_TYPE * Type, + OUT gctSIZE_T * ArrayLength + ); + +/******************************************************************************* +** gcATTRIBUTE_GetName +******************************************************************************** +** +** Get the name of a gcATTRIBUTE object. +** +** INPUT: +** +** gcATTRIBUTE Attribute +** Pointer to a gcATTRIBUTE object. +** +** OUTPUT: +** +** gctSIZE_T * Length +** Pointer to a variable receiving the length of the attribute name. +** 'Length' can be gcvNULL, in which case no length will be returned. +** +** gctCONST_STRING * Name +** Pointer to a variable receiving the pointer to the attribute name. +** 'Name' can be gcvNULL, in which case no name will be returned. +*/ +gceSTATUS +gcATTRIBUTE_GetName( + IN gcATTRIBUTE Attribute, + OUT gctSIZE_T * Length, + OUT gctCONST_STRING * Name + ); + +/******************************************************************************* +** gcATTRIBUTE_IsEnabled +******************************************************************************** +** +** Query the enabled state of a gcATTRIBUTE object. +** +** INPUT: +** +** gcATTRIBUTE Attribute +** Pointer to a gcATTRIBUTE object. +** +** OUTPUT: +** +** gctBOOL * Enabled +** Pointer to a variable receiving the enabled state of the attribute. +*/ +gceSTATUS +gcATTRIBUTE_IsEnabled( + IN gcATTRIBUTE Attribute, + OUT gctBOOL * Enabled + ); + +/******************************************************************************* +** gcUNIFORM_GetType +******************************************************************************** +** +** Get the type and array length of a gcUNIFORM object. +** +** INPUT: +** +** gcUNIFORM Uniform +** Pointer to a gcUNIFORM object. +** +** OUTPUT: +** +** gcSHADER_TYPE * Type +** Pointer to a variable receiving the type of the uniform. 'Type' can +** be gcvNULL, in which case no type will be returned. +** +** gctSIZE_T * ArrayLength +** Pointer to a variable receiving the length of the array if the +** uniform was declared as an array. If the uniform was not declared +** as an array, the array length will be 1. 'ArrayLength' can be gcvNULL, +** in which case no array length will be returned. +*/ +gceSTATUS +gcUNIFORM_GetType( + IN gcUNIFORM Uniform, + OUT gcSHADER_TYPE * Type, + OUT gctSIZE_T * ArrayLength + ); + +/******************************************************************************* +** gcUNIFORM_GetName +******************************************************************************** +** +** Get the name of a gcUNIFORM object. +** +** INPUT: +** +** gcUNIFORM Uniform +** Pointer to a gcUNIFORM object. +** +** OUTPUT: +** +** gctSIZE_T * Length +** Pointer to a variable receiving the length of the uniform name. +** 'Length' can be gcvNULL, in which case no length will be returned. +** +** gctCONST_STRING * Name +** Pointer to a variable receiving the pointer to the uniform name. +** 'Name' can be gcvNULL, in which case no name will be returned. +*/ +gceSTATUS +gcUNIFORM_GetName( + IN gcUNIFORM Uniform, + OUT gctSIZE_T * Length, + OUT gctCONST_STRING * Name + ); + +/******************************************************************************* +** gcUNIFORM_GetSampler +******************************************************************************** +** +** Get the physical sampler number for a sampler gcUNIFORM object. +** +** INPUT: +** +** gcUNIFORM Uniform +** Pointer to a gcUNIFORM object. +** +** OUTPUT: +** +** gctUINT32 * Sampler +** Pointer to a variable receiving the physical sampler. +*/ +gceSTATUS +gcUNIFORM_GetSampler( + IN gcUNIFORM Uniform, + OUT gctUINT32 * Sampler + ); + +/******************************************************************************* +** gcUNIFORM_SetValue +******************************************************************************** +** +** Set the value of a uniform in integer. +** +** INPUT: +** +** gcUNIFORM Uniform +** Pointer to a gcUNIFORM object. +** +** gctSIZE_T Count +** Number of entries to program if the uniform has been declared as an +** array. +** +** const gctINT * Value +** Pointer to a buffer holding the integer values for the uniform. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gcUNIFORM_SetValue( + IN gcUNIFORM Uniform, + IN gctSIZE_T Count, + IN const gctINT * Value + ); + +/******************************************************************************* +** gcUNIFORM_SetValueX +******************************************************************************** +** +** Set the value of a uniform in fixed point. +** +** INPUT: +** +** gcUNIFORM Uniform +** Pointer to a gcUNIFORM object. +** +** gctSIZE_T Count +** Number of entries to program if the uniform has been declared as an +** array. +** +** const gctFIXED_POINT * Value +** Pointer to a buffer holding the fixed point values for the uniform. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gcUNIFORM_SetValueX( + IN gcUNIFORM Uniform, + IN gctSIZE_T Count, + IN gctFIXED_POINT * Value + ); + +/******************************************************************************* +** gcUNIFORM_SetValueF +******************************************************************************** +** +** Set the value of a uniform in floating point. +** +** INPUT: +** +** gcUNIFORM Uniform +** Pointer to a gcUNIFORM object. +** +** gctSIZE_T Count +** Number of entries to program if the uniform has been declared as an +** array. +** +** const gctFLOAT * Value +** Pointer to a buffer holding the floating point values for the +** uniform. +** +** OUTPUT: +** +** Nothing. +*/ +gceSTATUS +gcUNIFORM_SetValueF( + IN gcUNIFORM Uniform, + IN gctSIZE_T Count, + IN const gctFLOAT * Value + ); + +/******************************************************************************* +** gcOUTPUT_GetType +******************************************************************************** +** +** Get the type and array length of a gcOUTPUT object. +** +** INPUT: +** +** gcOUTPUT Output +** Pointer to a gcOUTPUT object. +** +** OUTPUT: +** +** gcSHADER_TYPE * Type +** Pointer to a variable receiving the type of the output. 'Type' can +** be gcvNULL, in which case no type will be returned. +** +** gctSIZE_T * ArrayLength +** Pointer to a variable receiving the length of the array if the +** output was declared as an array. If the output was not declared +** as an array, the array length will be 1. 'ArrayLength' can be gcvNULL, +** in which case no array length will be returned. +*/ +gceSTATUS +gcOUTPUT_GetType( + IN gcOUTPUT Output, + OUT gcSHADER_TYPE * Type, + OUT gctSIZE_T * ArrayLength + ); + +/******************************************************************************* +** gcOUTPUT_GetIndex +******************************************************************************** +** +** Get the index of a gcOUTPUT object. +** +** INPUT: +** +** gcOUTPUT Output +** Pointer to a gcOUTPUT object. +** +** OUTPUT: +** +** gctUINT * Index +** Pointer to a variable receiving the temporary register index of the +** output. 'Index' can be gcvNULL,. in which case no index will be +** returned. +*/ +gceSTATUS +gcOUTPUT_GetIndex( + IN gcOUTPUT Output, + OUT gctUINT * Index + ); + +/******************************************************************************* +** gcOUTPUT_GetName +******************************************************************************** +** +** Get the name of a gcOUTPUT object. +** +** INPUT: +** +** gcOUTPUT Output +** Pointer to a gcOUTPUT object. +** +** OUTPUT: +** +** gctSIZE_T * Length +** Pointer to a variable receiving the length of the output name. +** 'Length' can be gcvNULL, in which case no length will be returned. +** +** gctCONST_STRING * Name +** Pointer to a variable receiving the pointer to the output name. +** 'Name' can be gcvNULL, in which case no name will be returned. +*/ +gceSTATUS +gcOUTPUT_GetName( + IN gcOUTPUT Output, + OUT gctSIZE_T * Length, + OUT gctCONST_STRING * Name + ); + +/******************************************************************************* +*********************************************************** F U N C T I O N S ** +*******************************************************************************/ + +gceSTATUS +gcFUNCTION_AddArgument( + IN gcFUNCTION Function, + IN gctUINT16 TempIndex, + IN gctUINT8 Enable, + IN gctUINT8 Qualifier + ); + +gceSTATUS +gcFUNCTION_GetArgument( + IN gcFUNCTION Function, + IN gctUINT16 Index, + OUT gctUINT16_PTR Temp, + OUT gctUINT8_PTR Enable, + OUT gctUINT8_PTR Swizzle + ); + +gceSTATUS +gcFUNCTION_GetLabel( + IN gcFUNCTION Function, + OUT gctUINT_PTR Label + ); + +/******************************************************************************* +** gcCompileShader +******************************************************************************** +** +** Compile a shader. +** +** INPUT: +** +** gcoOS Hal +** Pointer to an gcoHAL object. +** +** gctINT ShaderType +** Shader type to compile. Can be one of the following values: +** +** gcSHADER_TYPE_VERTEX +** Compile a vertex shader. +** +** gcSHADER_TYPE_FRAGMENT +** Compile a fragment shader. +** +** gctSIZE_T SourceSize +** Size of the source buffer in bytes. +** +** gctCONST_STRING Source +** Pointer to the buffer containing the shader source code. +** +** OUTPUT: +** +** gcSHADER * Binary +** Pointer to a variable receiving the pointer to a gcSHADER object +** containg the compiled shader code. +** +** gctSTRING * Log +** Pointer to a variable receiving a string pointer containging the +** compile log. +*/ +gceSTATUS +gcCompileShader( + IN gcoHAL Hal, + IN gctINT ShaderType, + IN gctSIZE_T SourceSize, + IN gctCONST_STRING Source, + OUT gcSHADER * Binary, + OUT gctSTRING * Log + ); + +/******************************************************************************* +** gcOptimizeShader +******************************************************************************** +** +** Optimize a shader. +** +** INPUT: +** +** gcSHADER Shader +** Pointer to a gcSHADER object holding information about the compiled +** shader. +** +** gctFILE LogFile +** Pointer to an open FILE object. +*/ +gceSTATUS +gcOptimizeShader( + IN gcSHADER Shader, + IN gctFILE LogFile + ); + +/******************************************************************************* +** gcLinkShaders +******************************************************************************** +** +** Link two shaders and generate a harwdare specific state buffer by compiling +** the compiler generated code through the resource allocator and code +** generator. +** +** INPUT: +** +** gcSHADER VertexShader +** Pointer to a gcSHADER object holding information about the compiled +** vertex shader. +** +** gcSHADER FragmentShader +** Pointer to a gcSHADER object holding information about the compiled +** fragment shader. +** +** gceSHADER_FLAGS Flags +** Compiler flags. Can be any of the following: +** +** gcvSHADER_DEAD_CODE - Dead code elimination. +** gcvSHADER_RESOURCE_USAGE - Resource usage optimizaion. +** gcvSHADER_OPTIMIZER - Full optimization. +** gcvSHADER_USE_GL_Z - Use OpenGL ES Z coordinate. +** gcvSHADER_USE_GL_POSITION - Use OpenGL ES gl_Position. +** gcvSHADER_USE_GL_FACE - Use OpenGL ES gl_FaceForward. +** +** OUTPUT: +** +** gctSIZE_T * StateBufferSize +** Pointer to a variable receicing the number of bytes in the buffer +** returned in 'StateBuffer'. +** +** gctPOINTER * StateBuffer +** Pointer to a variable receiving a buffer pointer that contains the +** states required to download the shaders into the hardware. +** +** gcsHINT_PTR * Hints +** Pointer to a variable receiving a gcsHINT structure pointer that +** contains information required when loading the shader states. +*/ +gceSTATUS +gcLinkShaders( + IN gcSHADER VertexShader, + IN gcSHADER FragmentShader, + IN gceSHADER_FLAGS Flags, + OUT gctSIZE_T * StateBufferSize, + OUT gctPOINTER * StateBuffer, + OUT gcsHINT_PTR * Hints + ); + +/******************************************************************************* +** gcLoadShaders +******************************************************************************** +** +** Load a pre-compiled and pre-linked shader program into the hardware. +** +** INPUT: +** +** gcoHAL Hal +** Pointer to a gcoHAL object. +** +** gctSIZE_T StateBufferSize +** The number of bytes in the 'StateBuffer'. +** +** gctPOINTER StateBuffer +** Pointer to the states that make up the shader program. +** +** gcsHINT_PTR Hints +** Pointer to a gcsHINT structure that contains information required +** when loading the shader states. +** +** gcePRIMITIVE PrimitiveType +** Primitive type to be rendered. +*/ +gceSTATUS +gcLoadShaders( + IN gcoHAL Hal, + IN gctSIZE_T StateBufferSize, + IN gctPOINTER StateBuffer, + IN gcsHINT_PTR Hints, + IN gcePRIMITIVE PrimitiveType + ); + +/******************************************************************************* +** gcSaveProgram +******************************************************************************** +** +** Save pre-compiled shaders and pre-linked programs to a binary file. +** +** INPUT: +** +** gcSHADER VertexShader +** Pointer to vertex shader object. +** +** gcSHADER FragmentShader +** Pointer to fragment shader object. +** +** gctSIZE_T ProgramBufferSize +** Number of bytes in 'ProgramBuffer'. +** +** gctPOINTER ProgramBuffer +** Pointer to buffer containing the program states. +** +** gcsHINT_PTR Hints +** Pointer to HINTS structure for program states. +** +** OUTPUT: +** +** gctPOINTER * Binary +** Pointer to a variable receiving the binary data to be saved. +** +** gctSIZE_T * BinarySize +** Pointer to a variable receiving the number of bytes inside 'Binary'. +*/ +gceSTATUS +gcSaveProgram( + IN gcSHADER VertexShader, + IN gcSHADER FragmentShader, + IN gctSIZE_T ProgramBufferSize, + IN gctPOINTER ProgramBuffer, + IN gcsHINT_PTR Hints, + OUT gctPOINTER * Binary, + OUT gctSIZE_T * BinarySize + ); + +/******************************************************************************* +** gcLoadProgram +******************************************************************************** +** +** Load pre-compiled shaders and pre-linked programs from a binary file. +** +** INPUT: +** +** gctPOINTER Binary +** Pointer to the binary data loaded. +** +** gctSIZE_T BinarySize +** Number of bytes in 'Binary'. +** +** OUTPUT: +** +** gcSHADER * VertexShader +** Pointer to a variable receiving the vertex shader object. +** +** gcSHADER * FragmentShader +** Pointer to a variable receiving the fragment shader object. +** +** gctSIZE_T * ProgramBufferSize +** Pointer to a variable receicing the number of bytes in the buffer +** returned in 'ProgramBuffer'. +** +** gctPOINTER * ProgramBuffer +** Pointer to a variable receiving a buffer pointer that contains the +** states required to download the shaders into the hardware. +** +** gcsHINT_PTR * Hints +** Pointer to a variable receiving a gcsHINT structure pointer that +** contains information required when loading the shader states. +*/ +gceSTATUS +gcLoadProgram( + IN gctPOINTER Binary, + IN gctSIZE_T BinarySize, + OUT gcSHADER * VertexShader, + OUT gcSHADER * FragmentShader, + OUT gctSIZE_T * ProgramBufferSize, + OUT gctPOINTER * ProgramBuffer, + OUT gcsHINT_PTR * Hints + ); + +#ifdef __cplusplus +} +#endif + +#endif /* __gc_hal_compiler_h_ */ + diff --git a/native/include_dove/gc_hal_driver.h b/native/include_dove/gc_hal_driver.h new file mode 100644 index 0000000..bd60d95 --- /dev/null +++ b/native/include_dove/gc_hal_driver.h @@ -0,0 +1,640 @@ +/**************************************************************************** +* +* Copyright (C) 2005 - 2010 by Vivante Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the license, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +* +*****************************************************************************/ + + + + +#ifndef __gc_hal_driver_h_ +#define __gc_hal_driver_h_ + +#include "gc_hal_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/******************************************************************************\ +******************************* I/O Control Codes ****************************** +\******************************************************************************/ + +#define gcvHAL_CLASS "galcore" +#define IOCTL_GCHAL_INTERFACE 30000 +#define IOCTL_GCHAL_KERNEL_INTERFACE 30001 +#define IOCTL_GCHAL_TERMINATE 30002 + +/******************************************************************************\ +********************************* Command Codes ******************************** +\******************************************************************************/ + +typedef enum _gceHAL_COMMAND_CODES +{ + /* Generic query. */ + gcvHAL_QUERY_VIDEO_MEMORY, + gcvHAL_QUERY_CHIP_IDENTITY, + + /* Contiguous memory. */ + gcvHAL_ALLOCATE_NON_PAGED_MEMORY, + gcvHAL_FREE_NON_PAGED_MEMORY, + gcvHAL_ALLOCATE_CONTIGUOUS_MEMORY, + gcvHAL_FREE_CONTIGUOUS_MEMORY, + + /* Video memory allocation. */ + gcvHAL_ALLOCATE_VIDEO_MEMORY, /* Enforced alignment. */ + gcvHAL_ALLOCATE_LINEAR_VIDEO_MEMORY, /* No alignment. */ + gcvHAL_FREE_VIDEO_MEMORY, + + /* Physical-to-logical mapping. */ + gcvHAL_MAP_MEMORY, + gcvHAL_UNMAP_MEMORY, + + /* Logical-to-physical mapping. */ + gcvHAL_MAP_USER_MEMORY, + gcvHAL_UNMAP_USER_MEMORY, + + /* Surface lock/unlock. */ + gcvHAL_LOCK_VIDEO_MEMORY, + gcvHAL_UNLOCK_VIDEO_MEMORY, + + /* Event queue. */ + gcvHAL_EVENT_COMMIT, + + gcvHAL_USER_SIGNAL, + gcvHAL_SIGNAL, + gcvHAL_WRITE_DATA, + + gcvHAL_COMMIT, + gcvHAL_STALL, + + gcvHAL_READ_REGISTER, + gcvHAL_WRITE_REGISTER, + + gcvHAL_GET_PROFILE_SETTING, + gcvHAL_SET_PROFILE_SETTING, + + gcvHAL_READ_ALL_PROFILE_REGISTERS, + gcvHAL_PROFILE_REGISTERS_2D, + + /* Power management. */ + gcvHAL_SET_POWER_MANAGEMENT_STATE, + gcvHAL_QUERY_POWER_MANAGEMENT_STATE, + + gcvHAL_GET_BASE_ADDRESS, + + gcvHAL_SET_IDLE, /* reserved */ + + /* Queries. */ + gcvHAL_QUERY_KERNEL_SETTINGS, + + /* Reset. */ + gcvHAL_RESET, + + /* Map physical address into handle. */ + gcvHAL_MAP_PHYSICAL, + + /* Debugger stuff. */ + gcvHAL_DEBUG, + + /* Cache stuff. */ + gcvHAL_CACHE, + + gcvHAL_GC_OFF, + gcvHAL_GC_ON +} +gceHAL_COMMAND_CODES; + +/******************************************************************************\ +****************************** Interface Structure ***************************** +\******************************************************************************/ + +#define gcdMAX_PROFILE_FILE_NAME 128 + +typedef struct _gcsHAL_INTERFACE +{ + /* Command code. */ + gceHAL_COMMAND_CODES command; + + /* Status value. */ + gceSTATUS status; + + /* Handle to this interface channel. */ + gctHANDLE handle; + + /* Pid of the client. */ + gctUINT32 pid; + + /* Union of command structures. */ + union _u + { + /* gcvHAL_GET_BASE_ADDRESS */ + struct _gcsHAL_GET_BASE_ADDRESS + { + /* Physical memory address of internal memory. */ + OUT gctUINT32 baseAddress; + } + GetBaseAddress; + + /* gcvHAL_QUERY_VIDEO_MEMORY */ + struct _gcsHAL_QUERY_VIDEO_MEMORY + { + /* Physical memory address of internal memory. */ + OUT gctPHYS_ADDR internalPhysical; + + /* Size in bytes of internal memory.*/ + OUT gctSIZE_T internalSize; + + /* Physical memory address of external memory. */ + OUT gctPHYS_ADDR externalPhysical; + + /* Size in bytes of external memory.*/ + OUT gctSIZE_T externalSize; + + /* Physical memory address of contiguous memory. */ + OUT gctPHYS_ADDR contiguousPhysical; + + /* Size in bytes of contiguous memory.*/ + OUT gctSIZE_T contiguousSize; + } + QueryVideoMemory; + + /* gcvHAL_QUERY_CHIP_IDENTITY */ + struct _gcsHAL_QUERY_CHIP_IDENTITY + { + + /* Chip model. */ + OUT gceCHIPMODEL chipModel; + + /* Revision value.*/ + OUT gctUINT32 chipRevision; + + /* Supported feature fields. */ + OUT gctUINT32 chipFeatures; + + /* Supported minor feature fields. */ + OUT gctUINT32 chipMinorFeatures; + + /* Supported minor feature 1 fields. */ + OUT gctUINT32 chipMinorFeatures1; + + /* Number of streams supported. */ + OUT gctUINT32 streamCount; + + /* Total number of temporary registers per thread. */ + OUT gctUINT32 registerMax; + + /* Maximum number of threads. */ + OUT gctUINT32 threadCount; + + /* Number of shader cores. */ + OUT gctUINT32 shaderCoreCount; + + /* Size of the vertex cache. */ + OUT gctUINT32 vertexCacheSize; + + /* Number of entries in the vertex output buffer. */ + OUT gctUINT32 vertexOutputBufferSize; + } + QueryChipIdentity; + + /* gcvHAL_MAP_MEMORY */ + struct _gcsHAL_MAP_MEMORY + { + /* Physical memory address to map. */ + IN gctPHYS_ADDR physical; + + /* Number of bytes in physical memory to map. */ + IN gctSIZE_T bytes; + + /* Address of mapped memory. */ + OUT gctPOINTER logical; + } + MapMemory; + + /* gcvHAL_UNMAP_MEMORY */ + struct _gcsHAL_UNMAP_MEMORY + { + /* Physical memory address to unmap. */ + IN gctPHYS_ADDR physical; + + /* Number of bytes in physical memory to unmap. */ + IN gctSIZE_T bytes; + + /* Address of mapped memory to unmap. */ + IN gctPOINTER logical; + } + UnmapMemory; + + /* gcvHAL_ALLOCATE_LINEAR_VIDEO_MEMORY */ + struct _gcsHAL_ALLOCATE_LINEAR_VIDEO_MEMORY + { + /* Number of bytes to allocate. */ + IN OUT gctUINT bytes; + + /* Buffer alignment. */ + IN gctUINT alignment; + + /* Type of allocation. */ + IN gceSURF_TYPE type; + + /* Memory pool to allocate from. */ + IN OUT gcePOOL pool; + + /* Allocated video memory. */ + OUT gcuVIDMEM_NODE_PTR node; + } + AllocateLinearVideoMemory; + + /* gcvHAL_ALLOCATE_VIDEO_MEMORY */ + struct _gcsHAL_ALLOCATE_VIDEO_MEMORY + { + /* Width of rectangle to allocate. */ + IN OUT gctUINT width; + + /* Height of rectangle to allocate. */ + IN OUT gctUINT height; + + /* Depth of rectangle to allocate. */ + IN gctUINT depth; + + /* Format rectangle to allocate in gceSURF_FORMAT. */ + IN gceSURF_FORMAT format; + + /* Type of allocation. */ + IN gceSURF_TYPE type; + + /* Memory pool to allocate from. */ + IN OUT gcePOOL pool; + + /* Allocated video memory. */ + OUT gcuVIDMEM_NODE_PTR node; + } + AllocateVideoMemory; + + /* gcvHAL_FREE_VIDEO_MEMORY */ + struct _gcsHAL_FREE_VIDEO_MEMORY + { + /* Allocated video memory. */ + IN gcuVIDMEM_NODE_PTR node; + +#ifdef __QNXNTO__ +/* TODO: This is part of the unlock - why is it here? */ + /* Mapped logical address to unmap in user space. */ + OUT gctPOINTER memory; + + /* Number of bytes to allocated. */ + OUT gctSIZE_T bytes; +#endif + } + FreeVideoMemory; + + /* gcvHAL_LOCK_VIDEO_MEMORY */ + struct _gcsHAL_LOCK_VIDEO_MEMORY + { + /* Allocated video memory. */ + IN gcuVIDMEM_NODE_PTR node; + + /* Hardware specific address. */ + OUT gctUINT32 address; + + /* Mapped logical address. */ + OUT gctPOINTER memory; + } + LockVideoMemory; + + /* gcvHAL_UNLOCK_VIDEO_MEMORY */ + struct _gcsHAL_UNLOCK_VIDEO_MEMORY + { + /* Allocated video memory. */ + IN gcuVIDMEM_NODE_PTR node; + + /* Type of surface. */ + IN gceSURF_TYPE type; + + /* Flag to unlock surface asynchroneously. */ + IN OUT gctBOOL asynchroneous; + } + UnlockVideoMemory; + + /* gcvHAL_ALLOCATE_NON_PAGED_MEMORY */ + struct _gcsHAL_ALLOCATE_NON_PAGED_MEMORY + { + /* Number of bytes to allocate. */ + IN OUT gctSIZE_T bytes; + + /* Physical address of allocation. */ + OUT gctPHYS_ADDR physical; + + /* Logical address of allocation. */ + OUT gctPOINTER logical; + } + AllocateNonPagedMemory; + + /* gcvHAL_FREE_NON_PAGED_MEMORY */ + struct _gcsHAL_FREE_NON_PAGED_MEMORY + { + /* Number of bytes allocated. */ + IN gctSIZE_T bytes; + + /* Physical address of allocation. */ + IN gctPHYS_ADDR physical; + + /* Logical address of allocation. */ + IN gctPOINTER logical; + } + FreeNonPagedMemory; + + /* gcvHAL_EVENT_COMMIT. */ + struct _gcsHAL_EVENT_COMMIT + { + /* Event queue. */ + IN struct _gcsQUEUE * queue; + } + Event; + + /* gcvHAL_COMMIT */ + struct _gcsHAL_COMMIT + { + /* Command buffer. */ + IN gcoCMDBUF commandBuffer; + + /* Context buffer. */ + IN gcoCONTEXT contextBuffer; + + /* Process handle. */ + IN gctHANDLE process; + } + Commit; + + /* gcvHAL_MAP_USER_MEMORY */ + struct _gcsHAL_MAP_USER_MEMORY + { + /* Base address of user memory to map. */ + IN gctPOINTER memory; + + /* Size of user memory in bytes to map. */ + IN gctSIZE_T size; + + /* Info record required by gcvHAL_UNMAP_USER_MEMORY. */ + OUT gctPOINTER info; + + /* Physical address of mapped memory. */ + OUT gctUINT32 address; + } + MapUserMemory; + + /* gcvHAL_UNMAP_USER_MEMORY */ + struct _gcsHAL_UNMAP_USER_MEMORY + { + /* Base address of user memory to unmap. */ + IN gctPOINTER memory; + + /* Size of user memory in bytes to unmap. */ + IN gctSIZE_T size; + + /* Info record returned by gcvHAL_MAP_USER_MEMORY. */ + IN gctPOINTER info; + + /* Physical address of mapped memory as returned by + gcvHAL_MAP_USER_MEMORY. */ + IN gctUINT32 address; + } + UnmapUserMemory; + +#if !USE_NEW_LINUX_SIGNAL + /* gcsHAL_USER_SIGNAL */ + struct _gcsHAL_USER_SIGNAL + { + /* Command. */ + gceUSER_SIGNAL_COMMAND_CODES command; + + /* Signal ID. */ + IN OUT gctINT id; + + /* Reset mode. */ + IN gctBOOL manualReset; + + /* Signal ID. */ + IN gceSIGNAL_TYPE signalType; + + /* Wait timedout. */ + IN gctUINT32 wait; + + /* State. */ + IN gctBOOL state; + } + UserSignal; +#endif + + /* gcvHAL_SIGNAL. */ + struct _gcsHAL_SIGNAL + { + /* Signal handle to signal. */ + IN gctSIGNAL signal; + + /* Reserved. */ + IN gctSIGNAL auxSignal; + + /* Process owning the signal. */ + IN gctHANDLE process; + +#if defined(__QNXNTO__) + /* Client pulse side-channel connection ID. Set by client in gcoOS_CreateSignal. */ + IN gctINT32 coid; + + /* Set by server. */ + IN gctINT32 rcvid; +#endif + /* Event generated from where of pipeline */ + IN gceKERNEL_WHERE fromWhere; + } + Signal; + + /* gcvHAL_WRITE_DATA. */ + struct _gcsHAL_WRITE_DATA + { + /* Address to write data to. */ + IN gctUINT32 address; + + IN gctPOINTER kernelAddress; + /* Data to write. */ + IN gctUINT32 data; + } + WriteData; + + /* gcvHAL_ALLOCATE_CONTIGUOUS_MEMORY */ + struct _gcsHAL_ALLOCATE_CONTIGUOUS_MEMORY + { + /* Number of bytes to allocate. */ + IN OUT gctSIZE_T bytes; + + /* Physical address of allocation. */ + OUT gctPHYS_ADDR physical; + + /* Logical address of allocation. */ + OUT gctPOINTER logical; + + } + AllocateContiguousMemory; + + /* gcvHAL_FREE_CONTIGUOUS_MEMORY */ + struct _gcsHAL_FREE_CONTIGUOUS_MEMORY + { + /* Number of bytes allocated. */ + IN gctSIZE_T bytes; + + /* Physical address of allocation. */ + IN gctPHYS_ADDR physical; + + /* Logical address of allocation. */ + IN gctPOINTER logical; + } + FreeContiguousMemory; + + /* gcvHAL_READ_REGISTER */ + struct _gcsHAL_READ_REGISTER + { + /* Logical address of memory to write data to. */ + IN gctUINT32 address; + + /* Data read. */ + OUT gctUINT32 data; + } + ReadRegisterData; + + /* gcvHAL_WRITE_REGISTER */ + struct _gcsHAL_WRITE_REGISTER + { + /* Logical address of memory to write data to. */ + IN gctUINT32 address; + + /* Data read. */ + IN gctUINT32 data; + } + WriteRegisterData; + + /* gcvHAL_GET_PROFILE_SETTING */ + struct _gcsHAL_GET_PROFILE_SETTING + { + /* Enable profiling */ + OUT gctBOOL enable; + + /* The profile file name */ + OUT gctCHAR fileName[gcdMAX_PROFILE_FILE_NAME]; + } + GetProfileSetting; + + /* gcvHAL_SET_PROFILE_SETTING */ + struct _gcsHAL_SET_PROFILE_SETTING + { + /* Enable profiling */ + IN gctBOOL enable; + + /* The profile file name */ + IN gctCHAR fileName[gcdMAX_PROFILE_FILE_NAME]; + } + SetProfileSetting; + + /* gcvHAL_READ_ALL_PROFILE_REGISTERS */ + struct _gcsHAL_READ_ALL_PROFILE_REGISTERS + { + /* Data read. */ + OUT gcsPROFILER_COUNTERS counters; + } + RegisterProfileData; + + /* gcvHAL_PROFILE_REGISTERS_2D */ + struct _gcsHAL_PROFILE_REGISTERS_2D + { + /* Data read. */ + OUT gcs2D_PROFILE_PTR hwProfile2D; + } + RegisterProfileData2D; + + /* Power management. */ + /* gcvHAL_SET_POWER_MANAGEMENT_STATE */ + struct _gcsHAL_SET_POWER_MANAGEMENT + { + /* Data read. */ + IN gceCHIPPOWERSTATE state; + } + SetPowerManagement; + + /* gcvHAL_QUERY_POWER_MANAGEMENT_STATE */ + struct _gcsHAL_QUERY_POWER_MANAGEMENT + { + /* Data read. */ + OUT gceCHIPPOWERSTATE state; + + /* Idle query. */ + OUT gctBOOL isIdle; + } + QueryPowerManagement; + + /* gcvHAL_QUERY_KERNEL_SETTINGS */ + struct _gcsHAL_QUERY_KERNEL_SETTINGS + { + /* Settings.*/ + OUT gcsKERNEL_SETTINGS settings; + } + QueryKernelSettings; + + /* gcvHAL_MAP_PHYSICAL */ + struct _gcsHAL_MAP_PHYSICAL + { + /* gcvTRUE to map, gcvFALSE to unmap. */ + IN gctBOOL map; + + /* Physical address. */ + IN OUT gctPHYS_ADDR physical; + } + MapPhysical; + + /* gcvHAL_DEBUG */ + struct _gcsHAL_DEBUG + { + /* If gcvTRUE, set the debug information. */ + IN gctBOOL set; + IN gctUINT32 level; + IN gctUINT32 zones; + IN gctBOOL enable; + + /* Message to print if not empty. */ + IN gctCHAR message[80]; + } + Debug; + + struct _gcsHAL_CACHE + { + IN gctBOOL invalidate; + IN gctHANDLE process; + IN gctPOINTER logical; + IN gctSIZE_T bytes; + } + Cache; + } + u; +} +gcsHAL_INTERFACE; + +#ifdef __cplusplus +} +#endif + +#endif /* __gc_hal_driver_h_ */ + diff --git a/native/include_dove/gc_hal_dump.h b/native/include_dove/gc_hal_dump.h new file mode 100644 index 0000000..2264b60 --- /dev/null +++ b/native/include_dove/gc_hal_dump.h @@ -0,0 +1,90 @@ +/**************************************************************************** +* +* Copyright (C) 2005 - 2010 by Vivante Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the license, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +* +*****************************************************************************/ + + + + +#ifndef __gc_hal_dump_h_ +#define __gc_hal_dump_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** FILE LAYOUT: +** +** gcsDUMP_FILE structure +** +** gcsDUMP_DATA frame +** gcsDUMP_DATA or gcDUMP_DATA_SIZE records rendingring the frame +** gctUINT8 data[length] +*/ + +#define gcvDUMP_FILE_SIGNATURE gcmCC('g','c','D','B') + +typedef struct _gcsDUMP_FILE +{ + gctUINT32 signature; /* File signature */ + gctSIZE_T length; /* Length of file */ + gctUINT32 frames; /* Number of frames in file */ +} +gcsDUMP_FILE; + +typedef enum _gceDUMP_TAG +{ + gcvTAG_SURFACE = gcmCC('s','u','r','f'), + gcvTAG_FRAME = gcmCC('f','r','m',' '), + gcvTAG_COMMAND = gcmCC('c','m','d',' '), + gcvTAG_INDEX = gcmCC('i','n','d','x'), + gcvTAG_STREAM = gcmCC('s','t','r','m'), + gcvTAG_TEXTURE = gcmCC('t','e','x','t'), + gcvTAG_RENDER_TARGET = gcmCC('r','n','d','r'), + gcvTAG_DEPTH = gcmCC('z','b','u','f'), + gcvTAG_RESOLVE = gcmCC('r','s','l','v'), + gcvTAG_DELETE = gcmCC('d','e','l',' '), +} +gceDUMP_TAG; + +typedef struct _gcsDUMP_SURFACE +{ + gceDUMP_TAG type; /* Type of record. */ + gctUINT32 address; /* Address of the surface. */ + gctINT16 width; /* Width of surface. */ + gctINT16 height; /* Height of surface. */ + gceSURF_FORMAT format; /* Surface pixel format. */ + gctSIZE_T length; /* Number of bytes inside the surface. */ +} +gcsDUMP_SURFACE; + +typedef struct _gcsDUMP_DATA +{ + gceDUMP_TAG type; /* Type of record. */ + gctSIZE_T length; /* Number of bytes of data. */ + gctUINT32 address; /* Address for the data. */ +} +gcsDUMP_DATA; + +#ifdef __cplusplus +} +#endif + +#endif /* __gc_hal_dump_h_ */ + diff --git a/native/include_dove/gc_hal_engine.h b/native/include_dove/gc_hal_engine.h new file mode 100644 index 0000000..3fc88f7 --- /dev/null +++ b/native/include_dove/gc_hal_engine.h @@ -0,0 +1,1673 @@ +/**************************************************************************** +* +* Copyright (C) 2005 - 2010 by Vivante Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the license, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +* +*****************************************************************************/ + + + + +#ifndef __gc_hal_engine_h_ +#define __gc_hal_engine_h_ + +#include "gc_hal_types.h" +#include "gc_hal_enum.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/******************************************************************************\ +****************************** Object Declarations ***************************** +\******************************************************************************/ + +typedef struct _gcoSTREAM * gcoSTREAM; +typedef struct _gcoVERTEX * gcoVERTEX; +typedef struct _gcoTEXTURE * gcoTEXTURE; +typedef struct _gcoINDEX * gcoINDEX; +typedef struct _gcsVERTEX_ATTRIBUTES * gcsVERTEX_ATTRIBUTES_PTR; + +/******************************************************************************\ +********************************* Enumerations ********************************* +\******************************************************************************/ + +/* Shading format. */ +typedef enum _gceSHADING +{ + gcvSHADING_SMOOTH, + gcvSHADING_FLAT_D3D, + gcvSHADING_FLAT_OPENGL, +} +gceSHADING; + +/* Culling modes. */ +typedef enum _gceCULL +{ + gcvCULL_NONE, + gcvCULL_CCW, + gcvCULL_CW, +} +gceCULL; + +/* Fill modes. */ +typedef enum _gceFILL +{ + gcvFILL_POINT, + gcvFILL_WIRE_FRAME, + gcvFILL_SOLID, +} +gceFILL; + +/* Compare modes. */ +typedef enum _gceCOMPARE +{ + gcvCOMPARE_NEVER, + gcvCOMPARE_NOT_EQUAL, + gcvCOMPARE_LESS, + gcvCOMPARE_LESS_OR_EQUAL, + gcvCOMPARE_EQUAL, + gcvCOMPARE_GREATER, + gcvCOMPARE_GREATER_OR_EQUAL, + gcvCOMPARE_ALWAYS, +} +gceCOMPARE; + +/* Stencil modes. */ +typedef enum _gceSTENCIL_MODE +{ + gcvSTENCIL_NONE, + gcvSTENCIL_SINGLE_SIDED, + gcvSTENCIL_DOUBLE_SIDED, +} +gceSTENCIL_MODE; + +/* Stencil operations. */ +typedef enum _gceSTENCIL_OPERATION +{ + gcvSTENCIL_KEEP, + gcvSTENCIL_REPLACE, + gcvSTENCIL_ZERO, + gcvSTENCIL_INVERT, + gcvSTENCIL_INCREMENT, + gcvSTENCIL_DECREMENT, + gcvSTENCIL_INCREMENT_SATURATE, + gcvSTENCIL_DECREMENT_SATURATE, +} +gceSTENCIL_OPERATION; + +/* Stencil selection. */ +typedef enum _gceSTENCIL_WHERE +{ + gcvSTENCIL_FRONT, + gcvSTENCIL_BACK, +} +gceSTENCIL_WHERE; + +/* Texture addressing selection. */ +typedef enum _gceTEXTURE_WHICH +{ + gcvTEXTURE_S, + gcvTEXTURE_T, + gcvTEXTURE_R, +} +gceTEXTURE_WHICH; + +/* Texture addressing modes. */ +typedef enum _gceTEXTURE_ADDRESSING +{ + gcvTEXTURE_WRAP, + gcvTEXTURE_CLAMP, + gcvTEXTURE_BORDER, + gcvTEXTURE_MIRROR, + gcvTEXTURE_MIRROR_ONCE, +} +gceTEXTURE_ADDRESSING; + +/* Texture filters. */ +typedef enum _gceTEXTURE_FILTER +{ + gcvTEXTURE_NONE, + gcvTEXTURE_POINT, + gcvTEXTURE_LINEAR, + gcvTEXTURE_ANISOTROPIC, +} +gceTEXTURE_FILTER; + +/* Primitive types. */ +typedef enum _gcePRIMITIVE +{ + gcvPRIMITIVE_POINT_LIST, + gcvPRIMITIVE_LINE_LIST, + gcvPRIMITIVE_LINE_STRIP, + gcvPRIMITIVE_LINE_LOOP, + gcvPRIMITIVE_TRIANGLE_LIST, + gcvPRIMITIVE_TRIANGLE_STRIP, + gcvPRIMITIVE_TRIANGLE_FAN, +} +gcePRIMITIVE; + +/* Index types. */ +typedef enum _gceINDEX_TYPE +{ + gcvINDEX_8, + gcvINDEX_16, + gcvINDEX_32, +} +gceINDEX_TYPE; + +/******************************************************************************\ +********************************* gcoHAL Object ********************************* +\******************************************************************************/ + +/* Query the target capabilities. */ +gceSTATUS +gcoHAL_QueryTargetCaps( + IN gcoHAL Hal, + OUT gctUINT * MaxWidth, + OUT gctUINT * MaxHeight, + OUT gctUINT * MultiTargetCount, + OUT gctUINT * MaxSamples + ); + +gceSTATUS +gcoHAL_SetDepthOnly( + IN gcoHAL Hal, + IN gctBOOL Enable + ); + +gceSTATUS +gcoHAL_QueryShaderCaps( + IN gcoHAL Hal, + OUT gctUINT * VertexUniforms, + OUT gctUINT * FragmentUniforms, + OUT gctUINT * Varyings + ); + +gceSTATUS +gcoHAL_QueryTextureCaps( + IN gcoHAL Hal, + OUT gctUINT * MaxWidth, + OUT gctUINT * MaxHeight, + OUT gctUINT * MaxDepth, + OUT gctBOOL * Cubic, + OUT gctBOOL * NonPowerOfTwo, + OUT gctUINT * VertexSamplers, + OUT gctUINT * PixelSamplers + ); + +gceSTATUS +gcoHAL_QueryStreamCaps( + IN gcoHAL Hal, + OUT gctUINT32 * MaxAttributes, + OUT gctUINT32 * MaxStreamSize, + OUT gctUINT32 * NumberOfStreams, + OUT gctUINT32 * Alignment + ); + +/******************************************************************************\ +********************************* gcoSURF Object ******************************** +\******************************************************************************/ + +/*----------------------------------------------------------------------------*/ +/*--------------------------------- gcoSURF 3D --------------------------------*/ + +/* Copy surface. */ +gceSTATUS +gcoSURF_Copy( + IN gcoSURF Surface, + IN gcoSURF Source + ); + +/* Clear surface. */ +gceSTATUS +gcoSURF_Clear( + IN gcoSURF Surface, + IN gctUINT Flags + ); + +/* Set number of samples for a gcoSURF object. */ +gceSTATUS +gcoSURF_SetSamples( + IN gcoSURF Surface, + IN gctUINT Samples + ); + +/* Get the number of samples per pixel. */ +gceSTATUS +gcoSURF_GetSamples( + IN gcoSURF Surface, + OUT gctUINT_PTR Samples + ); + +/* Clear rectangular surface. */ +gceSTATUS +gcoSURF_ClearRect( + IN gcoSURF Surface, + IN gctINT Left, + IN gctINT Top, + IN gctINT Right, + IN gctINT Bottom, + IN gctUINT Flags + ); + +/* TO BE REMOVED */ +#if 1 + gceSTATUS + depr_gcoSURF_Resolve( + IN gcoSURF SrcSurface, + IN gcoSURF DestSurface, + IN gctUINT32 DestAddress, + IN gctPOINTER DestBits, + IN gctINT DestStride, + IN gceSURF_TYPE DestType, + IN gceSURF_FORMAT DestFormat, + IN gctUINT DestWidth, + IN gctUINT DestHeight + ); + + gceSTATUS + depr_gcoSURF_ResolveRect( + IN gcoSURF SrcSurface, + IN gcoSURF DestSurface, + IN gctUINT32 DestAddress, + IN gctPOINTER DestBits, + IN gctINT DestStride, + IN gceSURF_TYPE DestType, + IN gceSURF_FORMAT DestFormat, + IN gctUINT DestWidth, + IN gctUINT DestHeight, + IN gcsPOINT_PTR SrcOrigin, + IN gcsPOINT_PTR DestOrigin, + IN gcsPOINT_PTR RectSize + ); +#endif + +/* Resample surface. */ +gceSTATUS +gcoSURF_Resample( + IN gcoSURF SrcSurface, + IN gcoSURF DestSurface + ); + +/* Resolve surface. */ +gceSTATUS +gcoSURF_Resolve( + IN gcoSURF SrcSurface, + IN gcoSURF DestSurface + ); + +/* Resolve rectangular area of a surface. */ +gceSTATUS +gcoSURF_ResolveRect( + IN gcoSURF SrcSurface, + IN gcoSURF DestSurface, + IN gcsPOINT_PTR SrcOrigin, + IN gcsPOINT_PTR DestOrigin, + IN gcsPOINT_PTR RectSize + ); + +/* Set surface resolvability. */ +gceSTATUS +gcoSURF_SetResolvability( + IN gcoSURF Surface, + IN gctBOOL Resolvable + ); + +/******************************************************************************\ +******************************** gcoINDEX Object ******************************* +\******************************************************************************/ + +/* Construct a new gcoINDEX object. */ +gceSTATUS +gcoINDEX_Construct( + IN gcoHAL Hal, + OUT gcoINDEX * Index + ); + +/* Destroy a gcoINDEX object. */ +gceSTATUS +gcoINDEX_Destroy( + IN gcoINDEX Index + ); + +/* Lock index in memory. */ +gceSTATUS +gcoINDEX_Lock( + IN gcoINDEX Index, + OUT gctUINT32 * Address, + OUT gctPOINTER * Memory + ); + +/* Unlock index that was previously locked with gcoINDEX_Lock. */ +gceSTATUS +gcoINDEX_Unlock( + IN gcoINDEX Index + ); + +/* Upload index data into the memory. */ +gceSTATUS +gcoINDEX_Load( + IN gcoINDEX Index, + IN gceINDEX_TYPE IndexType, + IN gctUINT32 IndexCount, + IN gctPOINTER IndexBuffer + ); + +/* Bind an index object to the hardware. */ +gceSTATUS +gcoINDEX_Bind( + IN gcoINDEX Index, + IN gceINDEX_TYPE Type + ); + +/* Bind an index object to the hardware. */ +gceSTATUS +gcoINDEX_BindOffset( + IN gcoINDEX Index, + IN gceINDEX_TYPE Type, + IN gctUINT32 Offset + ); + +/* Free existing index buffer. */ +gceSTATUS +gcoINDEX_Free( + IN gcoINDEX Index + ); + +/* Upload data into an index buffer. */ +gceSTATUS +gcoINDEX_Upload( + IN gcoINDEX Index, + IN gctCONST_POINTER Buffer, + IN gctSIZE_T Bytes + ); + +/* Upload data into an index buffer starting at an offset. */ +gceSTATUS +gcoINDEX_UploadOffset( + IN gcoINDEX Index, + IN gctUINT32 Offset, + IN gctCONST_POINTER Buffer, + IN gctSIZE_T Bytes + ); + +/* Query the index capabilities. */ +gceSTATUS +gcoINDEX_QueryCaps( + OUT gctBOOL * Index8, + OUT gctBOOL * Index16, + OUT gctBOOL * Index32, + OUT gctUINT * MaxIndex + ); + +gceSTATUS +gcoIndex_CopyFakeIndex( + IN gcoINDEX index, + IN gctUINT8_PTR logic, + IN gctUINT32 physical, + IN gctUINT32 offset, + IN gctUINT32 size); + +/* Determine the index range in the current index buffer. */ +gceSTATUS +gcoINDEX_GetIndexRange( + IN gcoINDEX Index, + IN gceINDEX_TYPE Type, + IN gctUINT32 Offset, + IN gctUINT32 Count, + OUT gctUINT32 * MinimumIndex, + OUT gctUINT32 * MaximumIndex + ); +/* Convert Index32 to Index16*/ +gceSTATUS +gcoINDEX_CovertFrom32To16( + IN gcoINDEX Index, + OUT gcoINDEX* Index16 + ); +/* Convert Index32 to Index16*/ +gceSTATUS +gcoINDEX_CovertFrom32To16( + IN gcoINDEX Index, + OUT gcoINDEX* Index16 + ); + +/* Dynamic buffer management. */ +gceSTATUS +gcoINDEX_SetDynamic( + IN gcoINDEX Index, + IN gctSIZE_T Bytes, + IN gctUINT Buffers + ); + +gceSTATUS +gcoINDEX_UploadDynamic( + IN gcoINDEX Index, + IN gctCONST_POINTER Data, + IN gctSIZE_T Bytes + ); + +/******************************************************************************\ +********************************** gco3D Object ********************************* +\******************************************************************************/ + +/* Clear flags. */ +typedef enum _gceCLEAR +{ + gcvCLEAR_COLOR = 0x1, + gcvCLEAR_DEPTH = 0x2, + gcvCLEAR_STENCIL = 0x4, + gcvCLEAR_HZ = 0x8, + gcvCLEAR_HAS_VAA = 0x10, +} +gceCLEAR; + +/* Blending targets. */ +typedef enum _gceBLEND_UNIT +{ + gcvBLEND_SOURCE, + gcvBLEND_TARGET, +} +gceBLEND_UNIT; + +/* Construct a new gco3D object. */ +gceSTATUS +gco3D_Construct( + IN gcoHAL Hal, + OUT gco3D * Engine + ); + +/* Destroy an gco3D object. */ +gceSTATUS +gco3D_Destroy( + IN gco3D Engine + ); + +/* Set 3D API type. */ +gceSTATUS +gco3D_SetAPI( + IN gco3D Engine, + IN gceAPI ApiType + ); + +/* Set render target. */ +gceSTATUS +gco3D_SetTarget( + IN gco3D Engine, + IN gcoSURF Surface + ); + +/* Unset render target. */ +gceSTATUS +gco3D_UnsetTarget( + IN gco3D Engine, + IN gcoSURF Surface + ); + +/* Set depth buffer. */ +gceSTATUS +gco3D_SetDepth( + IN gco3D Engine, + IN gcoSURF Surface + ); + +/* Unset depth buffer. */ +gceSTATUS +gco3D_UnsetDepth( + IN gco3D Engine, + IN gcoSURF Surface + ); + +/* Set viewport. */ +gceSTATUS +gco3D_SetViewport( + IN gco3D Engine, + IN gctINT32 Left, + IN gctINT32 Top, + IN gctINT32 Right, + IN gctINT32 Bottom + ); + +/* Set scissors. */ +gceSTATUS +gco3D_SetScissors( + IN gco3D Engine, + IN gctINT32 Left, + IN gctINT32 Top, + IN gctINT32 Right, + IN gctINT32 Bottom + ); + +/* Set clear color. */ +gceSTATUS +gco3D_SetClearColor( + IN gco3D Engine, + IN gctUINT8 Red, + IN gctUINT8 Green, + IN gctUINT8 Blue, + IN gctUINT8 Alpha + ); + +/* Set fixed point clear color. */ +gceSTATUS +gco3D_SetClearColorX( + IN gco3D Engine, + IN gctFIXED_POINT Red, + IN gctFIXED_POINT Green, + IN gctFIXED_POINT Blue, + IN gctFIXED_POINT Alpha + ); + +/* Set floating point clear color. */ +gceSTATUS +gco3D_SetClearColorF( + IN gco3D Engine, + IN gctFLOAT Red, + IN gctFLOAT Green, + IN gctFLOAT Blue, + IN gctFLOAT Alpha + ); + +/* Set fixed point clear depth. */ +gceSTATUS +gco3D_SetClearDepthX( + IN gco3D Engine, + IN gctFIXED_POINT Depth + ); + +/* Set floating point clear depth. */ +gceSTATUS +gco3D_SetClearDepthF( + IN gco3D Engine, + IN gctFLOAT Depth + ); + +/* Set clear stencil. */ +gceSTATUS +gco3D_SetClearStencil( + IN gco3D Engine, + IN gctUINT32 Stencil + ); + +/* Clear a Rect sub-surface. */ +gceSTATUS +gco3D_ClearRect( + IN gco3D Engine, + IN gctUINT32 Address, + IN gctPOINTER Memory, + IN gctUINT32 Stride, + IN gceSURF_FORMAT Format, + IN gctINT32 Left, + IN gctINT32 Top, + IN gctINT32 Right, + IN gctINT32 Bottom, + IN gctUINT32 Width, + IN gctUINT32 Height, + IN gctUINT32 Flags + ); + +/* Clear surface. */ +gceSTATUS +gco3D_Clear( + IN gco3D Engine, + IN gctUINT32 Address, + IN gctUINT32 Stride, + IN gceSURF_FORMAT Format, + IN gctUINT32 Width, + IN gctUINT32 Height, + IN gctUINT32 Flags + ); + + +/* Clear tile status. */ +gceSTATUS +gco3D_ClearTileStatus( + IN gco3D Engine, + IN gcsSURF_INFO_PTR Surface, + IN gctUINT32 TileStatusAddress, + IN gctUINT32 Flags + ); + +/* Set shading mode. */ +gceSTATUS +gco3D_SetShading( + IN gco3D Engine, + IN gceSHADING Shading + ); + +/* Set blending mode. */ +gceSTATUS +gco3D_EnableBlending( + IN gco3D Engine, + IN gctBOOL Enable + ); + +/* Set blending function. */ +gceSTATUS +gco3D_SetBlendFunction( + IN gco3D Engine, + IN gceBLEND_UNIT Unit, + IN gceBLEND_FUNCTION FunctionRGB, + IN gceBLEND_FUNCTION FunctionAlpha + ); + +/* Set blending mode. */ +gceSTATUS +gco3D_SetBlendMode( + IN gco3D Engine, + IN gceBLEND_MODE ModeRGB, + IN gceBLEND_MODE ModeAlpha + ); + +/* Set blending color. */ +gceSTATUS +gco3D_SetBlendColor( + IN gco3D Engine, + IN gctUINT Red, + IN gctUINT Green, + IN gctUINT Blue, + IN gctUINT Alpha + ); + +/* Set fixed point blending color. */ +gceSTATUS +gco3D_SetBlendColorX( + IN gco3D Engine, + IN gctFIXED_POINT Red, + IN gctFIXED_POINT Green, + IN gctFIXED_POINT Blue, + IN gctFIXED_POINT Alpha + ); + +/* Set floating point blending color. */ +gceSTATUS +gco3D_SetBlendColorF( + IN gco3D Engine, + IN gctFLOAT Red, + IN gctFLOAT Green, + IN gctFLOAT Blue, + IN gctFLOAT Alpha + ); + +/* Set culling mode. */ +gceSTATUS +gco3D_SetCulling( + IN gco3D Engine, + IN gceCULL Mode + ); + +/* Enable point size */ +gceSTATUS +gco3D_SetPointSizeEnable( + IN gco3D Engine, + IN gctBOOL Enable + ); + +/* Set point sprite */ +gceSTATUS +gco3D_SetPointSprite( + IN gco3D Engine, + IN gctBOOL Enable + ); + +/* Set fill mode. */ +gceSTATUS +gco3D_SetFill( + IN gco3D Engine, + IN gceFILL Mode + ); + +/* Set depth compare mode. */ +gceSTATUS +gco3D_SetDepthCompare( + IN gco3D Engine, + IN gceCOMPARE Compare + ); + +/* Enable depth writing. */ +gceSTATUS +gco3D_EnableDepthWrite( + IN gco3D Engine, + IN gctBOOL Enable + ); + +/* Set depth mode. */ +gceSTATUS +gco3D_SetDepthMode( + IN gco3D Engine, + IN gceDEPTH_MODE Mode + ); + +/* Set depth range. */ +gceSTATUS +gco3D_SetDepthRangeX( + IN gco3D Engine, + IN gceDEPTH_MODE Mode, + IN gctFIXED_POINT Near, + IN gctFIXED_POINT Far + ); + +/* Set depth range. */ +gceSTATUS +gco3D_SetDepthRangeF( + IN gco3D Engine, + IN gceDEPTH_MODE Mode, + IN gctFLOAT Near, + IN gctFLOAT Far + ); + +/* Set last pixel enable */ +gceSTATUS +gco3D_SetLastPixelEnable( + IN gco3D Engine, + IN gctBOOL Enable + ); + +/* Set depth Bias and Scale */ +gceSTATUS +gco3D_SetDepthScaleBiasX( + IN gco3D Engine, + IN gctFIXED_POINT DepthScale, + IN gctFIXED_POINT DepthBias + ); + +gceSTATUS +gco3D_SetDepthScaleBiasF( + IN gco3D Engine, + IN gctFLOAT DepthScale, + IN gctFLOAT DepthBias + ); + +/* Enable or disable dithering. */ +gceSTATUS +gco3D_EnableDither( + IN gco3D Engine, + IN gctBOOL Enable + ); + +/* Set color write enable bits. */ +gceSTATUS +gco3D_SetColorWrite( + IN gco3D Engine, + IN gctUINT8 Enable + ); + +/* Enable or disable early depth. */ +gceSTATUS +gco3D_SetEarlyDepth( + IN gco3D Engine, + IN gctBOOL Enable + ); + +/* Enable or disable depth-only mode. */ +gceSTATUS +gco3D_SetDepthOnly( + IN gco3D Engine, + IN gctBOOL Enable + ); + +/* Set stencil mode. */ +gceSTATUS +gco3D_SetStencilMode( + IN gco3D Engine, + IN gceSTENCIL_MODE Mode + ); + +/* Set stencil mask. */ +gceSTATUS +gco3D_SetStencilMask( + IN gco3D Engine, + IN gctUINT8 Mask + ); + +/* Set stencil write mask. */ +gceSTATUS +gco3D_SetStencilWriteMask( + IN gco3D Engine, + IN gctUINT8 Mask + ); + +/* Set stencil reference. */ +gceSTATUS +gco3D_SetStencilReference( + IN gco3D Engine, + IN gctUINT8 Reference + ); + +/* Set stencil compare. */ +gceSTATUS +gco3D_SetStencilCompare( + IN gco3D Engine, + IN gceSTENCIL_WHERE Where, + IN gceCOMPARE Compare + ); + +/* Set stencil operation on pass. */ +gceSTATUS +gco3D_SetStencilPass( + IN gco3D Engine, + IN gceSTENCIL_WHERE Where, + IN gceSTENCIL_OPERATION Operation + ); + +/* Set stencil operation on fail. */ +gceSTATUS +gco3D_SetStencilFail( + IN gco3D Engine, + IN gceSTENCIL_WHERE Where, + IN gceSTENCIL_OPERATION Operation + ); + +/* Set stencil operation on depth fail. */ +gceSTATUS +gco3D_SetStencilDepthFail( + IN gco3D Engine, + IN gceSTENCIL_WHERE Where, + IN gceSTENCIL_OPERATION Operation + ); + +/* Enable or disable alpha test. */ +gceSTATUS +gco3D_SetAlphaTest( + IN gco3D Engine, + IN gctBOOL Enable + ); + +/* Set alpha test compare. */ +gceSTATUS +gco3D_SetAlphaCompare( + IN gco3D Engine, + IN gceCOMPARE Compare + ); + +/* Set alpha test reference in unsigned integer. */ +gceSTATUS +gco3D_SetAlphaReference( + IN gco3D Engine, + IN gctUINT8 Reference + ); + +/* Set alpha test reference in fixed point. */ +gceSTATUS +gco3D_SetAlphaReferenceX( + IN gco3D Engine, + IN gctFIXED_POINT Reference + ); + +/* Set alpha test reference in floating point. */ +gceSTATUS +gco3D_SetAlphaReferenceF( + IN gco3D Engine, + IN gctFLOAT Reference + ); + +/* Enable/Disable anti-alias line. */ +gceSTATUS +gco3D_SetAntiAliasLine( + IN gco3D Engine, + IN gctBOOL Enable + ); + +/* Set texture slot for anti-alias line. */ +gceSTATUS +gco3D_SetAALineTexSlot( + IN gco3D Engine, + IN gctUINT TexSlot + ); + +/* Set anti-alias line width scale. */ +gceSTATUS +gco3D_SetAALineWidth( + IN gco3D Engine, + IN gctFLOAT Width + ); + +/* Draw a number of primitives. */ +gceSTATUS +gco3D_DrawPrimitives( + IN gco3D Engine, + IN gcePRIMITIVE Type, + IN gctINT StartVertex, + IN gctSIZE_T PrimitiveCount + ); + +/* Draw a number of primitives using offsets. */ +gceSTATUS +gco3D_DrawPrimitivesOffset( + IN gco3D Engine, + IN gcePRIMITIVE Type, + IN gctINT32 StartOffset, + IN gctSIZE_T PrimitiveCount + ); + +/* Draw a number of indexed primitives. */ +gceSTATUS +gco3D_DrawIndexedPrimitives( + IN gco3D Engine, + IN gcePRIMITIVE Type, + IN gctINT BaseVertex, + IN gctINT StartIndex, + IN gctSIZE_T PrimitiveCount + ); + +/* Draw a number of indexed primitives using offsets. */ +gceSTATUS +gco3D_DrawIndexedPrimitivesOffset( + IN gco3D Engine, + IN gcePRIMITIVE Type, + IN gctINT32 BaseOffset, + IN gctINT32 StartOffset, + IN gctSIZE_T PrimitiveCount + ); + +/* Enable or disable anti-aliasing. */ +gceSTATUS +gco3D_SetAntiAlias( + IN gco3D Engine, + IN gctBOOL Enable + ); + +/* Write data into the command buffer. */ +gceSTATUS +gco3D_WriteBuffer( + IN gco3D Engine, + IN gctCONST_POINTER Data, + IN gctSIZE_T Bytes, + IN gctBOOL Aligned + ); + +/*Send sempahore and stall until sempahore is signalled.*/ +gceSTATUS +gco3D_Semaphore( + IN gco3D Engine, + IN gceWHERE From, + IN gceWHERE To, + IN gceHOW How); + +/*Set the subpixels center .*/ +gceSTATUS +gco3D_SetCentroids( + IN gco3D Engine, + IN gctUINT32 Index, + IN gctPOINTER Centroids + ); + +/*Get 3D engine status*/ +gceSTATUS +gco3D_Get3DStatus( + IN gco3D Engine, + OUT gctBOOL_PTR* Idle, + OUT gctINT_PTR Count, + OUT gctINT_PTR CurrentCmdIndex + ); +/*----------------------------------------------------------------------------*/ +/*-------------------------- gco3D Fragment Processor ------------------------*/ + +/* Set the fragment processor configuration. */ +gceSTATUS +gco3D_SetFragmentConfiguration( + IN gco3D Engine, + IN gctBOOL ColorFromStream, + IN gctBOOL EnableFog, + IN gctBOOL EnableSmoothPoint, + IN gctUINT32 ClipPlanes + ); + +/* Enable/disable texture stage operation. */ +gceSTATUS +gco3D_EnableTextureStage( + IN gco3D Engine, + IN gctINT Stage, + IN gctBOOL Enable + ); + +/* Program the channel enable masks for the color texture function. */ +gceSTATUS +gco3D_SetTextureColorMask( + IN gco3D Engine, + IN gctINT Stage, + IN gctBOOL ColorEnabled, + IN gctBOOL AlphaEnabled + ); + +/* Program the channel enable masks for the alpha texture function. */ +gceSTATUS +gco3D_SetTextureAlphaMask( + IN gco3D Engine, + IN gctINT Stage, + IN gctBOOL ColorEnabled, + IN gctBOOL AlphaEnabled + ); + +/* Program the constant fragment color. */ +gceSTATUS +gco3D_SetFragmentColorX( + IN gco3D Engine, + IN gctFIXED_POINT Red, + IN gctFIXED_POINT Green, + IN gctFIXED_POINT Blue, + IN gctFIXED_POINT Alpha + ); + +gceSTATUS +gco3D_SetFragmentColorF( + IN gco3D Engine, + IN gctFLOAT Red, + IN gctFLOAT Green, + IN gctFLOAT Blue, + IN gctFLOAT Alpha + ); + +/* Program the constant fog color. */ +gceSTATUS +gco3D_SetFogColorX( + IN gco3D Engine, + IN gctFIXED_POINT Red, + IN gctFIXED_POINT Green, + IN gctFIXED_POINT Blue, + IN gctFIXED_POINT Alpha + ); + +gceSTATUS +gco3D_SetFogColorF( + IN gco3D Engine, + IN gctFLOAT Red, + IN gctFLOAT Green, + IN gctFLOAT Blue, + IN gctFLOAT Alpha + ); + +/* Program the constant texture color. */ +gceSTATUS +gco3D_SetTetxureColorX( + IN gco3D Engine, + IN gctINT Stage, + IN gctFIXED_POINT Red, + IN gctFIXED_POINT Green, + IN gctFIXED_POINT Blue, + IN gctFIXED_POINT Alpha + ); + +gceSTATUS +gco3D_SetTetxureColorF( + IN gco3D Engine, + IN gctINT Stage, + IN gctFLOAT Red, + IN gctFLOAT Green, + IN gctFLOAT Blue, + IN gctFLOAT Alpha + ); + +/* Configure color texture function. */ +gceSTATUS +gco3D_SetColorTextureFunction( + IN gco3D Engine, + IN gctINT Stage, + IN gceTEXTURE_FUNCTION Function, + IN gceTEXTURE_SOURCE Source0, + IN gceTEXTURE_CHANNEL Channel0, + IN gceTEXTURE_SOURCE Source1, + IN gceTEXTURE_CHANNEL Channel1, + IN gceTEXTURE_SOURCE Source2, + IN gceTEXTURE_CHANNEL Channel2, + IN gctINT Scale + ); + +/* Configure alpha texture function. */ +gceSTATUS +gco3D_SetAlphaTextureFunction( + IN gco3D Engine, + IN gctINT Stage, + IN gceTEXTURE_FUNCTION Function, + IN gceTEXTURE_SOURCE Source0, + IN gceTEXTURE_CHANNEL Channel0, + IN gceTEXTURE_SOURCE Source1, + IN gceTEXTURE_CHANNEL Channel1, + IN gceTEXTURE_SOURCE Source2, + IN gceTEXTURE_CHANNEL Channel2, + IN gctINT Scale + ); + + +/******************************************************************************\ +******************************* gcoTEXTURE Object ******************************* +\******************************************************************************/ + +/* Cube faces. */ +typedef enum _gceTEXTURE_FACE +{ + gcvFACE_NONE, + gcvFACE_POSITIVE_X, + gcvFACE_NEGATIVE_X, + gcvFACE_POSITIVE_Y, + gcvFACE_NEGATIVE_Y, + gcvFACE_POSITIVE_Z, + gcvFACE_NEGATIVE_Z, +} +gceTEXTURE_FACE; + +/* Construct a new gcoTEXTURE object. */ +gceSTATUS +gcoTEXTURE_Construct( + IN gcoHAL Hal, + OUT gcoTEXTURE * Texture + ); + +/* Construct a new sized gcoTEXTURE object. */ +gceSTATUS +gcoTEXTURE_ConstructSized( + IN gcoHAL Hal, + IN gceSURF_FORMAT Format, + IN gctUINT Width, + IN gctUINT Height, + IN gctUINT Depth, + IN gctUINT Faces, + IN gctUINT MipMapCount, + IN gcePOOL Pool, + OUT gcoTEXTURE * Texture + ); + +/* Destroy an gcoTEXTURE object. */ +gceSTATUS +gcoTEXTURE_Destroy( + IN gcoTEXTURE Texture + ); + +/*Destroy a texture level*/ +gceSTATUS +gcoTEXTURE_DestroyLevel( + IN gcoTEXTURE Texture, + IN gctINT Level + ); + +/*check texture surface can be reuse*/ +gctBOOL gcoTEXTURE_BConsistent( + IN gcoTEXTURE Texture, + IN gctINT Level, + IN gctSIZE_T Width, + IN gctSIZE_T Height, + IN gceSURF_FORMAT Format + ); + +/* Upload data to an gcoTEXTURE object. */ +gceSTATUS +gcoTEXTURE_Upload( + IN gcoTEXTURE Texture, + IN gceTEXTURE_FACE Face, + IN gctUINT Width, + IN gctUINT Height, + IN gctUINT Slice, + IN gctCONST_POINTER Memory, + IN gctINT Stride, + IN gceSURF_FORMAT Format + ); + +/* Upload data to an gcoTEXTURE object. */ +gceSTATUS +gcoTEXTURE_Upload_Linear( + IN gcoTEXTURE Texture, + IN gceTEXTURE_FACE Face, + IN gctUINT Width, + IN gctUINT Height, + IN gctUINT Slice, + IN gctCONST_POINTER Memory, + IN gctINT Stride, + IN gceSURF_FORMAT Format + ); + +/* Upload data to an gcoTEXTURE object. */ +gceSTATUS +gcoTEXTURE_UploadSub( + IN gcoTEXTURE Texture, + IN gctUINT MipMap, + IN gceTEXTURE_FACE Face, + IN gctUINT X, + IN gctUINT Y, + IN gctUINT Width, + IN gctUINT Height, + IN gctUINT Slice, + IN gctCONST_POINTER Memory, + IN gctINT Stride, + IN gceSURF_FORMAT Format + ); + +gceSTATUS +gcoTEXTURE_UploadSub_Linear( + IN gcoTEXTURE Texture, + IN gctUINT MipMap, + IN gceTEXTURE_FACE Face, + IN gctUINT X, + IN gctUINT Y, + IN gctUINT Width, + IN gctUINT Height, + IN gctUINT Slice, + IN gctCONST_POINTER Memory, + IN gctINT Stride, + IN gceSURF_FORMAT Format + ); + + +/* Upload compressed data to an gcoTEXTURE object. */ +gceSTATUS +gcoTEXTURE_UploadCompressed( + IN gcoTEXTURE Texture, + IN gceTEXTURE_FACE Face, + IN gctUINT Width, + IN gctUINT Height, + IN gctUINT Slice, + IN gctCONST_POINTER Memory, + IN gctSIZE_T Bytes + ); + +/* Get gcoSURF object for a mipmap level. */ +gceSTATUS +gcoTEXTURE_GetMipMap( + IN gcoTEXTURE Texture, + IN gctUINT MipMap, + OUT gcoSURF * Surface + ); + +/* Get gcoSURF object for a mipmap level and face offset. */ +gceSTATUS +gcoTEXTURE_GetMipMapFace( + IN gcoTEXTURE Texture, + IN gctUINT MipMap, + IN gceTEXTURE_FACE Face, + OUT gcoSURF * Surface, + OUT gctUINT32_PTR Offset + ); + +gceSTATUS +gcoTEXTURE_AddMipMap( + IN gcoTEXTURE Texture, + IN gctINT Level, + IN gceSURF_FORMAT Format, + IN gctUINT Width, + IN gctUINT Height, + IN gctUINT Depth, + IN gctUINT Faces, + IN gcePOOL Pool, + OUT gcoSURF * Surface + ); + +gceSTATUS +gcoTEXTURE_AddMipMapFromClient( + IN gcoTEXTURE Texture, + IN gctINT Level, + IN gcoSURF Surface + ); + +gceSTATUS +gcoTEXTURE_AddMipMapFromSurface( + IN gcoTEXTURE Texture, + IN gctINT Level, + IN gcoSURF Surface + ); + +gceSTATUS +gcoTEXTURE_SetEndianHint( + IN gcoTEXTURE Texture, + IN gceENDIAN_HINT EndianHint + ); + +gceSTATUS +gcoTEXTURE_SetAddressingMode( + IN gcoTEXTURE Texture, + IN gceTEXTURE_WHICH Which, + IN gceTEXTURE_ADDRESSING Mode + ); + +gceSTATUS +gcoTEXTURE_SetBorderColor( + IN gcoTEXTURE Texture, + IN gctUINT Red, + IN gctUINT Green, + IN gctUINT Blue, + IN gctUINT Alpha + ); + +gceSTATUS +gcoTEXTURE_SetBorderColorX( + IN gcoTEXTURE Texture, + IN gctFIXED_POINT Red, + IN gctFIXED_POINT Green, + IN gctFIXED_POINT Blue, + IN gctFIXED_POINT Alpha + ); + +gceSTATUS +gcoTEXTURE_SetBorderColorF( + IN gcoTEXTURE Texture, + IN gctFLOAT Red, + IN gctFLOAT Green, + IN gctFLOAT Blue, + IN gctFLOAT Alpha + ); + +gctBOOL +gcoTEXTURE_IsSupportMipMap( + IN gcoTEXTURE Texture + ); + +gceSTATUS +gcoTEXTURE_SetMinFilter( + IN gcoTEXTURE Texture, + IN gceTEXTURE_FILTER Filter + ); + +gceSTATUS +gcoTEXTURE_SetMagFilter( + IN gcoTEXTURE Texture, + IN gceTEXTURE_FILTER Filter + ); + +gceSTATUS +gcoTEXTURE_SetMipFilter( + IN gcoTEXTURE Texture, + IN gceTEXTURE_FILTER Filter + ); + +gceSTATUS +gcoTEXTURE_SetLODBiasX( + IN gcoTEXTURE Texture, + IN gctFIXED_POINT Bias + ); + +gceSTATUS +gcoTEXTURE_SetLODBiasF( + IN gcoTEXTURE Texture, + IN gctFLOAT Bias + ); + +gceSTATUS +gcoTEXTURE_SetLODMinX( + IN gcoTEXTURE Texture, + IN gctFIXED_POINT LevelOfDetail + ); + +gceSTATUS +gcoTEXTURE_SetLODMinF( + IN gcoTEXTURE Texture, + IN gctFLOAT LevelOfDetail + ); + +gceSTATUS +gcoTEXTURE_SetLODMaxX( + IN gcoTEXTURE Texture, + IN gctFIXED_POINT LevelOfDetail + ); + +gceSTATUS +gcoTEXTURE_SetLODMaxF( + IN gcoTEXTURE Texture, + IN gctFLOAT LevelOfDetail + ); + +gceSTATUS +gcoTEXTURE_Bind( + IN gcoTEXTURE Texture, + IN gctINT Sampler, + IN gctUINT Param + ); + +gceSTATUS +gcoTEXTURE_Disable( + IN gcoHAL Hal, + IN gctINT Sampler + ); + +gceSTATUS +gcoTEXTURE_Flush( + IN gcoTEXTURE Texture + ); + +gceSTATUS +gcoTEXTURE_QueryCaps( + OUT gctUINT * MaxWidth, + OUT gctUINT * MaxHeight, + OUT gctUINT * MaxDepth, + OUT gctBOOL * Cubic, + OUT gctBOOL * NonPowerOfTwo, + OUT gctUINT * VertexSamplers, + OUT gctUINT * PixelSamplers + ); + +gceSTATUS +gcoTEXTURE_GetClosestFormat( + IN gcoHAL Hal, + IN gceSURF_FORMAT InFormat, + OUT gceSURF_FORMAT* OutFormat + ); + +gceSTATUS +gcoTEXTURE_RenderIntoMipMap( + IN gcoTEXTURE Texture, + IN gctINT Level + ); + +gceSTATUS +gcoTEXTURE_IsRenderable( + IN gcoTEXTURE Texture, + IN gctUINT Level + ); + +gceSTATUS +gcoTEXTURE_IsComplete( + IN gcoTEXTURE Texture, + IN gctINT MaxLevel + ); + +/******************************************************************************\ +******************************* gcoSTREAM Object ****************************** +\******************************************************************************/ + +typedef enum _gceVERTEX_FORMAT +{ + gcvVERTEX_BYTE, + gcvVERTEX_UNSIGNED_BYTE, + gcvVERTEX_SHORT, + gcvVERTEX_UNSIGNED_SHORT, + gcvVERTEX_INT, + gcvVERTEX_UNSIGNED_INT, + gcvVERTEX_FIXED, + gcvVERTEX_HALF, + gcvVERTEX_FLOAT, +} +gceVERTEX_FORMAT; + +gceSTATUS +gcoSTREAM_Construct( + IN gcoHAL Hal, + OUT gcoSTREAM * Stream + ); + +gceSTATUS +gcoSTREAM_Destroy( + IN gcoSTREAM Stream + ); + +gceSTATUS +gcoSTREAM_Upload( + IN gcoSTREAM Stream, + IN gctCONST_POINTER Buffer, + IN gctUINT32 Offset, + IN gctSIZE_T Bytes, + IN gctBOOL Dynamic + ); + +gceSTATUS +gcoSTREAM_SetStride( + IN gcoSTREAM Stream, + IN gctUINT32 Stride + ); + +gceSTATUS +gcoSTREAM_Lock( + IN gcoSTREAM Stream, + OUT gctPOINTER * Logical, + OUT gctUINT32 * Physical + ); + +gceSTATUS +gcoSTREAM_Unlock( + IN gcoSTREAM Stream); + +gceSTATUS +gcoSTREAM_Reserve( + IN gcoSTREAM Stream, + IN gctSIZE_T Bytes, + IN gctBOOL bSystemCache + ); + +gceSTATUS +gcoSTREAM_GetSystemCache( + IN gcoSTREAM Stream, + OUT gctPOINTER* pSystemCache); + +gceSTATUS +gcoSTREAM_GetStreamSize( + IN gcoSTREAM Stream, + OUT gctUINT32* pSize); + +gceSTATUS +gcoSTREAM_ConstructReserveMemory( + IN gcoHAL Hal); + +gceSTATUS +gcoSTREAM_DestroyReserveMemory( + IN gcoHAL Hal); + +gceSTATUS +gcoSTREAM_GetReserveMemIndexOffset( + IN gcoHAL Hal, + OUT gctUINT32 * reserveMemoryIndex, + OUT gctUINT32 * reserveMemoryOffset); + +gceSTATUS +gcoSTREAM_GetReserveMemory( + IN gcoHAL Hal, + IN gctUINT32 requestSize, + IN gcoSTREAM stream, + IN gcoINDEX index + ); + +gctBOOL +gcoSTREAM_SignalReserveMemory( + IN gcoHAL Hal); + +gceSTATUS +gcoSTREAM_Flush( + IN gcoSTREAM Stream + ); + +/* Dynamic buffer API. */ +gceSTATUS +gcoSTREAM_SetDynamic( + IN gcoSTREAM Stream, + IN gctSIZE_T Bytes, + IN gctUINT Buffers + ); + +typedef struct _gcsSTREAM_INFO +{ + gctUINT index; + gceVERTEX_FORMAT format; + gctBOOL normalized; + gctUINT components; + gctSIZE_T size; + gctCONST_POINTER data; + gctUINT stride; + gctUINT offset; + gcoSTREAM stream; +} +gcsSTREAM_INFO, * gcsSTREAM_INFO_PTR; + +gceSTATUS +gcoSTREAM_UploadDynamic( + IN gcoSTREAM Stream, + IN gctUINT VertexCount, + IN gctUINT InfoCount, + IN gcsSTREAM_INFO_PTR Info, + IN gcoVERTEX Vertex + ); + +/******************************************************************************\ +******************************** gcoVERTEX Object ****************************** +\******************************************************************************/ + +typedef struct _gcsVERTEX_ATTRIBUTES +{ + gceVERTEX_FORMAT format; + gctBOOL normalized; + gctUINT32 components; + gctSIZE_T size; + gctUINT32 stream; + gctUINT32 offset; + gctUINT32 stride; +} +gcsVERTEX_ATTRIBUTES; + +gceSTATUS +gcoVERTEX_Construct( + IN gcoHAL Hal, + OUT gcoVERTEX * Vertex + ); + +gceSTATUS +gcoVERTEX_Destroy( + IN gcoVERTEX Vertex + ); + +gceSTATUS +gcoVERTEX_Reset( + IN gcoVERTEX Vertex + ); + +gceSTATUS +gcoVERTEX_EnableAttribute( + IN gcoVERTEX Vertex, + IN gctUINT32 Index, + IN gceVERTEX_FORMAT Format, + IN gctBOOL Normalized, + IN gctUINT32 Components, + IN gcoSTREAM Stream, + IN gctUINT32 Offset, + IN gctUINT32 Stride + ); + +gceSTATUS +gcoVERTEX_DisableAttribute( + IN gcoVERTEX Vertex, + IN gctUINT32 Index + ); + +gceSTATUS +gcoVERTEX_Bind_fast( + IN gcoVERTEX Vertex, + IN gctUINT32 attributeCount + ); + +gceSTATUS +gcoVERTEX_Bind( + IN gcoVERTEX Vertex + ); + +#ifdef __cplusplus +} +#endif + +#endif /* __gc_hal_engine_h_ */ + diff --git a/native/include_dove/gc_hal_enum.h b/native/include_dove/gc_hal_enum.h new file mode 100644 index 0000000..d0361af --- /dev/null +++ b/native/include_dove/gc_hal_enum.h @@ -0,0 +1,565 @@ +/**************************************************************************** +* +* Copyright (C) 2005 - 2010 by Vivante Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the license, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +* +*****************************************************************************/ + + + + +#ifndef __gc_hal_enum_h_ +#define __gc_hal_enum_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Chip models. */ +typedef enum _gceCHIPMODEL +{ + gcv300 = 0x0300, + gcv400 = 0x0400, + gcv410 = 0x0410, + gcv450 = 0x0450, + gcv500 = 0x0500, + gcv530 = 0x0530, + gcv600 = 0x0600, + gcv700 = 0x0700, + gcv800 = 0x0800, + gcv860 = 0x0860, + gcv1000 = 0x1000, +} +gceCHIPMODEL; + +/* Chip features. */ +typedef enum _gceFEATURE +{ + gcvFEATURE_PIPE_2D, + gcvFEATURE_PIPE_3D, + gcvFEATURE_PIPE_VG, + gcvFEATURE_DC, + gcvFEATURE_HIGH_DYNAMIC_RANGE, + gcvFEATURE_MODULE_CG, + gcvFEATURE_MIN_AREA, + gcvFEATURE_BUFFER_INTERLEAVING, + gcvFEATURE_BYTE_WRITE_2D, + gcvFEATURE_ENDIANNESS_CONFIG, + gcvFEATURE_DUAL_RETURN_BUS, + gcvFEATURE_DEBUG_MODE, + gcvFEATURE_YUY2_RENDER_TARGET, + gcvFEATURE_FRAGMENT_PROCESSOR, + gcvFEATURE_2DPE20, + gcvFEATURE_FAST_CLEAR, + gcvFEATURE_YUV420_TILER, + gcvFEATURE_YUY2_AVERAGING, + gcvFEATURE_FLIP_Y, + gcvFEATURE_EARLY_Z, + gcvFEATURE_Z_COMPRESSION, + gcvFEATURE_MSAA, + gcvFEATURE_SPECIAL_ANTI_ALIASING, + gcvFEATURE_SPECIAL_MSAA_LOD, + gcvFEATURE_422_TEXTURE_COMPRESSION, + gcvFEATURE_DXT_TEXTURE_COMPRESSION, + gcvFEATURE_ETC1_TEXTURE_COMPRESSION, + gcvFEATURE_CORRECT_TEXTURE_CONVERTER, + gcvFEATURE_TEXTURE_8K, + gcvFEATURE_SCALER, + gcvFEATURE_YUV420_SCALER, + gcvFEATURE_SHADER_HAS_W, + gcvFEATURE_SHADER_HAS_SIGN, + gcvFEATURE_SHADER_HAS_FLOOR, + gcvFEATURE_SHADER_HAS_CEIL, + gcvFEATURE_SHADER_HAS_SQRT, + gcvFEATURE_SHADER_HAS_TRIG, + gcvFEATURE_VAA, + gcvFEATURE_HZ, + gcvFEATURE_CORRECT_STENCIL, + gcvFEATURE_VG20, + gcvFEATURE_VG_FILTER, + gcvFEATURE_VG21, + gcvFEATURE_VG_DOUBLE_BUFFER, + gcvFEATURE_MC20, + gcvFEATURE_SUPER_TILED, +} +gceFEATURE; + +/* Chip Power Status. */ +typedef enum _gceCHIPPOWERSTATE +{ + gcvPOWER_ON, + gcvPOWER_OFF, + gcvPOWER_IDLE, + gcvPOWER_SUSPEND, + gcvPOWER_SUSPEND_ATPOWERON, + gcvPOWER_OFF_ATPOWERON, + gcvPOWER_IDLE_BROADCAST, + gcvPOWER_SUSPEND_BROADCAST, + gcvPOWER_OFF_BROADCAST, + gcvPOWER_OFF_RECOVERY, +} +gceCHIPPOWERSTATE; + +/* Surface types. */ +typedef enum _gceSURF_TYPE +{ + gcvSURF_TYPE_UNKNOWN, + gcvSURF_INDEX, + gcvSURF_VERTEX, + gcvSURF_TEXTURE, + gcvSURF_RENDER_TARGET, + gcvSURF_DEPTH, + gcvSURF_BITMAP, + gcvSURF_TILE_STATUS, + gcvSURF_MASK, + gcvSURF_SCISSOR, + gcvSURF_HIERARCHICAL_DEPTH, + gcvSURF_NUM_TYPES, /* Make sure this is the last one! */ + + /* Combinations. */ + gcvSURF_NO_TILE_STATUS = 0x100, + gcvSURF_RENDER_TARGET_NO_TILE_STATUS = gcvSURF_RENDER_TARGET + | gcvSURF_NO_TILE_STATUS, + gcvSURF_DEPTH_NO_TILE_STATUS = gcvSURF_DEPTH + | gcvSURF_NO_TILE_STATUS, +} +gceSURF_TYPE; + +typedef enum _gceSURF_COLOR_TYPE +{ + gcvSURF_COLOR_UNKNOWN, + gcvSURF_COLOR_LINEAR = 0x01, + gcvSURF_COLOR_ALPHA_PRE = 0x02, +} +gceSURF_COLOR_TYPE; + +/* Rotation. */ +typedef enum _gceSURF_ROTATION +{ + gcvSURF_0_DEGREE, + gcvSURF_90_DEGREE, + gcvSURF_180_DEGREE, + gcvSURF_270_DEGREE +} +gceSURF_ROTATION; + +/* Surface formats. */ +typedef enum _gceSURF_FORMAT +{ + /* Unknown format. */ + gcvSURF_UNKNOWN, + + /* Palettized formats. */ + gcvSURF_INDEX1 = 100, + gcvSURF_INDEX4, + gcvSURF_INDEX8, + + /* RGB formats. */ + gcvSURF_A2R2G2B2 = 200, + gcvSURF_R3G3B2, + gcvSURF_A8R3G3B2, + gcvSURF_X4R4G4B4, + gcvSURF_A4R4G4B4, + gcvSURF_R4G4B4A4, + gcvSURF_X1R5G5B5, + gcvSURF_A1R5G5B5, + gcvSURF_R5G5B5A1, + gcvSURF_R5G6B5, + gcvSURF_R8G8B8, + gcvSURF_X8R8G8B8, + gcvSURF_A8R8G8B8, + gcvSURF_R8G8B8A8, + gcvSURF_G8R8G8B8, + gcvSURF_R8G8B8G8, + gcvSURF_X2R10G10B10, + gcvSURF_A2R10G10B10, + gcvSURF_X12R12G12B12, + gcvSURF_A12R12G12B12, + gcvSURF_X16R16G16B16, + gcvSURF_A16R16G16B16, + gcvSURF_R8G8B8X8, + gcvSURF_R5G5B5X1, + gcvSURF_R4G4B4X4, + + /* BGR formats. */ + gcvSURF_A4B4G4R4 = 300, + gcvSURF_A1B5G5R5, + gcvSURF_B5G6R5, + gcvSURF_B8G8R8, + gcvSURF_X8B8G8R8, + gcvSURF_A8B8G8R8, + gcvSURF_A2B10G10R10, + gcvSURF_A16B16G16R16, + gcvSURF_G16R16, + gcvSURF_B4G4R4A4, + gcvSURF_B5G5R5A1, + gcvSURF_B8G8R8X8, + gcvSURF_B8G8R8A8, + gcvSURF_X4B4G4R4, + gcvSURF_X1B5G5R5, + gcvSURF_B4G4R4X4, + gcvSURF_B5G5R5X1, + + /* Compressed formats. */ + gcvSURF_DXT1 = 400, + gcvSURF_DXT2, + gcvSURF_DXT3, + gcvSURF_DXT4, + gcvSURF_DXT5, + gcvSURF_CXV8U8, + gcvSURF_ETC1, + + /* YUV formats. */ + gcvSURF_YUY2 = 500, + gcvSURF_UYVY, + gcvSURF_YV12, + gcvSURF_I420, + gcvSURF_NV12, + gcvSURF_NV21, + gcvSURF_NV16, + gcvSURF_NV61, + gcvSURF_YVYU, + gcvSURF_VYUY, + + /* Depth formats. */ + gcvSURF_D16 = 600, + gcvSURF_D24S8, + gcvSURF_D32, + gcvSURF_D24X8, + + /* Alpha formats. */ + gcvSURF_A4 = 700, + gcvSURF_A8, + gcvSURF_A12, + gcvSURF_A16, + gcvSURF_A32, + gcvSURF_A1, + + /* Luminance formats. */ + gcvSURF_L4 = 800, + gcvSURF_L8, + gcvSURF_L12, + gcvSURF_L16, + gcvSURF_L32, + gcvSURF_L1, + + /* Alpha/Luminance formats. */ + gcvSURF_A4L4 = 900, + gcvSURF_A2L6, + gcvSURF_A8L8, + gcvSURF_A4L12, + gcvSURF_A12L12, + gcvSURF_A16L16, + + /* Bump formats. */ + gcvSURF_L6V5U5 = 1000, + gcvSURF_V8U8, + gcvSURF_X8L8V8U8, + gcvSURF_Q8W8V8U8, + gcvSURF_A2W10V10U10, + gcvSURF_V16U16, + gcvSURF_Q16W16V16U16, + + /* Floating point formats. */ + gcvSURF_R16F = 1100, + gcvSURF_G16R16F, + gcvSURF_A16B16G16R16F, + gcvSURF_R32F, + gcvSURF_G32R32F, + gcvSURF_A32B32G32R32F, + +#if 0 + /* FIXME: remove HDR support for now. */ + /* HDR formats. */ + gcvSURF_HDR7E3 = 1200, + gcvSURF_HDR6E4, + gcvSURF_HDR5E5, + gcvSURF_HDR6E5, +#endif +} +gceSURF_FORMAT; + +/* Pixel swizzle modes. */ +typedef enum _gceSURF_SWIZZLE +{ + gcvSURF_NOSWIZZLE, + gcvSURF_ARGB, + gcvSURF_ABGR, + gcvSURF_RGBA, + gcvSURF_BGRA +} +gceSURF_SWIZZLE; + +/* Transparency modes. */ +typedef enum _gceSURF_TRANSPARENCY +{ + /* Valid only for PE 1.0 */ + gcvSURF_OPAQUE, + gcvSURF_SOURCE_MATCH, + gcvSURF_SOURCE_MASK, + gcvSURF_PATTERN_MASK, +} +gceSURF_TRANSPARENCY; + +/* Transparency modes. */ +typedef enum _gce2D_TRANSPARENCY +{ + /* Valid only for PE 2.0 */ + gcv2D_OPAQUE, + gcv2D_KEYED, + gcv2D_MASKED +} +gce2D_TRANSPARENCY; + +/* Mono packing modes. */ +typedef enum _gceSURF_MONOPACK +{ + gcvSURF_PACKED8, + gcvSURF_PACKED16, + gcvSURF_PACKED32, + gcvSURF_UNPACKED, +} +gceSURF_MONOPACK; + +/* Blending modes. */ +typedef enum _gceSURF_BLEND_MODE +{ + /* Porter-Duff blending modes. */ + /* Fsrc Fdst */ + gcvBLEND_CLEAR, /* 0 0 */ + gcvBLEND_SRC, /* 1 0 */ + gcvBLEND_DST, /* 0 1 */ + gcvBLEND_SRC_OVER_DST, /* 1 1 - Asrc */ + gcvBLEND_DST_OVER_SRC, /* 1 - Adst 1 */ + gcvBLEND_SRC_IN_DST, /* Adst 0 */ + gcvBLEND_DST_IN_SRC, /* 0 Asrc */ + gcvBLEND_SRC_OUT_DST, /* 1 - Adst 0 */ + gcvBLEND_DST_OUT_SRC, /* 0 1 - Asrc */ + gcvBLEND_SRC_ATOP_DST, /* Adst 1 - Asrc */ + gcvBLEND_DST_ATOP_SRC, /* 1 - Adst Asrc */ + gcvBLEND_SRC_XOR_DST, /* 1 - Adst 1 - Asrc */ + + /* Special blending modes. */ + gcvBLEND_SET, /* DST = 1 */ + gcvBLEND_SUB /* DST = DST * (1 - SRC) */ +} +gceSURF_BLEND_MODE; + +/* Per-pixel alpha modes. */ +typedef enum _gceSURF_PIXEL_ALPHA_MODE +{ + gcvSURF_PIXEL_ALPHA_STRAIGHT, + gcvSURF_PIXEL_ALPHA_INVERSED +} +gceSURF_PIXEL_ALPHA_MODE; + +/* Global alpha modes. */ +typedef enum _gceSURF_GLOBAL_ALPHA_MODE +{ + gcvSURF_GLOBAL_ALPHA_OFF, + gcvSURF_GLOBAL_ALPHA_ON, + gcvSURF_GLOBAL_ALPHA_SCALE +} +gceSURF_GLOBAL_ALPHA_MODE; + +/* Color component modes for alpha blending. */ +typedef enum _gceSURF_PIXEL_COLOR_MODE +{ + gcvSURF_COLOR_STRAIGHT, + gcvSURF_COLOR_MULTIPLY +} +gceSURF_PIXEL_COLOR_MODE; + +/* Color component modes for alpha blending. */ +typedef enum _gce2D_PIXEL_COLOR_MULTIPLY_MODE +{ + gcv2D_COLOR_MULTIPLY_DISABLE, + gcv2D_COLOR_MULTIPLY_ENABLE +} +gce2D_PIXEL_COLOR_MULTIPLY_MODE; + +/* Color component modes for alpha blending. */ +typedef enum _gce2D_GLOBAL_COLOR_MULTIPLY_MODE +{ + gcv2D_GLOBAL_COLOR_MULTIPLY_DISABLE, + gcv2D_GLOBAL_COLOR_MULTIPLY_ALPHA, + gcv2D_GLOBAL_COLOR_MULTIPLY_COLOR +} +gce2D_GLOBAL_COLOR_MULTIPLY_MODE; + +/* Alpha blending factor modes. */ +typedef enum _gceSURF_BLEND_FACTOR_MODE +{ + gcvSURF_BLEND_ZERO, + gcvSURF_BLEND_ONE, + gcvSURF_BLEND_STRAIGHT, + gcvSURF_BLEND_INVERSED, + gcvSURF_BLEND_COLOR, + gcvSURF_BLEND_COLOR_INVERSED, + gcvSURF_BLEND_SRC_ALPHA_SATURATED +} +gceSURF_BLEND_FACTOR_MODE; + +/* Alpha blending porter duff rules. */ +typedef enum _gce2D_PORTER_DUFF_RULE +{ + gcvPD_CLEAR, + gcvPD_SRC, + gcvPD_SRC_OVER, + gcvPD_DST_OVER, + gcvPD_SRC_IN, + gcvPD_DST_IN, + gcvPD_SRC_OUT, + gcvPD_DST_OUT, + gcvPD_SRC_ATOP, + gcvPD_DST_ATOP, + gcvPD_ADD, + gcvPD_XOR, + gcvPD_DST +} +gce2D_PORTER_DUFF_RULE; + +/* Alpha blending factor modes. */ +typedef enum _gce2D_YUV_COLOR_MODE +{ + gcv2D_YUV_601, + gcv2D_YUV_709 +} +gce2D_YUV_COLOR_MODE; + +/* 2D Rotation and flipping. */ +typedef enum _gce2D_ORIENTATION +{ + gcv2D_0_DEGREE, + gcv2D_90_DEGREE, + gcv2D_180_DEGREE, + gcv2D_270_DEGREE, + gcv2D_X_FLIP, + gcv2D_Y_FLIP +} +gce2D_ORIENTATION; + +typedef enum _gce2D_COMMAND +{ + gcv2D_CLEAR, + gcv2D_LINE, + gcv2D_BLT, + gcv2D_STRETCH, + gcv2D_HOR_FILTER, + gcv2D_VER_FILTER, +} +gce2D_COMMAND; + +/* Texture functions. */ +typedef enum _gceTEXTURE_FUNCTION +{ + gcvTEXTURE_DUMMY = 0, + gcvTEXTURE_REPLACE = 0, + gcvTEXTURE_MODULATE, + gcvTEXTURE_ADD, + gcvTEXTURE_ADD_SIGNED, + gcvTEXTURE_INTERPOLATE, + gcvTEXTURE_SUBTRACT, + gcvTEXTURE_DOT3 +} +gceTEXTURE_FUNCTION; + +/* Texture sources. */ +typedef enum _gceTEXTURE_SOURCE +{ + gcvCOLOR_FROM_TEXTURE, + gcvCOLOR_FROM_CONSTANT_COLOR, + gcvCOLOR_FROM_PRIMARY_COLOR, + gcvCOLOR_FROM_PREVIOUS_COLOR +} +gceTEXTURE_SOURCE; + +/* Texture source channels. */ +typedef enum _gceTEXTURE_CHANNEL +{ + gcvFROM_COLOR, + gcvFROM_ONE_MINUS_COLOR, + gcvFROM_ALPHA, + gcvFROM_ONE_MINUS_ALPHA +} +gceTEXTURE_CHANNEL; + +/* Filter types. */ +typedef enum _gceFILTER_TYPE +{ + gcvFILTER_SYNC, + gcvFILTER_BLUR, + gcvFILTER_USER +} +gceFILTER_TYPE; + +/* Filter pass types. */ +typedef enum _gceFILTER_PASS_TYPE +{ + gcvFILTER_HOR_PASS, + gcvFILTER_VER_PASS +} +gceFILTER_PASS_TYPE; + +/* Endian hints. */ +typedef enum _gceENDIAN_HINT +{ + gcvENDIAN_NO_SWAP = 0, + gcvENDIAN_SWAP_WORD, + gcvENDIAN_SWAP_DWORD +} +gceENDIAN_HINT; + +/* Endian hints. */ +typedef enum _gceTILING +{ + gcvLINEAR, + gcvTILED, + gcvSUPERTILED +} +gceTILING; + +typedef enum _gceSAMPLERDIRTY +{ + gcvSAMPLER_MIN_FILTER_DIRTY, + gcvSAMPLER_MAG_FILTER_DIRTY, + gcvSAMPLER_WRAPR_DIRTY_DIRTY, + gcvSAMPLER_WRAPS_DIRTY_DIRTY, + gcvSAMPLER_WRAPT_DIRTY_DIRTY, + gcvSAMPLER_LODMINX_DIRTY, + gcvSAMPLER_LODBIASX_DIRTY, + gcvSAMPLER_BORDERCOLOR_DIRTY, + gcvSAMPLER_MIPMAP_DIRTY, + gcvSAMPLER_ALL_DIRTY +} +gceSAMPLERDIRTY; +/******************************************************************************\ +****************************** Object Declarations ***************************** +\******************************************************************************/ + +typedef struct _gcoCONTEXT * gcoCONTEXT; +typedef struct _gcoCTXBUF * gcoCTXBUF; +typedef struct _gcoCMDBUF * gcoCMDBUF; +typedef struct _gcoQUEUE * gcoQUEUE; +typedef struct _gcsHAL_INTERFACE * gcsHAL_INTERFACE_PTR; +typedef struct gcs2D_PROFILE * gcs2D_PROFILE_PTR; + +#ifdef __cplusplus +} +#endif + +#endif /* __gc_hal_enum_h_ */ + diff --git a/native/include_dove/gc_hal_mem.h b/native/include_dove/gc_hal_mem.h new file mode 100644 index 0000000..e3c4433 --- /dev/null +++ b/native/include_dove/gc_hal_mem.h @@ -0,0 +1,472 @@ +/**************************************************************************** +* +* Copyright (C) 2005 - 2010 by Vivante Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the license, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +* +*****************************************************************************/ + + + + +/* +** Include file for the local memory management. +*/ + +#ifndef __gc_hal_mem_h_ +#define __gc_hal_mem_h_ + +#ifdef __cplusplus +extern "C" { +#endif +#if 0 +******************************************************************************* +** Usage: + + The macros to declare MemPool type and functions are + gcmMEM_DeclareFSMemPool (Type, TypeName, Prefix) + gcmMEM_DeclareVSMemPool (Type, TypeName, Prefix) + gcmMEM_DeclareAFSMemPool(Type, TypeName, Prefix) + + The data structures for MemPool are + typedef struct _gcsMEM_FS_MEM_POOL * gcsMEM_FS_MEM_POOL; + typedef struct _gcsMEM_VS_MEM_POOL * gcsMEM_VS_MEM_POOL; + typedef struct _gcsMEM_AFS_MEM_POOL * gcsMEM_AFS_MEM_POOL; + + The MemPool constructor and destructor functions are + gcfMEM_InitFSMemPool(gcsMEM_FS_MEM_POOL *, gcoOS, gctUINT, gctUINT); + gcfMEM_FreeFSMemPool(gcsMEM_FS_MEM_POOL *); + gcfMEM_InitVSMemPool(gcsMEM_VS_MEM_POOL *, gcoOS, gctUINT, gctBOOL); + gcfMEM_FreeVSMemPool(gcsMEM_VS_MEM_POOL *); + gcfMEM_InitAFSMemPool(gcsMEM_AFS_MEM_POOL *, gcoOS, gctUINT); + gcfMEM_FreeAFSMemPool(gcsMEM_AFS_MEM_POOL *); + + FS: for Fixed-Size data structures + VS: for Variable-size data structures + AFS: for Array of Fixed-Size data structures + + + /* Example 1: For a fixed-size data structure, struct gcsNode. */ + /* It is used locally in a file, so the functions are static without prefix. */ + /* At top level, declear allocate and free functions. */ + /* The first argument is the data type. */ + /* The second armument is the short name used in the fuctions. */ + gcmMEM_DeclareFSMemPool(struct gcsNode, Node, ); + + /* The previous macro creates two inline functions, */ + /* _AllocateNode and _FreeNode. */ + + /* In function or struct */ + gcsMEM_FS_MEM_POOL nodeMemPool; + + /* In function, */ + struct gcsNode * node; + gceSTATUS status; + + /* Before using the memory pool, initialize it. */ + /* The second argument is the gcoOS object. */ + /* The third argument is the number of data structures to allocate for each chunk. */ + status = gcfMEM_InitFSMemPool(&nodeMemPool, os, 100, sizeof(struct gcsNode)); + ... + + /* Allocate a node. */ + status = _AllocateNode(nodeMemPool, &node); + ... + /* Free a node. */ + _FreeNode(nodeMemPool, node); + + /* After using the memory pool, free it. */ + gcfMEM_FreeFSMemPool(&nodeMemPool); + + + /* Example 2: For array of fixed-size data structures, struct gcsNode. */ + /* It is used in several files, so the functions are extern with prefix. */ + /* At top level, declear allocate and free functions. */ + /* The first argument is the data type, and the second one is the short name */ + /* used in the fuctions. */ + gcmMEM_DeclareAFSMemPool(struct gcsNode, NodeArray, gcfOpt); + + /* The previous macro creates two inline functions, */ + /* gcfOpt_AllocateNodeArray and gcfOpt_FreeNodeArray. */ + + /* In function or struct */ + gcsMEM_AFS_MEM_POOL nodeArrayMemPool; + + /* In function, */ + struct gcsNode * nodeArray; + gceSTATUS status; + + /* Before using the array memory pool, initialize it. */ + /* The second argument is the gcoOS object, the third is the number of data */ + /* structures to allocate for each chunk. */ + status = gcfMEM_InitAFSMemPool(&nodeArrayMemPool, os, sizeof(struct gcsNode)); + ... + + /* Allocate a node array of size 100. */ + status = gcfOpt_AllocateNodeArray(nodeArrayMemPool, &nodeArray, 100); + ... + /* Free a node array. */ + gcfOpt_FreeNodeArray(&nodeArrayMemPool, nodeArray); + + /* After using the array memory pool, free it. */ + gcfMEM_FreeAFSMemPool(&nodeArrayMemPool); + +******************************************************************************* +#endif + +/******************************************************************************* +** To switch back to use gcoOS_Allocate and gcoOS_Free, add +** #define USE_LOCAL_MEMORY_POOL 0 +** before including this file. +*******************************************************************************/ +#ifndef USE_LOCAL_MEMORY_POOL +/* + USE_LOCAL_MEMORY_POOL + + This define enables the local memory management to improve performance. +*/ +#define USE_LOCAL_MEMORY_POOL 1 +#endif + +/******************************************************************************* +** Memory Pool Data Structures +*******************************************************************************/ +#if USE_LOCAL_MEMORY_POOL + typedef struct _gcsMEM_FS_MEM_POOL * gcsMEM_FS_MEM_POOL; + typedef struct _gcsMEM_VS_MEM_POOL * gcsMEM_VS_MEM_POOL; + typedef struct _gcsMEM_AFS_MEM_POOL * gcsMEM_AFS_MEM_POOL; +#else + typedef gcoOS gcsMEM_FS_MEM_POOL; + typedef gcoOS gcsMEM_VS_MEM_POOL; + typedef gcoOS gcsMEM_AFS_MEM_POOL; +#endif + +/******************************************************************************* +** Memory Pool Macros +*******************************************************************************/ +#if USE_LOCAL_MEMORY_POOL +#define gcmMEM_DeclareFSMemPool(Type, TypeName, Prefix) \ +gceSTATUS \ +Prefix##_Allocate##TypeName( \ + gcsMEM_FS_MEM_POOL MemPool, \ + Type ** Pointer \ + ) \ +{ \ + return(gcfMEM_FSMemPoolGetANode(MemPool, (gctPOINTER *) Pointer)); \ +} \ + \ +gceSTATUS \ +Prefix##_CAllocate##TypeName( \ + gcsMEM_FS_MEM_POOL MemPool, \ + Type ** Pointer \ + ) \ +{ \ + gceSTATUS status; \ + gcmERR_RETURN(gcfMEM_FSMemPoolGetANode(MemPool, (gctPOINTER *) Pointer)); \ + gcmVERIFY_OK(gcoOS_ZeroMemory(*(gctPOINTER *) Pointer, gcmSIZEOF(Type))); \ + return gcvSTATUS_OK; \ +} \ + \ +gceSTATUS \ +Prefix##_Free##TypeName( \ + gcsMEM_FS_MEM_POOL MemPool, \ + Type * Pointer \ + ) \ +{ \ + return(gcfMEM_FSMemPoolFreeANode(MemPool, (gctPOINTER) Pointer)); \ +} \ + \ +gceSTATUS \ +Prefix##_Free##TypeName##List( \ + gcsMEM_FS_MEM_POOL MemPool, \ + Type * FirstPointer, \ + Type * LastPointer \ + ) \ +{ \ + return(gcfMEM_FSMemPoolFreeAList(MemPool, (gctPOINTER) FirstPointer, (gctPOINTER) LastPointer)); \ +} + +#define gcmMEM_DeclareVSMemPool(Type, TypeName, Prefix) \ +gceSTATUS \ +Prefix##_Allocate##TypeName( \ + gcsMEM_FS_MEM_POOL MemPool, \ + Type ** Pointer, \ + gctUINT Size \ + ) \ +{ \ + return(gcfMEM_VSMemPoolGetANode(MemPool, Size, (gctPOINTER *) Pointer)); \ +} \ + \ +gceSTATUS \ + Prefix##_CAllocate##TypeName( \ + gcsMEM_FS_MEM_POOL MemPool, \ + Type ** Pointer, \ + gctUINT Size \ + ) \ +{ \ + gceSTATUS status; \ + gcmERR_RETURN(gcfMEM_VSMemPoolGetANode(MemPool, Size, (gctPOINTER *) Pointer)); \ + gcmVERIFY_OK(gcoOS_ZeroMemory(*(gctPOINTER *) Pointer, size)); \ + return gcvSTATUS_OK; \ +} \ + \ +gceSTATUS \ +Prefix##_Free##TypeName( \ + gcsMEM_FS_MEM_POOL MemPool, \ + Type * Pointer \ + ) \ +{ \ + return(gcfMEM_VSMemPoolFreeANode(MemPool, (gctPOINTER) Pointer)); \ +} + +#define gcmMEM_DeclareAFSMemPool(Type, TypeName, Prefix) \ +gceSTATUS \ +Prefix##_Allocate##TypeName( \ + gcsMEM_AFS_MEM_POOL MemPool, \ + Type ** Pointer, \ + gctUINT Count \ + ) \ +{ \ + return(gcfMEM_AFSMemPoolGetANode(MemPool, Count, (gctPOINTER *) Pointer)); \ +} \ + \ +gceSTATUS \ +Prefix##_CAllocate##TypeName( \ + gcsMEM_AFS_MEM_POOL MemPool, \ + Type ** Pointer, \ + gctUINT Count \ + ) \ +{ \ + gceSTATUS status; \ + gcmERR_RETURN(gcfMEM_AFSMemPoolGetANode(MemPool, Count, (gctPOINTER *) Pointer)); \ + gcmVERIFY_OK(gcoOS_ZeroMemory(*(gctPOINTER *) Pointer, Count * gcmSIZEOF(Type))); \ + return gcvSTATUS_OK; \ +} \ + \ +gceSTATUS \ +Prefix##_Free##TypeName( \ + gcsMEM_AFS_MEM_POOL MemPool, \ + Type * Pointer \ + ) \ +{ \ + return(gcfMEM_AFSMemPoolFreeANode(MemPool, (gctPOINTER) Pointer)); \ +} + +#else + +#define gcmMEM_DeclareFSMemPool(Type, TypeName, Prefix) \ +gceSTATUS \ +Prefix##_Allocate##TypeName( \ + gcsMEM_FS_MEM_POOL MemPool, \ + Type ** Pointer \ + ) \ +{ \ + return(gcoOS_Allocate(MemPool, \ + gcmSIZEOF(Type), \ + (gctPOINTER *) Pointer)); \ +} \ + \ +gceSTATUS \ +Prefix##_CAllocate##TypeName( \ + gcsMEM_FS_MEM_POOL MemPool, \ + Type ** Pointer \ + ) \ +{ \ + gceSTATUS status; \ + gcmERR_RETURN(gcoOS_Allocate(MemPool, \ + gcmSIZEOF(Type), \ + (gctPOINTER *) Pointer)); \ + gcmVERIFY_OK(gcoOS_ZeroMemory(*(gctPOINTER *) Pointer, gcmSIZEOF(Type))); \ + return gcvSTATUS_OK; \ +} \ + \ +gceSTATUS \ +Prefix##_Free##TypeName( \ + gcsMEM_FS_MEM_POOL MemPool, \ + Type * Pointer \ + ) \ +{ \ + return(gcoOS_Free(MemPool, Pointer)); \ +} + +#define gcmMEM_DeclareVSMemPool(Type, TypeName, Prefix) \ +gceSTATUS \ +Prefix##_Allocate##TypeName( \ + gcsMEM_VS_MEM_POOL MemPool, \ + Type ** Pointer, \ + gctUINT Size \ + ) \ +{ \ + return(gcoOS_Allocate(MemPool, \ + Size, \ + (gctPOINTER *) Pointer)); \ +} \ + \ +gceSTATUS \ +Prefix##_CAllocate##TypeName( \ + gcsMEM_VS_MEM_POOL MemPool, \ + Type ** Pointer, \ + gctUINT Size \ + ) \ +{ \ + gceSTATUS status; \ + gcmERR_RETURN(gcoOS_Allocate(MemPool, \ + Size, \ + (gctPOINTER *) Pointer)); \ + gcmVERIFY_OK(gcoOS_ZeroMemory(*(gctPOINTER *) Pointer, Size)); \ + return gcvSTATUS_OK; \ +} \ + \ +gceSTATUS \ +Prefix##_Free##TypeName( \ + gcsMEM_VS_MEM_POOL MemPool, \ + Type * Pointer \ + ) \ +{ \ + return(gcoOS_Free(MemPool, Pointer)); \ +} + +#define gcmMEM_DeclareAFSMemPool(Type, TypeName, Prefix) \ +gceSTATUS \ +Prefix##_Allocate##TypeName( \ + gcsMEM_AFS_MEM_POOL MemPool, \ + Type ** Pointer, \ + gctUINT Count \ + ) \ +{ \ + return(gcoOS_Allocate(MemPool, \ + Count * gcmSIZEOF(Type), \ + (gctPOINTER *) Pointer)); \ +} \ + \ +gceSTATUS \ +Prefix##_CAllocate##TypeName( \ + gcsMEM_AFS_MEM_POOL MemPool, \ + Type ** Pointer, \ + gctUINT Count \ + ) \ +{ \ + gceSTATUS status; \ + gcmERR_RETURN(gcoOS_Allocate(MemPool, \ + Count * gcmSIZEOF(Type), \ + (gctPOINTER *) Pointer)); \ + gcmVERIFY_OK(gcoOS_ZeroMemory(*(gctPOINTER *) Pointer, Count * gcmSIZEOF(Type))); \ + return gcvSTATUS_OK; \ +} \ + \ +gceSTATUS \ +Prefix##_Free##TypeName( \ + gcsMEM_AFS_MEM_POOL MemPool, \ + Type * Pointer \ + ) \ +{ \ + return(gcoOS_Free(MemPool, Pointer)); \ +} +#endif + +/******************************************************************************* +** Memory Pool Data Functions +*******************************************************************************/ +gceSTATUS +gcfMEM_InitFSMemPool( + IN gcsMEM_FS_MEM_POOL * MemPool, + IN gcoOS OS, + IN gctUINT NodeCount, + IN gctUINT NodeSize + ); + +gceSTATUS +gcfMEM_FreeFSMemPool( + IN gcsMEM_FS_MEM_POOL * MemPool + ); + +gceSTATUS +gcfMEM_FSMemPoolGetANode( + IN gcsMEM_FS_MEM_POOL MemPool, + OUT gctPOINTER * Node + ); + +gceSTATUS +gcfMEM_FSMemPoolFreeANode( + IN gcsMEM_FS_MEM_POOL MemPool, + IN gctPOINTER Node + ); + +gceSTATUS +gcfMEM_FSMemPoolFreeAList( + IN gcsMEM_FS_MEM_POOL MemPool, + IN gctPOINTER FirstNode, + IN gctPOINTER LastNode + ); + +gceSTATUS +gcfMEM_InitVSMemPool( + IN gcsMEM_VS_MEM_POOL * MemPool, + IN gcoOS OS, + IN gctUINT BlockSize, + IN gctBOOL RecycleFreeNode + ); + +gceSTATUS +gcfMEM_FreeVSMemPool( + IN gcsMEM_VS_MEM_POOL * MemPool + ); + +gceSTATUS +gcfMEM_VSMemPoolGetANode( + IN gcsMEM_VS_MEM_POOL MemPool, + IN gctUINT Size, + IN gctUINT Alignment, + OUT gctPOINTER * Node + ); + +gceSTATUS +gcfMEM_VSMemPoolFreeANode( + IN gcsMEM_VS_MEM_POOL MemPool, + IN gctPOINTER Node + ); + +gceSTATUS +gcfMEM_InitAFSMemPool( + IN gcsMEM_AFS_MEM_POOL *MemPool, + IN gcoOS OS, + IN gctUINT NodeCount, + IN gctUINT NodeSize + ); + +gceSTATUS +gcfMEM_FreeAFSMemPool( + IN gcsMEM_AFS_MEM_POOL *MemPool + ); + +gceSTATUS +gcfMEM_AFSMemPoolGetANode( + IN gcsMEM_AFS_MEM_POOL MemPool, + IN gctUINT Count, + OUT gctPOINTER * Node + ); + +gceSTATUS +gcfMEM_AFSMemPoolFreeANode( + IN gcsMEM_AFS_MEM_POOL MemPool, + IN gctPOINTER Node + ); + +#ifdef __cplusplus +} +#endif + +#endif /* __gc_hal_mem_h_ */ + diff --git a/native/include_dove/gc_hal_options.h b/native/include_dove/gc_hal_options.h new file mode 100644 index 0000000..b9749f4 --- /dev/null +++ b/native/include_dove/gc_hal_options.h @@ -0,0 +1,532 @@ +/**************************************************************************** +* +* Copyright (C) 2005 - 2010 by Vivante Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the license, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +* +*****************************************************************************/ + + + + +#ifndef __gc_hal_options_h_ +#define __gc_hal_options_h_ + +/* + USE_NEW_LINUX_SIGNAL + + This define enables the Linux kernel signaling between kernel and user. +*/ +#ifndef USE_NEW_LINUX_SIGNAL +# define USE_NEW_LINUX_SIGNAL 0 +#endif + +/* + NO_USER_DIRECT_ACCESS_FROM_KERNEL + + This define enables the Linux kernel behavior accessing user memory. +*/ +#ifndef NO_USER_DIRECT_ACCESS_FROM_KERNEL +# define NO_USER_DIRECT_ACCESS_FROM_KERNEL 0 +#endif + +/* + VIVANTE_PROFILER + + This define enables the profiler. +*/ +#ifndef VIVANTE_PROFILER +# define VIVANTE_PROFILER 0 +#endif + +/* + gcdUSE_VG + + Enable VG HAL layer (only for GC350). +*/ +#ifndef gcdUSE_VG +# define gcdUSE_VG 0 +#endif + +/* + USE_SW_FB + + Set to 1 if the frame buffer memory cannot be accessed by the GPU. +*/ +#ifndef USE_SW_FB +#define USE_SW_FB 0 +#endif + +/* + USE_SHADER_SYMBOL_TABLE + + This define enables the symbol table in shader object. +*/ +#define USE_SHADER_SYMBOL_TABLE 1 + +/* + USE_SUPER_SAMPLING + + This define enables super-sampling support. +*/ +#define USE_SUPER_SAMPLING 0 + +/* + PROFILE_HAL_COUNTERS + + This define enables HAL counter profiling support. + HW and SHADER Counter profiling depends on this. +*/ +#define PROFILE_HAL_COUNTERS 1 + +/* + PROFILE_HW_COUNTERS + + This define enables HW counter profiling support. +*/ +#define PROFILE_HW_COUNTERS 1 + +/* + PROFILE_SHADER_COUNTERS + + This define enables SHADER counter profiling support. +*/ +#define PROFILE_SHADER_COUNTERS 1 + +/* + COMMAND_PROCESSOR_VERSION + + The version of the command buffer and task manager. +*/ +#define COMMAND_PROCESSOR_VERSION 1 + +/* + gcdDUMP + + When set to 1, a dump of all states and memory uploads, as well as other + hardware related execution will be printed to the debug console. This + data can be used for playing back applications. +*/ +#define gcdDUMP 0 + +/* + gcdDUMP_API + + When set to 1, a high level dump of the EGL and GL/VG APs's are + captured. +*/ +#define gcdDUMP_API 0 + +/* + gcdDUMP_IN_KERNEL + + When set to 1, all dumps will happen in the kernel. This is handy if + you want the kernel to dump its command buffers as well and the data + needs to be in sync. +*/ +#define gcdDUMP_IN_KERNEL 0 + +/* + gcdDUMP_COMMAND + + When set to non-zero, the command queue will dump all incoming command + and context buffers as well as all other modifications to the command + queue. +*/ +#define gcdDUMP_COMMAND 0 + +/* + gcdNULL_DRIVER +*/ +#define gcdNULL_DRIVER 0 + +/* + gcdENABLE_TIMEOUT_DETECTION + + Enable timeout detection. +*/ +#define gcdENABLE_TIMEOUT_DETECTION 0 + +/* + gcdCMD_BUFFERS + + Number of command buffers to use per client. Each command buffer is 32kB in + size. +*/ +#define gcdCMD_BUFFERS 2 + +/* + gcdPOWER_CONTROL_DELAY + + The delay in milliseconds required to wait until the GPU has woke up from a + suspend or power-down state. This is system dependent because the bus clock + also needs to be stabalize. +*/ +#define gcdPOWER_CONTROL_DELAY 1 + +/* + gcdMMU_SIZE + + Size of the MMU page table in bytes. Each 4 bytes can hold 4kB worth of + virtual data. +*/ +#define gcdMMU_SIZE (128 << 10) + +/* + gcdSECURE_USER + + Use logical addresses instead of physical addresses in user land. In this + case a hint table is created for both command buffers and context buffers, + and that hint table will be used to patch up those buffers in the kernel + when they are ready to submit. +*/ +#define gcdSECURE_USER 0 + +/* + gcdSECURE_CACHE_SLOTS + + Number of slots in the logical to DMA address cache table. Each time a + logical address needs to be translated into a DMA address for the GPU, this + cache will be walked. The replacement scheme is LRU. +*/ +#define gcdSECURE_CACHE_SLOTS 64 + +/* + gcdREGISTER_ACCESS_FROM_USER + + Set to 1 to allow IOCTL calls to get through from user land. This should + only be in debug or development drops. +*/ +#ifndef gcdREGISTER_ACCESS_FROM_USER +# define gcdREGISTER_ACCESS_FROM_USER 1 +#endif + +/* + gcdHEAP_SIZE + + Set the allocation size for the internal heaps. Each time a heap is full, + a new heap will be allocated with this minmimum amount of bytes. The bigger + this size, the fewer heaps there are to allocate, the better the + performance. However, heaps won't be freed until they are completely free, + so there might be some more memory waste if the size is too big. +*/ +#define gcdHEAP_SIZE (64 << 10) +/* + MRVL_TAVOR_PV2_DISABLE_YFLIP +*/ +#define MRVL_TAVOR_PV2_DISABLE_YFLIP 0 + +/* + gcdNO_POWER_MANAGEMENT + + This define disables the power management code. +*/ +#ifndef gcdNO_POWER_MANAGEMENT +# define gcdNO_POWER_MANAGEMENT 0 +#endif + +/* + VIVANTE_POWER_MANAGE + + This define enable the vivante power management code. +*/ +#ifndef VIVANTE_POWER_MANAGE +# define VIVANTE_POWER_MANAGE 1 +#endif +/* + gcdFPGA_BUILD + + This define enables work arounds for FPGA images. +*/ +#if !defined(gcdFPGA_BUILD) +# define gcdFPGA_BUILD 0 +#endif + +/* + gcdGPU_TIMEOUT + + This define specified the number of milliseconds the system will wait before + it broadcasts the GPU is stuck. In other words, it will define the timeout + of any operation that needs to wait for the GPU. + + If the value is 0, no timeout will be checked for. +*/ +#if !defined(gcdGPU_TIMEOUT) +# define gcdGPU_TIMEOUT 0 +#endif + +/* + * MACRO definition of MRVL + */ +#ifdef CONFIG_CPU_PXA910 +#define MRVL_PLATFORM_TD 1 +#else +#define MRVL_PLATFORM_TD 0 +#endif + +#ifdef CONFIG_PXA95x +#define MRVL_PLATFORM_MG1 1 +#else +#define MRVL_PLATFORM_MG1 0 +#endif + +#ifdef CONFIG_CPU_MMP2 +#define MRVL_PLATFORM_MMP2 1 +#else +#define MRVL_PLATFORM_MMP2 0 +#endif + +#if (defined CONFIG_DVFM) && (defined CONFIG_DVFM_PXA910) +#define MRVL_CONFIG_DVFM_TD 1 +#else +#define MRVL_CONFIG_DVFM_TD 0 +#endif + +#ifdef CONFIG_PXA95x +#define MRVL_CONFIG_DVFM_MG1 1 +#else +#define MRVL_CONFIG_DVFM_MG1 0 +#endif + +#if (defined CONFIG_DVFM) && (defined CONFIG_DVFM_MMP2) +#define MRVL_CONFIG_DVFM_MMP2 1 +#else +#define MRVL_CONFIG_DVFM_MMP2 0 +#endif + +/* + MRVL_LOW_POWER_MODE_DEBUG +*/ +#define MRVL_LOW_POWER_MODE_DEBUG 0 + +/* + MRVL Utility Options +*/ +#define MRVL_FORCE_MSAA_ON 0 + +/* + MRVL_SWAP_BUFFER_IN_EVERY_DRAW + + This define force swapbuffer after every drawElement/drawArray. +*/ +#define MRVL_SWAP_BUFFER_IN_EVERY_DRAW 0 + +#ifndef MRVL_BENCH +# define MRVL_BENCH 0 +#endif + +#define MRVL_EANBLE_COMPRESSION_DXT 0 + +/* Texture coordinate generation */ +#define MRVL_TEXGEN 1 + +/* Tex gen code from Vivante */ +#define VIVANTE_TEXGEN 0 + +/* Swap buffer optimization */ +#define MRVL_OPTI_SWAP_BUFFER 1 + +/* Disable swap worker thread */ +#define MRVL_DISABLE_SWAP_THREAD 1 + +/* API log enable */ +#define MRVL_ENABLE_ERROR_LOG 1 +#define MRVL_ENABLE_API_LOG 0 +#define MRVL_ENABLE_EGL_API_LOG 0 +#define MRVL_ENABLE_OES1_API_LOG 0 +#define MRVL_ENABLE_OES2_API_LOG 0 +#define MRVL_ENABLE_OVG_API_LOG 0 + +/* enable it can dump logs to file + * for android can stop dump by "setprop marvell.graphics.dump_log 0" +*/ +#define MRVL_DUMP_LOG_TO_FILE 0 + +/* Optimization for Eclair UI */ +#define MRVL_OPTI_ANDROID_IMAGE 1 + +/* if pmem is enabled and cacheable, enable it */ +#define MRVL_CACHEABLE_PMEM 1 + +#define MRVL_DISABLE_FASTCLEAR 0 + +#define MRVL_OPTI_COMPOSITOR 1 +#define MRVL_OPTI_COMPOSITOR_DEBUG 0 +#define MRVL_READ_PIXEL_2D 1 +#define MRVL_2D_SKIP_CONTEXT 0 +#define MRVL_2D_FORCE_FILTER_UPLOAD 1 + + +#define MRVL_OPTI_STREAM_FAST_PATH 1 +#define MRVL_OPTI_USE_RESERVE_MEMORY 1 + +/* Enable user mode heap allocation + * if enable, all internal structure should be allocated from pre-allocated heap + * if disable, all internal structure should be allocated by malloc directly + */ +#define MRVL_ENABLE_USERMODE_HEAP_ALLOCATION 0 + + +/* Enable a timer thread to check the status of GC periodically */ +#define MRVL_TIMER 0 + +/* Enable a idle profiling thread to turn off GC when idle */ +#if (MRVL_PLATFORM_TD || MRVL_PLATFORM_MG1 || MRVL_PLATFORM_MMP2) && (defined ANDROID) +#define MRVL_PROFILE_THREAD 1 +#else +#define MRVL_PROFILE_THREAD 0 +#endif + +/* Enable a guard thread to check the status of GC */ +#if (MRVL_PLATFORM_TD || MRVL_PLATFORM_MG1) && (defined ANDROID) +#define MRVL_GUARD_THREAD 1 +#define MRVL_PRINT_CMD_BUFFER 1 +#else +#define MRVL_GUARD_THREAD 0 +#define MRVL_PRINT_CMD_BUFFER 0 +#endif + +/* Power -- Enable clock gating */ +#define MRVL_ENABLE_CLOCK_GATING 1 + +/* Power -- Enable frequency scaling */ +#define MRVL_ENABLE_FREQ_SCALING 1 + +/* Enable dvfm control for certain platform */ +#if MRVL_CONFIG_DVFM_MG1 || MRVL_CONFIG_DVFM_MMP2 +#define MRVL_CONFIG_ENABLE_DVFM 1 +#else +#define MRVL_CONFIG_ENABLE_DVFM 0 +#endif + +/* Separate GC clk and power on/off */ +#if (MRVL_PLATFORM_TD || MRVL_PLATFORM_MG1) +#define SEPARATE_CLOCK_AND_POWER 1 +#define KEEP_POWER_ON 0 +#else +#define SEPARATE_CLOCK_AND_POWER 0 +#endif + +/* Enable control of AXI bus clock */ +#if MRVL_PLATFORM_MG1 +#define MRVL_CONFIG_AXICLK_CONTROL 1 +#else +#define MRVL_CONFIG_AXICLK_CONTROL 0 +#endif + +/* Enable early-suspend related functions */ +#if (defined CONFIG_HAS_EARLYSUSPEND) && (defined CONFIG_EARLYSUSPEND) +#define MRVL_CONFIG_ENABLE_EARLYSUSPEND 1 +#else +#define MRVL_CONFIG_ENABLE_EARLYSUSPEND 0 +#endif + +/* Enable BSP runtime or idle profile */ +#if (defined CONFIG_PXA910_DVFM_STATS) +#define ENABLE_BSP_IDLE_PROFILE 1 +#else +#define ENABLE_BSP_IDLE_PROFILE 0 +#endif + +/* Force surface format RGBA8888*/ +#define MRVL_FORCE_8888 0 + + +/* Preserve cmd buffer space to avoid unneeded split(then context switch */ +#define MRVL_PRESERVE_CMD_BUFFER 1 + +/* + Record texture in command buffer for it idle or not +*/ +#define MRVL_TEXTURE_USED_LIST 0 + +/* + simple wait vsync +*/ +#define MRVL_SIMPLE_WAIT_VSYNC 0 + +/* + * to decrese mov instruction + */ +#define MRVL_OPTIMIZE_LIGHT_MOV 0 + +/* + * for eglSwapInterval in Android + */ +#define MRVL_ANDROID_VSYNC_INTERVAL 1 + +/* for speed up texture lookup + * + */ +#define MRVL_OPT_TEXTURE_LOOKUP 1 + +/* + * skip unnecessary texture attribute validate + */ +#define MRVL_TEXTURE_VALIDATE_OPT 1 + +/* + * New Back Copy Propagation Optimization + */ +#define MRVL_NEW_BCP_OPT 1 + +/* + * VBO dirty patch Optimization + */ +#define MRVL_VBO_DIRTY_PATCH 1 + +/* + * Pre-allocated context buffers and reuse them + */ +#define MRVL_PRE_ALLOCATE_CTX_BUFFER 1 + +#if MRVL_PRE_ALLOCATE_CTX_BUFFER +/* Minimal number of context buffers. +* Can't be less than 2, or it can't get the signal when wait. +*/ +#define gcdCTXBUF_SIZE_MIN 2 +/* +* Number of context buffers to use per client by default. +*/ +#define gcdCTXBUF_SIZE_DEFAULT 10 +#endif + +/* + * Remove image texture surface to save video memory on 2d path. + */ +#define MRVL_MEM_OPT 1 + +/* + Definitions for vendor, renderer and version strings +*/ + +#define _VENDOR_STRING_ "Marvell Technology Group Ltd" + +#define _EGL_VERSION_STRING_ "EGL 1.3"; + +#if defined(COMMON_LITE) +#define _OES11_VERSION_STRING_ "OpenGL ES-CL 1.1"; +#else +#define _OES11_VERSION_STRING_ "OpenGL ES-CM 1.1"; +#endif + +#define _OES20_VERSION_STRING_ "OpenGL ES 2.0"; +#define _GLSL_ES_VERSION_STRING_ "OpenGL ES GLSL ES 1.00" + +#define _OPENVG_VERSION_STRING_ "OpenVG 1.1" + +#define _GC_VERSION_STRING_ "GC Ver0.8.0.3184-1" + +#endif /* __gc_hal_options_h_ */ diff --git a/native/include_dove/gc_hal_profiler.h b/native/include_dove/gc_hal_profiler.h new file mode 100644 index 0000000..4373215 --- /dev/null +++ b/native/include_dove/gc_hal_profiler.h @@ -0,0 +1,221 @@ +/**************************************************************************** +* +* Copyright (C) 2005 - 2010 by Vivante Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the license, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +* +*****************************************************************************/ + + +#ifndef __gc_hal_profiler_h_ +#define __gc_hal_profiler_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define GLVERTEX_OBJECT 10 +#define GLVERTEX_OBJECT_BYTES 11 + +#define GLINDEX_OBJECT 20 +#define GLINDEX_OBJECT_BYTES 21 + +#define GLTEXTURE_OBJECT 30 +#define GLTEXTURE_OBJECT_BYTES 31 + +#if VIVANTE_PROFILER +#define gcmPROFILE_GC(Hal, Enum, Value) gcoPROFILER_Count(Hal, Enum, Value) +#else +#define gcmPROFILE_GC(Hal, Enum, Value) do { } while (gcvFALSE) +#endif + +/* HW profile information. */ +typedef struct _gcsPROFILER_COUNTERS +{ + /* HW static counters. */ + gctUINT32 gpuClock; + gctUINT32 axiClock; + gctUINT32 shaderClock; + + /* HW vairable counters. */ + gctUINT32 gpuClockStart; + gctUINT32 gpuClockEnd; + + /* HW vairable counters. */ + gctUINT32 gpuCyclesCounter; + gctUINT32 gpuTotalRead64BytesPerFrame; + gctUINT32 gpuTotalWrite64BytesPerFrame; + + /* PE */ + gctUINT32 pe_pixel_count_killed_by_color_pipe; + gctUINT32 pe_pixel_count_killed_by_depth_pipe; + gctUINT32 pe_pixel_count_drawn_by_color_pipe; + gctUINT32 pe_pixel_count_drawn_by_depth_pipe; + + /* SH */ + gctUINT32 ps_inst_counter; + gctUINT32 rendered_pixel_counter; + gctUINT32 vs_inst_counter; + gctUINT32 rendered_vertice_counter; + gctUINT32 vtx_branch_inst_counter; + gctUINT32 vtx_texld_inst_counter; + gctUINT32 pxl_branch_inst_counter; + gctUINT32 pxl_texld_inst_counter; + + /* PA */ + gctUINT32 pa_input_vtx_counter; + gctUINT32 pa_input_prim_counter; + gctUINT32 pa_output_prim_counter; + gctUINT32 pa_depth_clipped_counter; + gctUINT32 pa_trivial_rejected_counter; + gctUINT32 pa_culled_counter; + + /* SE */ + gctUINT32 se_culled_triangle_count; + gctUINT32 se_culled_lines_count; + + /* RA */ + gctUINT32 ra_valid_pixel_count; + gctUINT32 ra_total_quad_count; + gctUINT32 ra_valid_quad_count_after_early_z; + gctUINT32 ra_total_primitive_count; + gctUINT32 ra_pipe_cache_miss_counter; + gctUINT32 ra_prefetch_cache_miss_counter; + gctUINT32 ra_eez_culled_counter; + + /* TX */ + gctUINT32 tx_total_bilinear_requests; + gctUINT32 tx_total_trilinear_requests; + gctUINT32 tx_total_discarded_texture_requests; + gctUINT32 tx_total_texture_requests; + gctUINT32 tx_mem_read_count; + gctUINT32 tx_mem_read_in_8B_count; + gctUINT32 tx_cache_miss_count; + gctUINT32 tx_cache_hit_texel_count; + gctUINT32 tx_cache_miss_texel_count; + + /* MC */ + gctUINT32 mc_total_read_req_8B_from_pipeline; + gctUINT32 mc_total_read_req_8B_from_IP; + gctUINT32 mc_total_write_req_8B_from_pipeline; + + /* HI */ + gctUINT32 hi_axi_cycles_read_request_stalled; + gctUINT32 hi_axi_cycles_write_request_stalled; + gctUINT32 hi_axi_cycles_write_data_stalled; +} +gcsPROFILER_COUNTERS; + +/* HAL profile information. */ +typedef struct _gcsPROFILER +{ + gctFILE file; + + /* Aggregate Information */ + + /* Clock Info */ + gctUINT64 frameStart; + + /* Current frame information */ + gctUINT32 frameNumber; + gctUINT64 frameStartTimeusec; + +#if PROFILE_HAL_COUNTERS + gctUINT32 vertexBufferTotalBytesAlloc; + gctUINT32 vertexBufferNewBytesAlloc; + int vertexBufferTotalObjectsAlloc; + int vertexBufferNewObjectsAlloc; + + gctUINT32 indexBufferTotalBytesAlloc; + gctUINT32 indexBufferNewBytesAlloc; + int indexBufferTotalObjectsAlloc; + int indexBufferNewObjectsAlloc; + + gctUINT32 textureBufferTotalBytesAlloc; + gctUINT32 textureBufferNewBytesAlloc; + int textureBufferTotalObjectsAlloc; + int textureBufferNewObjectsAlloc; + +#endif +} +gcsPROFILER; + +/* Memory profile information. */ +struct _gcsMemProfile +{ + /* Memory Usage */ + gctUINT32 videoMemUsed; + gctUINT32 systemMemUsed; + gctUINT32 commitBufferSize; + gctUINT32 contextBufferCopyBytes; +}; + +/* Shader profile information. */ +struct _gcsSHADER_PROFILER +{ + gctUINT32 shaderLength; + gctUINT32 shaderALUCycles; + gctUINT32 shaderTexLoadCycles; + gctUINT32 shaderTempRegCount; + gctUINT32 shaderSamplerRegCount; + gctUINT32 shaderInputRegCount; + gctUINT32 shaderOutputRegCount; +}; + +/* Initialize the gcsProfiler. */ +gceSTATUS +gcoPROFILER_Initialize( + IN gcoHAL Hal, + IN gctFILE File + ); + +/* Destroy the gcProfiler. */ +gceSTATUS +gcoPROFILER_Destroy( + IN gcoHAL Hal + ); + +/* Call to signal end of frame. */ +gceSTATUS +gcoPROFILER_EndFrame( + IN gcoHAL Hal + ); + +gceSTATUS +gcoPROFILER_Count( + IN gcoHAL Hal, + IN gctUINT32 Enum, + IN gctINT Value + ); + +/* Profile input vertex shader. */ +gceSTATUS +gcoPROFILER_ShaderVS( + IN gcoHAL Hal, + IN gctPOINTER Vs + ); + +/* Profile input fragment shader. */ +gceSTATUS +gcoPROFILER_ShaderFS( + IN gcoHAL Hal, + IN gctPOINTER Fs + ); + +#ifdef __cplusplus +} +#endif + +#endif /* __gc_hal_profiler_h_ */ diff --git a/native/include_dove/gc_hal_raster.h b/native/include_dove/gc_hal_raster.h new file mode 100644 index 0000000..23485a2 --- /dev/null +++ b/native/include_dove/gc_hal_raster.h @@ -0,0 +1,807 @@ +/**************************************************************************** +* +* Copyright (C) 2005 - 2010 by Vivante Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the license, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +* +*****************************************************************************/ + + + + +#ifndef __gc_hal_raster_h_ +#define __gc_hal_raster_h_ + +#include "gc_hal_enum.h" +#include "gc_hal_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/******************************************************************************\ +****************************** Object Declarations ***************************** +\******************************************************************************/ + +typedef struct _gcoBRUSH * gcoBRUSH; +typedef struct _gcoBRUSH_CACHE * gcoBRUSH_CACHE; + +/******************************************************************************\ +******************************** gcoBRUSH Object ******************************* +\******************************************************************************/ + +/* Create a new solid color gcoBRUSH object. */ +gceSTATUS +gcoBRUSH_ConstructSingleColor( + IN gcoHAL Hal, + IN gctUINT32 ColorConvert, + IN gctUINT32 Color, + IN gctUINT64 Mask, + gcoBRUSH * Brush + ); + +/* Create a new monochrome gcoBRUSH object. */ +gceSTATUS +gcoBRUSH_ConstructMonochrome( + IN gcoHAL Hal, + IN gctUINT32 OriginX, + IN gctUINT32 OriginY, + IN gctUINT32 ColorConvert, + IN gctUINT32 FgColor, + IN gctUINT32 BgColor, + IN gctUINT64 Bits, + IN gctUINT64 Mask, + gcoBRUSH * Brush + ); + +/* Create a color gcoBRUSH object. */ +gceSTATUS +gcoBRUSH_ConstructColor( + IN gcoHAL Hal, + IN gctUINT32 OriginX, + IN gctUINT32 OriginY, + IN gctPOINTER Address, + IN gceSURF_FORMAT Format, + IN gctUINT64 Mask, + gcoBRUSH * Brush + ); + +/* Destroy an gcoBRUSH object. */ +gceSTATUS +gcoBRUSH_Destroy( + IN gcoBRUSH Brush + ); + +/******************************************************************************\ +******************************** gcoSURF Object ******************************* +\******************************************************************************/ + +/* Set cipping rectangle. */ +gceSTATUS +gcoSURF_SetClipping( + IN gcoSURF Surface + ); + +/* Clear one or more rectangular areas. */ +gceSTATUS +gcoSURF_Clear2D( + IN gcoSURF DestSurface, + IN gctUINT32 RectCount, + IN gcsRECT_PTR DestRect, + IN gctUINT32 LoColor, + IN gctUINT32 HiColor + ); + +/* Draw one or more Bresenham lines. */ +gceSTATUS +gcoSURF_Line( + IN gcoSURF Surface, + IN gctUINT32 LineCount, + IN gcsRECT_PTR Position, + IN gcoBRUSH Brush, + IN gctUINT8 FgRop, + IN gctUINT8 BgRop + ); + +/* Generic rectangular blit. */ +gceSTATUS +gcoSURF_Blit( + IN OPTIONAL gcoSURF SrcSurface, + IN gcoSURF DestSurface, + IN gctUINT32 RectCount, + IN OPTIONAL gcsRECT_PTR SrcRect, + IN gcsRECT_PTR DestRect, + IN OPTIONAL gcoBRUSH Brush, + IN gctUINT8 FgRop, + IN gctUINT8 BgRop, + IN OPTIONAL gceSURF_TRANSPARENCY Transparency, + IN OPTIONAL gctUINT32 TransparencyColor, + IN OPTIONAL gctPOINTER Mask, + IN OPTIONAL gceSURF_MONOPACK MaskPack + ); + +/* Monochrome blit. */ +gceSTATUS +gcoSURF_MonoBlit( + IN gcoSURF DestSurface, + IN gctPOINTER Source, + IN gceSURF_MONOPACK SourcePack, + IN gcsPOINT_PTR SourceSize, + IN gcsPOINT_PTR SourceOrigin, + IN gcsRECT_PTR DestRect, + IN OPTIONAL gcoBRUSH Brush, + IN gctUINT8 FgRop, + IN gctUINT8 BgRop, + IN gctBOOL ColorConvert, + IN gctUINT8 MonoTransparency, + IN gceSURF_TRANSPARENCY Transparency, + IN gctUINT32 FgColor, + IN gctUINT32 BgColor + ); + +/* Filter blit. */ +gceSTATUS +gcoSURF_FilterBlit( + IN gcoSURF SrcSurface, + IN gcoSURF DestSurface, + IN gcsRECT_PTR SrcRect, + IN gcsRECT_PTR DestRect, + IN gcsRECT_PTR DestSubRect + ); + +/* Enable alpha blending engine in the hardware and disengage the ROP engine. */ +gceSTATUS +gcoSURF_EnableAlphaBlend( + IN gcoSURF Surface, + IN gctUINT8 SrcGlobalAlphaValue, + IN gctUINT8 DstGlobalAlphaValue, + IN gceSURF_PIXEL_ALPHA_MODE SrcAlphaMode, + IN gceSURF_PIXEL_ALPHA_MODE DstAlphaMode, + IN gceSURF_GLOBAL_ALPHA_MODE SrcGlobalAlphaMode, + IN gceSURF_GLOBAL_ALPHA_MODE DstGlobalAlphaMode, + IN gceSURF_BLEND_FACTOR_MODE SrcFactorMode, + IN gceSURF_BLEND_FACTOR_MODE DstFactorMode, + IN gceSURF_PIXEL_COLOR_MODE SrcColorMode, + IN gceSURF_PIXEL_COLOR_MODE DstColorMode + ); + +/* Disable alpha blending engine in the hardware and engage the ROP engine. */ +gceSTATUS +gcoSURF_DisableAlphaBlend( + IN gcoSURF Surface + ); + +/* Copy a rectangular area with format conversion. */ +gceSTATUS +gcoSURF_CopyPixels( + IN gcoSURF Source, + IN gcoSURF Target, + IN gctINT SourceX, + IN gctINT SourceY, + IN gctINT TargetX, + IN gctINT TargetY, + IN gctINT Width, + IN gctINT Height + ); + +/* Read surface pixel. */ +gceSTATUS +gcoSURF_ReadPixel( + IN gcoSURF Surface, + IN gctPOINTER Memory, + IN gctINT X, + IN gctINT Y, + IN gceSURF_FORMAT Format, + OUT gctPOINTER PixelValue + ); + +/* Write surface pixel. */ +gceSTATUS +gcoSURF_WritePixel( + IN gcoSURF Surface, + IN gctPOINTER Memory, + IN gctINT X, + IN gctINT Y, + IN gceSURF_FORMAT Format, + IN gctPOINTER PixelValue + ); + +/******************************************************************************\ +********************************** gco2D Object ********************************* +\******************************************************************************/ + +/* Construct a new gco2D object. */ +gceSTATUS +gco2D_Construct( + IN gcoHAL Hal, + OUT gco2D * Hardware + ); + +/* Destroy an gco2D object. */ +gceSTATUS +gco2D_Destroy( + IN gco2D Hardware + ); + + +/* Start and end of gco2D draws */ +gceSTATUS +gco2D_Begin( + IN gco2D Engine, + IN gctUINT cmdSize + ); + +gceSTATUS +gco2D_End( + IN gco2D Engine + ); + + + +/* Sets the maximum number of brushes in the brush cache. */ +gceSTATUS +gco2D_SetBrushLimit( + IN gco2D Hardware, + IN gctUINT MaxCount + ); + +/* Flush the brush. */ +gceSTATUS +gco2D_FlushBrush( + IN gco2D Engine, + IN gcoBRUSH Brush, + IN gceSURF_FORMAT Format + ); + +/* Program the specified solid color brush. */ +gceSTATUS +gco2D_LoadSolidBrush( + IN gco2D Engine, + IN gceSURF_FORMAT Format, + IN gctUINT32 ColorConvert, + IN gctUINT32 Color, + IN gctUINT64 Mask + ); + +/* Configure monochrome source. */ +gceSTATUS +gco2D_SetMonochromeSource( + IN gco2D Engine, + IN gctBOOL ColorConvert, + IN gctUINT8 MonoTransparency, + IN gceSURF_MONOPACK DataPack, + IN gctBOOL CoordRelative, + IN gceSURF_TRANSPARENCY Transparency, + IN gctUINT32 FgColor, + IN gctUINT32 BgColor + ); + +/* Configure color source. */ +gceSTATUS +gco2D_SetColorSource( + IN gco2D Engine, + IN gctUINT32 Address, + IN gctUINT32 Stride, + IN gceSURF_FORMAT Format, + IN gceSURF_ROTATION Rotation, + IN gctUINT32 SurfaceWidth, + IN gctBOOL CoordRelative, + IN gceSURF_TRANSPARENCY Transparency, + IN gctUINT32 TransparencyColor + ); + +/* Configure color source extension for full rotation. */ +gceSTATUS +gco2D_SetColorSourceEx( + IN gco2D Engine, + IN gctUINT32 Address, + IN gctUINT32 Stride, + IN gceSURF_FORMAT Format, + IN gceSURF_ROTATION Rotation, + IN gctUINT32 SurfaceWidth, + IN gctUINT32 SurfaceHeight, + IN gctBOOL CoordRelative, + IN gceSURF_TRANSPARENCY Transparency, + IN gctUINT32 TransparencyColor + ); + +/* Configure color source. */ +gceSTATUS +gco2D_SetColorSourceAdvanced( + IN gco2D Engine, + IN gctUINT32 Address, + IN gctUINT32 Stride, + IN gceSURF_FORMAT Format, + IN gceSURF_ROTATION Rotation, + IN gctUINT32 SurfaceWidth, + IN gctUINT32 SurfaceHeight, + IN gctBOOL CoordRelative + ); + +/* Configure masked color source. */ +gceSTATUS +gco2D_SetMaskedSource( + IN gco2D Engine, + IN gctUINT32 Address, + IN gctUINT32 Stride, + IN gceSURF_FORMAT Format, + IN gctBOOL CoordRelative, + IN gceSURF_MONOPACK MaskPack + ); + +/* Configure masked color source extension for full rotation. */ +gceSTATUS +gco2D_SetMaskedSourceEx( + IN gco2D Engine, + IN gctUINT32 Address, + IN gctUINT32 Stride, + IN gceSURF_FORMAT Format, + IN gctBOOL CoordRelative, + IN gceSURF_MONOPACK MaskPack, + IN gceSURF_ROTATION Rotation, + IN gctUINT32 SurfaceWidth, + IN gctUINT32 SurfaceHeight + ); + +/* Setup the source rectangle. */ +gceSTATUS +gco2D_SetSource( + IN gco2D Engine, + IN gcsRECT_PTR SrcRect + ); + +/* Set clipping rectangle. */ +gceSTATUS +gco2D_SetClipping( + IN gco2D Engine, + IN gcsRECT_PTR Rect + ); + +/* Configure destination. */ +gceSTATUS +gco2D_SetTarget( + IN gco2D Engine, + IN gctUINT32 Address, + IN gctUINT32 Stride, + IN gceSURF_ROTATION Rotation, + IN gctUINT32 SurfaceWidth + ); + +/* Configure destination extension for full rotation. */ +gceSTATUS +gco2D_SetTargetEx( + IN gco2D Engine, + IN gctUINT32 Address, + IN gctUINT32 Stride, + IN gceSURF_ROTATION Rotation, + IN gctUINT32 SurfaceWidth, + IN gctUINT32 SurfaceHeight + ); + +/* Calculate and program the stretch factors. */ +gceSTATUS +gco2D_SetStretchFactors( + IN gco2D Engine, + IN gctUINT32 HorFactor, + IN gctUINT32 VerFactor + ); + +/* Calculate and program the stretch factors based on the rectangles. */ +gceSTATUS +gco2D_SetStretchRectFactors( + IN gco2D Engine, + IN gcsRECT_PTR SrcRect, + IN gcsRECT_PTR DestRect + ); + +/* Create a new solid color gcoBRUSH object. */ +gceSTATUS +gco2D_ConstructSingleColorBrush( + IN gco2D Engine, + IN gctUINT32 ColorConvert, + IN gctUINT32 Color, + IN gctUINT64 Mask, + gcoBRUSH * Brush + ); + +/* Create a new monochrome gcoBRUSH object. */ +gceSTATUS +gco2D_ConstructMonochromeBrush( + IN gco2D Engine, + IN gctUINT32 OriginX, + IN gctUINT32 OriginY, + IN gctUINT32 ColorConvert, + IN gctUINT32 FgColor, + IN gctUINT32 BgColor, + IN gctUINT64 Bits, + IN gctUINT64 Mask, + gcoBRUSH * Brush + ); + +/* Create a color gcoBRUSH object. */ +gceSTATUS +gco2D_ConstructColorBrush( + IN gco2D Engine, + IN gctUINT32 OriginX, + IN gctUINT32 OriginY, + IN gctPOINTER Address, + IN gceSURF_FORMAT Format, + IN gctUINT64 Mask, + gcoBRUSH * Brush + ); + +/* Clear one or more rectangular areas. */ +gceSTATUS +gco2D_Clear( + IN gco2D Engine, + IN gctUINT32 RectCount, + IN gcsRECT_PTR Rect, + IN gctUINT32 Color32, + IN gctUINT8 FgRop, + IN gctUINT8 BgRop, + IN gceSURF_FORMAT DestFormat + ); + +gceSTATUS +gco2D_ClearEx( + IN gco2D Engine, + IN gctUINT32 RectCount, + IN gcsRECT_PTR Rect, + IN gctUINT32 Color32, + IN gctUINT8 FgRop, + IN gctUINT8 BgRop, + IN gceSURF_FORMAT DestFormat + ); + +/* Draw one or more Bresenham lines. */ +gceSTATUS +gco2D_Line( + IN gco2D Engine, + IN gctUINT32 LineCount, + IN gcsRECT_PTR Position, + IN gcoBRUSH Brush, + IN gctUINT8 FgRop, + IN gctUINT8 BgRop, + IN gceSURF_FORMAT DestFormat + ); + +/* Draw one or more Bresenham lines based on the 32-bit color. */ +gceSTATUS +gco2D_ColorLine( + IN gco2D Engine, + IN gctUINT32 LineCount, + IN gcsRECT_PTR Position, + IN gctUINT32 Color32, + IN gctUINT8 FgRop, + IN gctUINT8 BgRop, + IN gceSURF_FORMAT DestFormat + ); + +/* Generic blit. */ +gceSTATUS +gco2D_Blit( + IN gco2D Engine, + IN gctUINT32 RectCount, + IN gcsRECT_PTR Rect, + IN gctUINT8 FgRop, + IN gctUINT8 BgRop, + IN gceSURF_FORMAT DestFormat + ); + +/* Batch blit. */ +gceSTATUS +gco2D_BatchBlit( + IN gco2D Engine, + IN gctUINT32 RectCount, + IN gcsRECT_PTR SrcRect, + IN gcsRECT_PTR DestRect, + IN gctUINT8 FgRop, + IN gctUINT8 BgRop, + IN gceSURF_FORMAT DestFormat + ); + +/* Stretch blit. */ +gceSTATUS +gco2D_StretchBlit( + IN gco2D Engine, + IN gctUINT32 RectCount, + IN gcsRECT_PTR Rect, + IN gctUINT8 FgRop, + IN gctUINT8 BgRop, + IN gceSURF_FORMAT DestFormat + ); + +/* Monochrome blit. */ +gceSTATUS +gco2D_MonoBlit( + IN gco2D Engine, + IN gctPOINTER StreamBits, + IN gcsPOINT_PTR StreamSize, + IN gcsRECT_PTR StreamRect, + IN gceSURF_MONOPACK SrcStreamPack, + IN gceSURF_MONOPACK DestStreamPack, + IN gcsRECT_PTR DestRect, + IN gctUINT32 FgRop, + IN gctUINT32 BgRop, + IN gceSURF_FORMAT DestFormat + ); + +/* Set kernel size. */ +gceSTATUS +gco2D_SetKernelSize( + IN gco2D Engine, + IN gctUINT8 HorKernelSize, + IN gctUINT8 VerKernelSize + ); + +/* Set filter type. */ +gceSTATUS +gco2D_SetFilterType( + IN gco2D Engine, + IN gceFILTER_TYPE FilterType + ); + +/* Set the filter kernel by user. */ +gceSTATUS +gco2D_SetUserFilterKernel( + IN gco2D Engine, + IN gceFILTER_PASS_TYPE PassType, + IN gctUINT16_PTR KernelArray + ); + +/* Select the pass(es) to be done for user defined filter. */ +gceSTATUS +gco2D_EnableUserFilterPasses( + IN gco2D Engine, + IN gctBOOL HorPass, + IN gctBOOL VerPass + ); + +/* Frees the temporary buffer allocated by filter blit operation. */ +gceSTATUS +gco2D_FreeFilterBuffer( + IN gco2D Engine + ); + +/* Filter blit. */ +gceSTATUS +gco2D_FilterBlit( + IN gco2D Engine, + IN gctUINT32 SrcAddress, + IN gctUINT SrcStride, + IN gctUINT32 SrcUAddress, + IN gctUINT SrcUStride, + IN gctUINT32 SrcVAddress, + IN gctUINT SrcVStride, + IN gceSURF_FORMAT SrcFormat, + IN gceSURF_ROTATION SrcRotation, + IN gctUINT32 SrcSurfaceWidth, + IN gcsRECT_PTR SrcRect, + IN gctUINT32 DestAddress, + IN gctUINT DestStride, + IN gceSURF_FORMAT DestFormat, + IN gceSURF_ROTATION DestRotation, + IN gctUINT32 DestSurfaceWidth, + IN gcsRECT_PTR DestRect, + IN gcsRECT_PTR DestSubRect + ); + +/* Filter blit extension for full rotation. */ +gceSTATUS +gco2D_FilterBlitEx( + IN gco2D Engine, + IN gctUINT32 SrcAddress, + IN gctUINT SrcStride, + IN gctUINT32 SrcUAddress, + IN gctUINT SrcUStride, + IN gctUINT32 SrcVAddress, + IN gctUINT SrcVStride, + IN gceSURF_FORMAT SrcFormat, + IN gceSURF_ROTATION SrcRotation, + IN gctUINT32 SrcSurfaceWidth, + IN gctUINT32 SrcSurfaceHeight, + IN gcsRECT_PTR SrcRect, + IN gctUINT32 DestAddress, + IN gctUINT DestStride, + IN gceSURF_FORMAT DestFormat, + IN gceSURF_ROTATION DestRotation, + IN gctUINT32 DestSurfaceWidth, + IN gctUINT32 DestSurfaceHeight, + IN gcsRECT_PTR DestRect, + IN gcsRECT_PTR DestSubRect + ); + +/* Enable alpha blending engine in the hardware and disengage the ROP engine. */ +gceSTATUS +gco2D_EnableAlphaBlend( + IN gco2D Engine, + IN gctUINT8 SrcGlobalAlphaValue, + IN gctUINT8 DstGlobalAlphaValue, + IN gceSURF_PIXEL_ALPHA_MODE SrcAlphaMode, + IN gceSURF_PIXEL_ALPHA_MODE DstAlphaMode, + IN gceSURF_GLOBAL_ALPHA_MODE SrcGlobalAlphaMode, + IN gceSURF_GLOBAL_ALPHA_MODE DstGlobalAlphaMode, + IN gceSURF_BLEND_FACTOR_MODE SrcFactorMode, + IN gceSURF_BLEND_FACTOR_MODE DstFactorMode, + IN gceSURF_PIXEL_COLOR_MODE SrcColorMode, + IN gceSURF_PIXEL_COLOR_MODE DstColorMode + ); + +/* Enable alpha blending engine in the hardware. */ +gceSTATUS +gco2D_EnableAlphaBlendAdvanced( + IN gco2D Engine, + IN gceSURF_PIXEL_ALPHA_MODE SrcAlphaMode, + IN gceSURF_PIXEL_ALPHA_MODE DstAlphaMode, + IN gceSURF_GLOBAL_ALPHA_MODE SrcGlobalAlphaMode, + IN gceSURF_GLOBAL_ALPHA_MODE DstGlobalAlphaMode, + IN gceSURF_BLEND_FACTOR_MODE SrcFactorMode, + IN gceSURF_BLEND_FACTOR_MODE DstFactorMode + ); + +/* Enable alpha blending engine with Porter Duff rule. */ +gceSTATUS +gco2D_SetPorterDuffBlending( + IN gco2D Engine, + IN gce2D_PORTER_DUFF_RULE Rule + ); + +/* Disable alpha blending engine in the hardware and engage the ROP engine. */ +gceSTATUS +gco2D_DisableAlphaBlend( + IN gco2D Engine + ); + +/* Retrieve the maximum number of 32-bit data chunks for a single DE command. */ +gctUINT32 +gco2D_GetMaximumDataCount( + void + ); + +/* Retrieve the maximum number of rectangles, that can be passed in a single DE command. */ +gctUINT32 +gco2D_GetMaximumRectCount( + void + ); + +/* Returns the pixel alignment of the surface. */ +gceSTATUS +gco2D_GetPixelAlignment( + gceSURF_FORMAT Format, + gcsPOINT_PTR Alignment + ); + +/* Retrieve monochrome stream pack size. */ +gceSTATUS +gco2D_GetPackSize( + IN gceSURF_MONOPACK StreamPack, + OUT gctUINT32 * PackWidth, + OUT gctUINT32 * PackHeight + ); + +/* Flush the 2D pipeline. */ +gceSTATUS +gco2D_Flush( + IN gco2D Engine + ); + +/* Load 256-entry color table for INDEX8 source surfaces. */ +gceSTATUS +gco2D_LoadPalette( + IN gco2D Engine, + IN gctUINT FirstIndex, + IN gctUINT IndexCount, + IN gctPOINTER ColorTable, + IN gctBOOL ColorConvert + ); + +/* Enable/disable 2D BitBlt mirrorring. */ +gceSTATUS +gco2D_SetBitBlitMirror( + IN gco2D Engine, + IN gctBOOL HorizontalMirror, + IN gctBOOL VerticalMirror + ); + +/* Set the transparency for source, destination and pattern. */ +gceSTATUS +gco2D_SetTransparencyAdvanced( + IN gco2D Engine, + IN gce2D_TRANSPARENCY SrcTransparency, + IN gce2D_TRANSPARENCY DstTransparency, + IN gce2D_TRANSPARENCY PatTransparency + ); + +/* Set the source color key. */ +gceSTATUS +gco2D_SetSourceColorKeyAdvanced( + IN gco2D Engine, + IN gctUINT32 ColorKey + ); + +/* Set the source color key range. */ +gceSTATUS +gco2D_SetSourceColorKeyRangeAdvanced( + IN gco2D Engine, + IN gctUINT32 ColorKeyLow, + IN gctUINT32 ColorKeyHigh + ); + +/* Set the target color key. */ +gceSTATUS +gco2D_SetTargetColorKeyAdvanced( + IN gco2D Engine, + IN gctUINT32 ColorKey + ); + +/* Set the target color key range. */ +gceSTATUS +gco2D_SetTargetColorKeyRangeAdvanced( + IN gco2D Engine, + IN gctUINT32 ColorKeyLow, + IN gctUINT32 ColorKeyHigh + ); + +/* Set the YUV color space mode. */ +gceSTATUS +gco2D_SetYUVColorMode( + IN gco2D Engine, + IN gce2D_YUV_COLOR_MODE Mode + ); + +/* Setup the source global color value in ARGB8 format. */ +gceSTATUS gco2D_SetSourceGlobalColorAdvanced( + IN gco2D Engine, + IN gctUINT32 Color32 + ); + +/* Setup the target global color value in ARGB8 format. */ +gceSTATUS gco2D_SetTargetGlobalColorAdvanced( + IN gco2D Engine, + IN gctUINT32 Color32 + ); + +/* Setup the source and target pixel multiply modes. */ +gceSTATUS +gco2D_SetPixelMultiplyModeAdvanced( + IN gco2D Engine, + IN gce2D_PIXEL_COLOR_MULTIPLY_MODE SrcPremultiplySrcAlpha, + IN gce2D_PIXEL_COLOR_MULTIPLY_MODE DstPremultiplyDstAlpha, + IN gce2D_GLOBAL_COLOR_MULTIPLY_MODE SrcPremultiplyGlobalMode, + IN gce2D_PIXEL_COLOR_MULTIPLY_MODE DstDemultiplyDstAlpha + ); + +/* Set the GPU clock cycles after which the idle engine will keep auto-flushing. */ +gceSTATUS +gco2D_SetAutoFlushCycles( + IN gco2D Engine, + IN gctUINT32 Cycles + ); + +/* Read the profile registers available in the 2D engine and sets them in the profile. + The function will also reset the pixelsRendered counter every time. +*/ +gceSTATUS +gco2D_ProfileEngine( + IN gco2D Engine, + OPTIONAL gcs2D_PROFILE_PTR Profile + ); + +#ifdef __cplusplus +} +#endif + +#endif /* __gc_hal_raster_h_ */ + diff --git a/native/include_dove/gc_hal_types.h b/native/include_dove/gc_hal_types.h new file mode 100644 index 0000000..34d126a --- /dev/null +++ b/native/include_dove/gc_hal_types.h @@ -0,0 +1,601 @@ +/**************************************************************************** +* +* Copyright (C) 2005 - 2010 by Vivante Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the license, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +* +*****************************************************************************/ + + + + +#ifndef __gc_hal_types_h_ +#define __gc_hal_types_h_ + +#include "gc_hal_options.h" + +#ifdef _WIN32 +#pragma warning(disable:4127) /* Conditional expression is constant (do { } + ** while(0)). */ +#pragma warning(disable:4100) /* Unreferenced formal parameter. */ +#pragma warning(disable:4204) /* Non-constant aggregate initializer (C99). */ +#pragma warning(disable:4131) /* Uses old-style declarator (for Bison and + ** Flex generated files). */ +#pragma warning(disable:4206) /* Translation unit is empty. */ +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/******************************************************************************\ +** Platform macros. +*/ + +#if defined(__GNUC__) +# define gcdHAS_ELLIPSES 1 /* GCC always has it. */ +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +# define gcdHAS_ELLIPSES 1 /* C99 has it. */ +#elif defined(_MSC_VER) && (_MSC_VER >= 1500) +# define gcdHAS_ELLIPSES 1 /* MSVC 2007+ has it. */ +#elif defined(UNDER_CE) +# define gcdHAS_ELLIPSES 0 /* Windows CE doesn't have it. */ +#else +# error "gcdHAS_ELLIPSES: Platform could not be determined" +#endif + +/******************************************************************************\ +************************************ Keyword *********************************** +\******************************************************************************/ + +#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) +# define gcmINLINE inline /* C99 keyword. */ +#elif defined(__GNUC__) +# define gcmINLINE __inline__ /* GNU keyword. */ +#elif defined(_MSC_VER) || defined(UNDER_CE) +# define gcmINLINE __inline /* Internal keyword. */ +#else +# error "gcmINLINE: Platform could not be determined" +#endif + +#ifndef gcdDEBUG +# if (defined(DBG) && DBG) || defined(DEBUG) || defined(_DEBUG) +# define gcdDEBUG 1 +# else +# define gcdDEBUG 0 +# endif +#endif + +#ifdef _USRDLL +# ifdef _MSC_VER +# ifdef HAL_EXPORTS +# define HALAPI __declspec(dllexport) +# else +# define HALAPI __declspec(dllimport) +# endif +# define HALDECL __cdecl +# else +# ifdef HAL_EXPORTS +# define HALAPI +# else +# define HALAPI extern +# endif +# endif +#else +# define HALAPI +# define HALDECL +#endif + +/******************************************************************************\ +********************************** Common Types ******************************** +\******************************************************************************/ + +#define gcvFALSE 0 +#define gcvTRUE 1 + +#define gcvINFINITE ((gctUINT32) ~0U) + +typedef int gctBOOL; +typedef gctBOOL * gctBOOL_PTR; + +typedef int gctINT; +typedef signed char gctINT8; +typedef signed short gctINT16; +typedef signed int gctINT32; +typedef signed long long gctINT64; + +typedef gctINT * gctINT_PTR; +typedef gctINT8 * gctINT8_PTR; +typedef gctINT16 * gctINT16_PTR; +typedef gctINT32 * gctINT32_PTR; +typedef gctINT64 * gctINT64_PTR; + +typedef unsigned int gctUINT; +typedef unsigned char gctUINT8; +typedef unsigned short gctUINT16; +typedef unsigned int gctUINT32; +typedef unsigned long long gctUINT64; + +typedef gctUINT * gctUINT_PTR; +typedef gctUINT8 * gctUINT8_PTR; +typedef gctUINT16 * gctUINT16_PTR; +typedef gctUINT32 * gctUINT32_PTR; +typedef gctUINT64 * gctUINT64_PTR; + +typedef unsigned long gctSIZE_T; +typedef gctSIZE_T * gctSIZE_T_PTR; + +#ifdef __cplusplus +# define gcvNULL 0 +#else +# define gcvNULL ((void *) 0) +#endif + +typedef float gctFLOAT; +typedef signed int gctFIXED_POINT; +typedef float * gctFLOAT_PTR; + +typedef void * gctPHYS_ADDR; +typedef void * gctHANDLE; +typedef void * gctFILE; +typedef void * gctSIGNAL; +typedef void * gctWINDOW; +typedef void * gctIMAGE; + +typedef void * gctPOINTER; +typedef const void * gctCONST_POINTER; + +typedef char gctCHAR; +typedef char * gctSTRING; +typedef const char * gctCONST_STRING; + +typedef struct _gcsCOUNT_STRING +{ + gctSIZE_T Length; + gctCONST_STRING String; +} +gcsCOUNT_STRING; + +/* Fixed point constants. */ +#define gcvZERO_X ((gctFIXED_POINT) 0x00000000) +#define gcvHALF_X ((gctFIXED_POINT) 0x00008000) +#define gcvONE_X ((gctFIXED_POINT) 0x00010000) +#define gcvNEGONE_X ((gctFIXED_POINT) 0xFFFF0000) +#define gcvTWO_X ((gctFIXED_POINT) 0x00020000) + +/******************************************************************************\ +******************************* Fixed Point Math ******************************* +\******************************************************************************/ + +#define gcmXMultiply(x1, x2) \ + (gctFIXED_POINT) (((gctINT64) (x1) * (x2)) >> 16) + +#define gcmXDivide(x1, x2) \ + (gctFIXED_POINT) ((((gctINT64) (x1)) << 16) / (x2)) + +#define gcmXMultiplyDivide(x1, x2, x3) \ + (gctFIXED_POINT) ((gctINT64) (x1) * (x2) / (x3)) + +/* 2D Engine profile. */ +struct gcs2D_PROFILE +{ + /* Cycle count. + 32bit counter incremented every 2D clock cycle. + Wraps back to 0 when the counter overflows. + */ + gctUINT32 cycleCount; + + /* Pixels rendered by the 2D engine. + Resets to 0 every time it is read. */ + gctUINT32 pixelsRendered; +}; + + +/* Macro to combine four characters into a Charcater Code. */ +#define gcmCC(c1, c2, c3, c4) \ +( \ + (char) (c1) \ + | \ + ((char) (c2) << 8) \ + | \ + ((char) (c3) << 16) \ + | \ + ((char) (c4) << 24) \ +) + +#define gcmPRINTABLE(c) ((((c) >= ' ') && ((c) <= '}')) ? (c) : ' ') + +#define gcmCC_PRINT(cc) \ + gcmPRINTABLE((char) ( (cc) & 0xFF)), \ + gcmPRINTABLE((char) (((cc) >> 8) & 0xFF)), \ + gcmPRINTABLE((char) (((cc) >> 16) & 0xFF)), \ + gcmPRINTABLE((char) (((cc) >> 24) & 0xFF)) + +/******************************************************************************\ +****************************** Function Parameters ***************************** +\******************************************************************************/ + +#define IN +#define OUT +#define OPTIONAL + +/******************************************************************************\ +********************************* Status Codes ********************************* +\******************************************************************************/ + +typedef enum _gceSTATUS +{ + gcvSTATUS_OK = 0, + gcvSTATUS_FALSE = 0, + gcvSTATUS_TRUE = 1, + gcvSTATUS_NO_MORE_DATA = 2, + gcvSTATUS_CACHED = 3, + gcvSTATUS_MIPMAP_TOO_LARGE = 4, + gcvSTATUS_NAME_NOT_FOUND = 5, + gcvSTATUS_NOT_OUR_INTERRUPT = 6, + gcvSTATUS_MISMATCH = 7, + gcvSTATUS_MIPMAP_TOO_SMALL = 8, + gcvSTATUS_LARGER = 9, + gcvSTATUS_SMALLER = 10, + gcvSTATUS_CHIP_NOT_READY = 11, + gcvSTATUS_NEED_CONVERSION = 12, + gcvSTATUS_SKIP = 13, + gcvSTATUS_DATA_TOO_LARGE = 14, + gcvSTATUS_INVALID_CONFIG = 15, + gcvSTATUS_CHANGED = 16, + + gcvSTATUS_INVALID_ARGUMENT = -1, + gcvSTATUS_INVALID_OBJECT = -2, + gcvSTATUS_OUT_OF_MEMORY = -3, + gcvSTATUS_MEMORY_LOCKED = -4, + gcvSTATUS_MEMORY_UNLOCKED = -5, + gcvSTATUS_HEAP_CORRUPTED = -6, + gcvSTATUS_GENERIC_IO = -7, + gcvSTATUS_INVALID_ADDRESS = -8, + gcvSTATUS_CONTEXT_LOSSED = -9, + gcvSTATUS_TOO_COMPLEX = -10, + gcvSTATUS_BUFFER_TOO_SMALL = -11, + gcvSTATUS_INTERFACE_ERROR = -12, + gcvSTATUS_NOT_SUPPORTED = -13, + gcvSTATUS_MORE_DATA = -14, + gcvSTATUS_TIMEOUT = -15, + gcvSTATUS_OUT_OF_RESOURCES = -16, + gcvSTATUS_INVALID_DATA = -17, + gcvSTATUS_INVALID_MIPMAP = -18, + gcvSTATUS_NOT_FOUND = -19, + gcvSTATUS_NOT_ALIGNED = -20, + gcvSTATUS_INVALID_REQUEST = -21, + gcvSTATUS_GPU_NOT_RESPONDING = -22, + + /* Linker errors. */ + gcvSTATUS_GLOBAL_TYPE_MISMATCH = -1000, + gcvSTATUS_TOO_MANY_ATTRIBUTES = -1001, + gcvSTATUS_TOO_MANY_UNIFORMS = -1002, + gcvSTATUS_TOO_MANY_VARYINGS = -1003, + gcvSTATUS_UNDECLARED_VARYING = -1004, + gcvSTATUS_VARYING_TYPE_MISMATCH = -1005, + gcvSTATUS_MISSING_MAIN = -1006, + gcvSTATUS_NAME_MISMATCH = -1007, + gcvSTATUS_INVALID_INDEX = -1008, +} +gceSTATUS; + +/******************************************************************************\ +********************************* Status Macros ******************************** +\******************************************************************************/ + +#define gcmIS_ERROR(status) (status < 0) +#define gcmNO_ERROR(status) (status >= 0) +#define gcmIS_SUCCESS(status) (status == gcvSTATUS_OK) + +/******************************************************************************\ +********************************* Field Macros ********************************* +\******************************************************************************/ + +#define __gcmSTART(reg_field) \ + (0 ? reg_field) + +#define __gcmEND(reg_field) \ + (1 ? reg_field) + +#define __gcmGETSIZE(reg_field) \ + (__gcmEND(reg_field) - __gcmSTART(reg_field) + 1) + +#define __gcmALIGN(data, reg_field) \ + (((gctUINT32) (data)) << __gcmSTART(reg_field)) + +#define __gcmMASK(reg_field) \ + ((gctUINT32) ((__gcmGETSIZE(reg_field) == 32) \ + ? ~0 \ + : (~(~0 << __gcmGETSIZE(reg_field))))) + +/******************************************************************************* +** +** gcmFIELDMASK +** +** Get aligned field mask. +** +** ARGUMENTS: +** +** reg Name of register. +** field Name of field within register. +*/ +#define gcmFIELDMASK(reg, field) \ +( \ + __gcmALIGN(__gcmMASK(reg##_##field), reg##_##field) \ +) + +/******************************************************************************* +** +** gcmGETFIELD +** +** Extract the value of a field from specified data. +** +** ARGUMENTS: +** +** data Data value. +** reg Name of register. +** field Name of field within register. +*/ +#define gcmGETFIELD(data, reg, field) \ +( \ + ((((gctUINT32) (data)) >> __gcmSTART(reg##_##field)) \ + & __gcmMASK(reg##_##field)) \ +) + +/******************************************************************************* +** +** gcmSETFIELD +** +** Set the value of a field within specified data. +** +** ARGUMENTS: +** +** data Data value. +** reg Name of register. +** field Name of field within register. +** value Value for field. +*/ +#define gcmSETFIELD(data, reg, field, value) \ +( \ + (((gctUINT32) (data)) \ + & ~__gcmALIGN(__gcmMASK(reg##_##field), reg##_##field)) \ + | __gcmALIGN((gctUINT32) (value) \ + & __gcmMASK(reg##_##field), reg##_##field) \ +) + +/******************************************************************************* +** +** gcmSETFIELDVALUE +** +** Set the value of a field within specified data with a +** predefined value. +** +** ARGUMENTS: +** +** data Data value. +** reg Name of register. +** field Name of field within register. +** value Name of the value within the field. +*/ +#define gcmSETFIELDVALUE(data, reg, field, value) \ +( \ + (((gctUINT32) (data)) \ + & ~__gcmALIGN(__gcmMASK(reg##_##field), reg##_##field)) \ + | __gcmALIGN(reg##_##field##_##value \ + & __gcmMASK(reg##_##field), reg##_##field) \ +) + +/******************************************************************************* +** +** gcmSETMASKEDFIELD +** +** Set the value of a masked field with specified data. +** +** ARGUMENTS: +** +** reg Name of register. +** field Name of field within register. +** value Value for field. +*/ +#define gcmSETMASKEDFIELD(reg, field, value) \ +( \ + gcmSETFIELD(~0, reg, field, value) & \ + gcmSETFIELDVALUE(~0, reg, MASK_ ## field, ENABLED) \ +) + +/******************************************************************************* +** +** gcmVERIFYFIELDVALUE +** +** Verify if the value of a field within specified data equals a +** predefined value. +** +** ARGUMENTS: +** +** data Data value. +** reg Name of register. +** field Name of field within register. +** value Name of the value within the field. +*/ +#define gcmVERIFYFIELDVALUE(data, reg, field, value) \ +( \ + (((gctUINT32) (data)) >> __gcmSTART(reg##_##field) & \ + __gcmMASK(reg##_##field)) \ + == \ + (reg##_##field##_##value & __gcmMASK(reg##_##field)) \ +) + +/******************************************************************************* +** Bit field macros. +*/ + +#define __gcmSTARTBIT(Field) \ + ( 1 ? Field ) + +#define __gcmBITSIZE(Field) \ + ( 0 ? Field ) + +#define __gcmBITMASK(Field) \ +( \ + (1 << __gcmBITSIZE(Field)) - 1 \ +) + +#define gcmGETBITS(Value, Type, Field) \ +( \ + ( ((Type) (Value)) >> __gcmSTARTBIT(Field) ) \ + & \ + __gcmBITMASK(Field) \ +) + +#define gcmSETBITS(Value, Type, Field, NewValue) \ +( \ + ( ((Type) (Value)) \ + & ~(__gcmBITMASK(Field) << __gcmSTARTBIT(Field)) \ + ) \ + | \ + ( ( ((Type) (NewValue)) \ + & __gcmBITMASK(Field) \ + ) << __gcmSTARTBIT(Field) \ + ) \ +) + +/******************************************************************************\ +******************************** Min/Max Macros ******************************** +\******************************************************************************/ + +#define gcmMIN(x, y) (((x) <= (y)) ? (x) : (y)) +#define gcmMAX(x, y) (((x) >= (y)) ? (x) : (y)) +#define gcmCLAMP(x, min, max) (((x) < (min)) ? (min) : \ + ((x) > (max)) ? (max) : (x)) +#define gcmABS(x) (((x) < 0) ? -(x) : (x)) +#define gcmNEG(x) (((x) < 0) ? (x) : -(x)) + + +#define gcmUNALIGNMENT(X) ((gctUINT32)(X) & (sizeof (gctUINT32) - 1)) + +#define gcmMEMCPY_BYTE(dst,src,size) \ + {\ + gctUINT32 i = 0; \ + for(i = 0; i < size; i++)\ + {\ + *((gctUINT8 *)dst+i) = *((gctUINT8*)src+i);\ + }\ + } + +/* Optimize memory copy. + For 4,8,12,16 bytes copy, use unsigned int assignment instead of calling memcopy. + ATTENTION: no break in switch branch. +*/ +#define gcmMEMCPY_DWORD(dst,src,size) \ + switch(size) \ + {\ + case 16:\ + *((gctUINT32 *)dst + 3) = *((gctUINT32 *)src + 3);\ + case 12:\ + *((gctUINT32 *)dst + 2) = *((gctUINT32 *)src + 2);\ + case 8:\ + *((gctUINT32 *)dst + 1) = *((gctUINT32 *)src + 1);\ + case 4:\ + *((gctUINT32 *)dst) = *((gctUINT32 *)src);\ + break;\ + default:\ + gcmMEMCPY_BYTE(dst,src,size);\ + break;\ + } + +/* + * gcmMEMCPY. + * + * gcmMEMCPY is for normal size(> 16 bytes) memory copy + * gcmMEMCPY_DWORD is for size <=16 bytes + * Note: if you do not know the size, just use gcmMEMCPY +*/ +#define gcmMEMCPY(dst,src,size) \ + { \ + gctUINT32 *pDst = (gctUINT32 *)dst; \ + gctUINT32 *pSrc = (gctUINT32 *)src; \ + gctUINT32 Size = size; \ + while(Size >= gcmSIZEOF(gctUINT32) * 4) \ + { \ + pDst[0] = pSrc[0]; \ + pDst[1] = pSrc[1]; \ + pDst[2] = pSrc[2]; \ + pDst[3] = pSrc[3]; \ + pDst += 4; \ + pSrc += 4; \ + Size -= (gcmSIZEOF(gctUINT32) * 4); \ + } \ + gcmMEMCPY_DWORD(pDst,pSrc,Size) \ + } +/******************************************************************************* +** +** gcmPTR2INT +** +** Convert a pointer to an integer value. +** +** ARGUMENTS: +** +** p Pointer value. +*/ +#if defined(_WIN32) || (defined(__LP64__) && __LP64__) +# define gcmPTR2INT(p) \ + ( \ + (gctUINT32) (gctUINT64) (p) \ + ) +#else +# define gcmPTR2INT(p) \ + ( \ + (gctUINT32) (p) \ + ) +#endif + +/******************************************************************************* +** +** gcmINT2PTR +** +** Convert an integer value into a pointer. +** +** ARGUMENTS: +** +** v Integer value. +*/ +#define gcmINT2PTR(i) \ +( \ + (gctPOINTER) (i) \ +) + +/******************************************************************************* +** +** gcmOFFSETOF +** +** Compute the byte offset of a field inside a structure. +** +** ARGUMENTS: +** +** s Structure name. +** field Field name. +*/ +#define gcmOFFSETOF(s, field) \ +( \ + gcmPTR2INT(& (((struct s *) 0)->field)) \ +) + +#ifdef __cplusplus +} +#endif + +#endif /* __gc_hal_types_h_ */ + diff --git a/native/include_dove/gc_hal_user_context.h b/native/include_dove/gc_hal_user_context.h new file mode 100644 index 0000000..10c0564 --- /dev/null +++ b/native/include_dove/gc_hal_user_context.h @@ -0,0 +1,199 @@ +/**************************************************************************** +* +* Copyright (c) 2005 - 2010 by Vivante Corp. All rights reserved. +* +* The material in this file is confidential and contains trade secrets +* of Vivante Corporation. This is proprietary information owned by +* Vivante Corporation. No part of this work may be disclosed, +* reproduced, copied, transmitted, or used in any way for any purpose, +* without the express written permission of Vivante Corporation. +* +***************************************************************************** +* +* +*****************************************************************************/ + + + + +#ifndef __gc_hal_user_context_h_ +#define __gc_hal_user_context_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +struct _gcoCTXBUF +{ + /* The object. */ + gcsOBJECT object; + + /* Pointer to gcoOS object. */ + gcoOS os; + + /* Pointer to gcoHARDWARE object. */ + gcoHARDWARE hardware; + + /* Physical address of context buffer. */ + gctPHYS_ADDR physical; + + /* Logical address of context buffer. */ + gctPOINTER logical; + + /* Number of bytes in context buffer. */ + gctSIZE_T bytes; +}; + +/* gcoCONTEXT structure that hold the current context. */ +struct _gcoCONTEXT +{ + /* Object. */ + gcsOBJECT object; + + /* Pointer to gcoOS object. */ + gcoOS os; + + /* Pointer to gcoHARDWARE object. */ + gcoHARDWARE hardware; + + /* Context ID. */ + gctUINT64 id; + + /* State mapping. */ + gctUINT32_PTR map; + gctSIZE_T stateCount; + + /* State hinting. */ + gctUINT8_PTR hint; + gctUINT8 hintValue; + gctSIZE_T hintCount; + + /* Context buffer. */ + gctUINT32_PTR buffer; + gctUINT32 pipe3DIndex; + gctUINT32 pipe2DIndex; + gctUINT32 linkIndex; + gctUINT32 inUseIndex; + gctSIZE_T bufferSize; + + /* Context buffer used for commitment. */ +#if MRVL_PRE_ALLOCATE_CTX_BUFFER + /* Array of phisical context buffers and their signals. */ + gcoCTXBUF ctxbufArray[gcdCTXBUF_SIZE_DEFAULT]; + gctSIGNAL ctxbufSignal[gcdCTXBUF_SIZE_DEFAULT]; + /* Real number of context buffers pre-allocated. */ + gctINT ctxbufSize; + /* Current context buffer. */ + gctINT ctxbufIndex; +#else + gctSIZE_T bytes; + gctPHYS_ADDR physical; +#endif + gctPOINTER logical; + + /* Pointer to final LINK command. */ + gctPOINTER link; + + /* Requested pipe select for context. */ + gctUINT32 initialPipe; + gctUINT32 entryPipe; + gctUINT32 currentPipe; + + /* Flag to specify whether PostCommit needs to be called. */ + gctBOOL postCommit; + + /* Busy flag. */ + volatile gctBOOL * inUse; + + /* Variables used for building state buffer. */ + gctUINT32 lastAddress; + gctSIZE_T lastSize; + gctUINT32 lastIndex; + gctBOOL lastFixed; + + /* Hint array. */ + gctUINT32_PTR hintArray; + gctUINT32_PTR hintIndex; + + /* Skip flag */ + gctBOOL skipContext; +}; + +struct _gcoCMDBUF +{ + /* The object. */ + gcsOBJECT object; + + /* Pointer to gcoOS object. */ + gcoOS os; + + /* Pointer to gcoHARDWARE object. */ + gcoHARDWARE hardware; + + /* Physical address of command buffer. */ + gctPHYS_ADDR physical; + + /* Logical address of command buffer. */ + gctPOINTER logical; + + /* Number of bytes in command buffer. */ + gctSIZE_T bytes; + + /* Start offset into the command buffer. */ + gctUINT32 startOffset; + + /* Current offset into the command buffer. */ + gctUINT32 offset; + + /* Number of free bytes in command buffer. */ + gctSIZE_T free; + +#if gcdSECURE_USER + /* Table of offsets that define the physical addresses to be mapped. */ + gctUINT32_PTR hintTable; + + /* Current index into map table. */ + gctUINT32_PTR hintIndex; + + /* Commit index for map table. */ + gctUINT32_PTR hintCommit; +#endif +}; + +typedef struct _gcsQUEUE * gcsQUEUE_PTR; + +typedef struct _gcsQUEUE +{ + /* Pointer to next gcsQUEUE structure. */ + gcsQUEUE_PTR next; + +#ifdef __QNXNTO__ + /* Size of this object. */ + gctSIZE_T bytes; +#endif + + /* Event information. */ + gcsHAL_INTERFACE iface; +} +gcsQUEUE; + +/* Event queue. */ +struct _gcoQUEUE +{ + /* The object. */ + gcsOBJECT object; + + /* Pointer to gcoOS object. */ + gcoOS os; + + /* Pointer to current event queue. */ + gcsQUEUE_PTR head; + gcsQUEUE_PTR tail; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* __gc_hal_user_context_h_ */ + diff --git a/native/lib/elf_hook.c b/native/lib/elf_hook.c index 7e34867..b5764e5 100644 --- a/native/lib/elf_hook.c +++ b/native/lib/elf_hook.c @@ -10,7 +10,7 @@ #include <sys/mman.h> #include <unistd.h> #include <errno.h> -//rename standart types for convenience +//rename standard types for convenience #ifdef __x86_64 #define Elf_Ehdr Elf64_Ehdr #define Elf_Shdr Elf64_Shdr @@ -447,15 +447,22 @@ void *elf_hook(char const *module_filename, void const *module_address, char con { name_address = (size_t *)(((size_t)module_address) + rel_plt_table[i].r_offset); original = (void *)*name_address; - mprotect((void *)(((size_t)name_address) & (((size_t)-1) ^ (pagesize - 1))), pagesize, PROT_READ | PROT_WRITE); //mark a memory page that contains the relocation as writable + mprotect((void *)(((size_t)name_address) & (((size_t)-1) ^ (pagesize - 1))), pagesize, PROT_READ | PROT_WRITE | PROT_EXEC); //mark a memory page that contains the relocation as writable *name_address = (size_t)substitution; //and replace it with the substitutional - mprotect((void *)(((size_t)name_address) & (((size_t)-1) ^ (pagesize - 1))), pagesize, PROT_READ | PROT_EXEC); //mark a memory page that contains the relocation as executable - + // Removing write protection works on some platforms (such as Android), on others the LD linker + // itself uses writability of the plt memory. As security is not a concern here, leave it writable. + //mprotect((void *)(((size_t)name_address) & (((size_t)-1) ^ (pagesize - 1))), pagesize, PROT_READ | PROT_EXEC); //mark a memory page that contains the relocation as executable +#ifdef DEBUG + printf("Replaced %p at %p with %p\n", original, name_address, substitution); +#endif break; //the target symbol appears in ".rel.plt" only once } if (original) return original; +#ifdef DEBUG + printf("non-PIC module: fallback\n"); +#endif //we will get here only with 32-bit non-PIC module for (i = 0; i < rel_dyn_amount; ++i) //lookup the ".rel.dyn" table if (ELF_R_SYM(rel_dyn_table[i].r_info) == name_index) //if we found the symbol to substitute in ".rel.dyn" diff --git a/native/lib/esTransform.c b/native/lib/esTransform.c index 8c5e020..a8cffc8 100644 --- a/native/lib/esTransform.c +++ b/native/lib/esTransform.c @@ -30,17 +30,7 @@ * DEALINGS IN THE SOFTWARE. */ -// ESUtil.c -// -// A utility library for OpenGL ES. This library provides a -// basic common framework for the example applications in the -// OpenGL ES 2.0 Programming Guide. -// - -/// -// Includes -// -#include "esUtil.h" +#include "esTransform.h" #include <math.h> #include <string.h> diff --git a/native/lib/esTransform.h b/native/lib/esTransform.h new file mode 100644 index 0000000..6592f08 --- /dev/null +++ b/native/lib/esTransform.h @@ -0,0 +1,127 @@ +// +// Book: OpenGL(R) ES 2.0 Programming Guide +// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner +// ISBN-10: 0321502795 +// ISBN-13: 9780321502797 +// Publisher: Addison-Wesley Professional +// URLs: http://safari.informit.com/9780321563835 +// http://www.opengles-book.com +// + +/* + * (c) 2009 Aaftab Munshi, Dan Ginsburg, Dave Shreiner + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef ESTRANSFORM_H +#define ESTRANSFORM_H + +/// +// Includes +// +#include <GLES2/gl2.h> +#include <EGL/egl.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define ESUTIL_API + +/// +// Types +// + +typedef struct +{ + GLfloat m[4][4]; +} ESMatrix; + +// +/// \brief multiply matrix specified by result with a scaling matrix and return new matrix in result +/// \param result Specifies the input matrix. Scaled matrix is returned in result. +/// \param sx, sy, sz Scale factors along the x, y and z axes respectively +// +void ESUTIL_API esScale(ESMatrix *result, GLfloat sx, GLfloat sy, GLfloat sz); + +// +/// \brief multiply matrix specified by result with a translation matrix and return new matrix in result +/// \param result Specifies the input matrix. Translated matrix is returned in result. +/// \param tx, ty, tz Scale factors along the x, y and z axes respectively +// +void ESUTIL_API esTranslate(ESMatrix *result, GLfloat tx, GLfloat ty, GLfloat tz); + +// +/// \brief multiply matrix specified by result with a rotation matrix and return new matrix in result +/// \param result Specifies the input matrix. Rotated matrix is returned in result. +/// \param angle Specifies the angle of rotation, in degrees. +/// \param x, y, z Specify the x, y and z coordinates of a vector, respectively +// +void ESUTIL_API esRotate(ESMatrix *result, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); + +// +// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result +/// \param result Specifies the input matrix. new matrix is returned in result. +/// \param left, right Coordinates for the left and right vertical clipping planes +/// \param bottom, top Coordinates for the bottom and top horizontal clipping planes +/// \param nearZ, farZ Distances to the near and far depth clipping planes. Both distances must be positive. +// +void ESUTIL_API esFrustum(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ); + +// +/// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result +/// \param result Specifies the input matrix. new matrix is returned in result. +/// \param fovy Field of view y angle in degrees +/// \param aspect Aspect ratio of screen +/// \param nearZ Near plane distance +/// \param farZ Far plane distance +// +void ESUTIL_API esPerspective(ESMatrix *result, float fovy, float aspect, float nearZ, float farZ); + +// +/// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result +/// \param result Specifies the input matrix. new matrix is returned in result. +/// \param left, right Coordinates for the left and right vertical clipping planes +/// \param bottom, top Coordinates for the bottom and top horizontal clipping planes +/// \param nearZ, farZ Distances to the near and far depth clipping planes. These values are negative if plane is behind the viewer +// +void ESUTIL_API esOrtho(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ); + +// +/// \brief perform the following operation - result matrix = srcA matrix * srcB matrix +/// \param result Returns multiplied matrix +/// \param srcA, srcB Input matrices to be multiplied +// +void ESUTIL_API esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB); + +// +//// \brief return an indentity matrix +//// \param result returns identity matrix +// +void ESUTIL_API esMatrixLoadIdentity(ESMatrix *result); + +void ESUTIL_API esMatrixInverse3x3(ESMatrix *result, ESMatrix *input); +void ESUTIL_API esMatrixTranspose(ESMatrix *result, ESMatrix *input); + +#ifdef __cplusplus +} +#endif + +#endif // ESUTIL_H diff --git a/native/lib/esUtil.c b/native/lib/esUtil.c new file mode 100644 index 0000000..bdceb87 --- /dev/null +++ b/native/lib/esUtil.c @@ -0,0 +1,418 @@ +//
+// Book: OpenGL(R) ES 2.0 Programming Guide
+// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
+// ISBN-10: 0321502795
+// ISBN-13: 9780321502797
+// Publisher: Addison-Wesley Professional
+// URLs: http://safari.informit.com/9780321563835
+// http://www.opengles-book.com
+//
+
+// ESUtil.c
+//
+// A utility library for OpenGL ES. This library provides a
+// basic common framework for the example applications in the
+// OpenGL ES 2.0 Programming Guide.
+//
+
+///
+// Includes
+//
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <sys/time.h>
+#include <GLES2/gl2.h>
+#include <EGL/egl.h>
+#include "esUtil.h"
+
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+
+// X11 related local variables
+static Display *x_display = NULL;
+
+///
+// CreateEGLContext()
+//
+// Creates an EGL rendering context and all associated elements
+//
+EGLBoolean CreateEGLContext ( EGLNativeWindowType hWnd, EGLDisplay* eglDisplay,
+ EGLContext* eglContext, EGLSurface* eglSurface,
+ EGLint attribList[])
+{
+ EGLint numConfigs;
+ EGLint majorVersion;
+ EGLint minorVersion;
+ EGLDisplay display;
+ EGLContext context;
+ EGLSurface surface;
+ EGLConfig config;
+ EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE };
+
+ // Get Display
+ display = eglGetDisplay((EGLNativeDisplayType)x_display);
+ if ( display == EGL_NO_DISPLAY )
+ {
+ return EGL_FALSE;
+ }
+
+ // Initialize EGL
+ if ( !eglInitialize(display, &majorVersion, &minorVersion) )
+ {
+ return EGL_FALSE;
+ }
+
+ // Get configs
+ if ( !eglGetConfigs(display, NULL, 0, &numConfigs) )
+ {
+ return EGL_FALSE;
+ }
+
+ // Choose config
+ if ( !eglChooseConfig(display, attribList, &config, 1, &numConfigs) )
+ {
+ return EGL_FALSE;
+ }
+
+ // Create a surface
+ surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType)hWnd, NULL);
+ if ( surface == EGL_NO_SURFACE )
+ {
+ return EGL_FALSE;
+ }
+
+ // Create a GL context
+ context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs );
+ if ( context == EGL_NO_CONTEXT )
+ {
+ return EGL_FALSE;
+ }
+
+ // Make the context current
+ if ( !eglMakeCurrent(display, surface, surface, context) )
+ {
+ return EGL_FALSE;
+ }
+
+ *eglDisplay = display;
+ *eglSurface = surface;
+ *eglContext = context;
+ return EGL_TRUE;
+}
+
+
+///
+// WinCreate()
+//
+// This function initialized the native X11 display and window for EGL
+//
+EGLBoolean WinCreate(ESContext *esContext, const char *title)
+{
+ Window root;
+ XSetWindowAttributes swa;
+ XSetWindowAttributes xattr;
+ Atom wm_state;
+ XWMHints hints;
+ XEvent xev;
+ Window win;
+
+ /*
+ * X11 native display initialization
+ */
+
+ x_display = XOpenDisplay(NULL);
+ if ( x_display == NULL )
+ {
+ return EGL_FALSE;
+ }
+
+ root = DefaultRootWindow(x_display);
+
+ swa.event_mask = ExposureMask | PointerMotionMask | KeyPressMask;
+ win = XCreateWindow(
+ x_display, root,
+ 0, 0, esContext->width, esContext->height, 0,
+ CopyFromParent, InputOutput,
+ CopyFromParent, CWEventMask,
+ &swa );
+
+ xattr.override_redirect = FALSE;
+ XChangeWindowAttributes ( x_display, win, CWOverrideRedirect, &xattr );
+
+ hints.input = TRUE;
+ hints.flags = InputHint;
+ XSetWMHints(x_display, win, &hints);
+
+ // make the window visible on the screen
+ XMapWindow (x_display, win);
+ XStoreName (x_display, win, title);
+
+ // get identifiers for the provided atom name strings
+ wm_state = XInternAtom (x_display, "_NET_WM_STATE", FALSE);
+
+ memset ( &xev, 0, sizeof(xev) );
+ xev.type = ClientMessage;
+ xev.xclient.window = win;
+ xev.xclient.message_type = wm_state;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = 1;
+ xev.xclient.data.l[1] = FALSE;
+ XSendEvent (
+ x_display,
+ DefaultRootWindow ( x_display ),
+ FALSE,
+ SubstructureNotifyMask,
+ &xev );
+
+ esContext->hWnd = (EGLNativeWindowType) win;
+ return EGL_TRUE;
+}
+
+
+///
+// userInterrupt()
+//
+// Reads from X11 event loop and interrupt program if there is a keypress, or
+// window close action.
+//
+GLboolean userInterrupt(ESContext *esContext)
+{
+ XEvent xev;
+ KeySym key;
+ GLboolean userinterrupt = GL_FALSE;
+ char text;
+
+ // Pump all messages from X server. Keypresses are directed to keyfunc (if defined)
+ while ( XPending ( x_display ) )
+ {
+ XNextEvent( x_display, &xev );
+ if ( xev.type == KeyPress )
+ {
+ if (XLookupString(&xev.xkey,&text,1,&key,0)==1)
+ {
+ if (esContext->keyFunc != NULL)
+ esContext->keyFunc(esContext, text, 0, 0);
+ }
+ }
+ if ( xev.type == DestroyNotify )
+ userinterrupt = GL_TRUE;
+ }
+ return userinterrupt;
+}
+
+
+//////////////////////////////////////////////////////////////////
+//
+// Public Functions
+//
+//
+
+///
+// esInitContext()
+//
+// Initialize ES utility context. This must be called before calling any other
+// functions.
+//
+void ESUTIL_API esInitContext ( ESContext *esContext )
+{
+ if ( esContext != NULL )
+ {
+ memset( esContext, 0, sizeof( ESContext) );
+ }
+}
+
+
+///
+// esCreateWindow()
+//
+// title - name for title bar of window
+// width - width of window to create
+// height - height of window to create
+// flags - bitwise or of window creation flags
+// ES_WINDOW_ALPHA - specifies that the framebuffer should have alpha
+// ES_WINDOW_DEPTH - specifies that a depth buffer should be created
+// ES_WINDOW_STENCIL - specifies that a stencil buffer should be created
+// ES_WINDOW_MULTISAMPLE - specifies that a multi-sample buffer should be created
+//
+GLboolean ESUTIL_API esCreateWindow ( ESContext *esContext, const char* title, GLint width, GLint height, GLuint flags )
+{
+ EGLint attribList[] =
+ {
+ EGL_RED_SIZE, 5,
+ EGL_GREEN_SIZE, 6,
+ EGL_BLUE_SIZE, 5,
+ EGL_ALPHA_SIZE, (flags & ES_WINDOW_ALPHA) ? 8 : EGL_DONT_CARE,
+ EGL_DEPTH_SIZE, (flags & ES_WINDOW_DEPTH) ? 8 : EGL_DONT_CARE,
+ EGL_STENCIL_SIZE, (flags & ES_WINDOW_STENCIL) ? 8 : EGL_DONT_CARE,
+ EGL_SAMPLE_BUFFERS, (flags & ES_WINDOW_MULTISAMPLE) ? 1 : 0,
+ EGL_NONE
+ };
+
+ if ( esContext == NULL )
+ {
+ return GL_FALSE;
+ }
+
+ esContext->width = width;
+ esContext->height = height;
+
+ if ( !WinCreate ( esContext, title) )
+ {
+ return GL_FALSE;
+ }
+
+
+ if ( !CreateEGLContext ( esContext->hWnd,
+ &esContext->eglDisplay,
+ &esContext->eglContext,
+ &esContext->eglSurface,
+ attribList) )
+ {
+ return GL_FALSE;
+ }
+
+
+ return GL_TRUE;
+}
+
+
+///
+// esMainLoop()
+//
+// Start the main loop for the OpenGL ES application
+//
+
+void ESUTIL_API esMainLoop ( ESContext *esContext )
+{
+ struct timeval t1, t2;
+ struct timezone tz;
+ float deltatime;
+ float totaltime = 0.0f;
+ unsigned int frames = 0;
+
+ gettimeofday ( &t1 , &tz );
+
+ while(userInterrupt(esContext) == GL_FALSE && !esContext->terminate)
+ {
+ gettimeofday(&t2, &tz);
+ deltatime = (float)(t2.tv_sec - t1.tv_sec + (t2.tv_usec - t1.tv_usec) * 1e-6);
+ t1 = t2;
+
+ if (esContext->updateFunc != NULL)
+ esContext->updateFunc(esContext, deltatime);
+ if (esContext->drawFunc != NULL)
+ esContext->drawFunc(esContext);
+
+ eglSwapBuffers(esContext->eglDisplay, esContext->eglSurface);
+
+ totaltime += deltatime;
+ frames++;
+ if (totaltime > 2.0f)
+ {
+ printf("%4d frames rendered in %1.4f seconds -> FPS=%3.4f\n", frames, totaltime, frames/totaltime);
+ totaltime -= 2.0f;
+ frames = 0;
+ }
+ }
+}
+
+
+///
+// esRegisterDrawFunc()
+//
+void ESUTIL_API esRegisterDrawFunc ( ESContext *esContext, void (ESCALLBACK *drawFunc) (ESContext* ) )
+{
+ esContext->drawFunc = drawFunc;
+}
+
+
+///
+// esRegisterUpdateFunc()
+//
+void ESUTIL_API esRegisterUpdateFunc ( ESContext *esContext, void (ESCALLBACK *updateFunc) ( ESContext*, float ) )
+{
+ esContext->updateFunc = updateFunc;
+}
+
+
+///
+// esRegisterKeyFunc()
+//
+void ESUTIL_API esRegisterKeyFunc ( ESContext *esContext,
+ void (ESCALLBACK *keyFunc) (ESContext*, unsigned char, int, int ) )
+{
+ esContext->keyFunc = keyFunc;
+}
+
+
+///
+// esLogMessage()
+//
+// Log an error message to the debug output for the platform
+//
+void ESUTIL_API esLogMessage ( const char *formatStr, ... )
+{
+ va_list params;
+ char buf[BUFSIZ];
+
+ va_start ( params, formatStr );
+ vsprintf ( buf, formatStr, params );
+
+ printf ( "%s", buf );
+
+ va_end ( params );
+}
+
+
+///
+// esLoadTGA()
+//
+// Loads a 24-bit TGA image from a file. This is probably the simplest TGA loader ever.
+// Does not support loading of compressed TGAs nor TGAa with alpha channel. But for the
+// sake of the examples, this is sufficient.
+//
+
+char* ESUTIL_API esLoadTGA ( char *fileName, int *width, int *height )
+{
+ char *buffer = NULL;
+ FILE *f;
+ unsigned char tgaheader[12];
+ unsigned char attributes[6];
+ unsigned int imagesize;
+
+ f = fopen(fileName, "rb");
+ if(f == NULL) return NULL;
+
+ if(fread(&tgaheader, sizeof(tgaheader), 1, f) == 0)
+ {
+ fclose(f);
+ return NULL;
+ }
+
+ if(fread(attributes, sizeof(attributes), 1, f) == 0)
+ {
+ fclose(f);
+ return 0;
+ }
+
+ *width = attributes[1] * 256 + attributes[0];
+ *height = attributes[3] * 256 + attributes[2];
+ imagesize = attributes[4] / 8 * *width * *height;
+ buffer = malloc(imagesize);
+ if (buffer == NULL)
+ {
+ fclose(f);
+ return 0;
+ }
+
+ if(fread(buffer, 1, imagesize, f) != imagesize)
+ {
+ free(buffer);
+ return NULL;
+ }
+ fclose(f);
+ return buffer;
+}
diff --git a/native/lib/esUtil.h b/native/lib/esUtil.h index acbcf8c..7c8ad0c 100644 --- a/native/lib/esUtil.h +++ b/native/lib/esUtil.h @@ -1,141 +1,158 @@ -// -// Book: OpenGL(R) ES 2.0 Programming Guide -// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner -// ISBN-10: 0321502795 -// ISBN-13: 9780321502797 -// Publisher: Addison-Wesley Professional -// URLs: http://safari.informit.com/9780321563835 -// http://www.opengles-book.com -// - -/* - * (c) 2009 Aaftab Munshi, Dan Ginsburg, Dave Shreiner - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -// -/// \file ESUtil.h -/// \brief A utility library for OpenGL ES. This library provides a -/// basic common framework for the example applications in the -/// OpenGL ES 2.0 Programming Guide. -// -#ifndef ESUTIL_H -#define ESUTIL_H - -/// -// Includes -// -#include <GLES2/gl2.h> -#include <EGL/egl.h> - -#ifdef __cplusplus - -extern "C" { -#endif - -#define ESUTIL_API - -/// -// Types -// - -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif - -typedef struct -{ - GLfloat m[4][4]; -} ESMatrix; - -// -/// \brief multiply matrix specified by result with a scaling matrix and return new matrix in result -/// \param result Specifies the input matrix. Scaled matrix is returned in result. -/// \param sx, sy, sz Scale factors along the x, y and z axes respectively -// -void ESUTIL_API esScale(ESMatrix *result, GLfloat sx, GLfloat sy, GLfloat sz); - -// -/// \brief multiply matrix specified by result with a translation matrix and return new matrix in result -/// \param result Specifies the input matrix. Translated matrix is returned in result. -/// \param tx, ty, tz Scale factors along the x, y and z axes respectively -// -void ESUTIL_API esTranslate(ESMatrix *result, GLfloat tx, GLfloat ty, GLfloat tz); - -// -/// \brief multiply matrix specified by result with a rotation matrix and return new matrix in result -/// \param result Specifies the input matrix. Rotated matrix is returned in result. -/// \param angle Specifies the angle of rotation, in degrees. -/// \param x, y, z Specify the x, y and z coordinates of a vector, respectively -// -void ESUTIL_API esRotate(ESMatrix *result, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); - -// -// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result -/// \param result Specifies the input matrix. new matrix is returned in result. -/// \param left, right Coordinates for the left and right vertical clipping planes -/// \param bottom, top Coordinates for the bottom and top horizontal clipping planes -/// \param nearZ, farZ Distances to the near and far depth clipping planes. Both distances must be positive. -// -void ESUTIL_API esFrustum(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ); - -// -/// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result -/// \param result Specifies the input matrix. new matrix is returned in result. -/// \param fovy Field of view y angle in degrees -/// \param aspect Aspect ratio of screen -/// \param nearZ Near plane distance -/// \param farZ Far plane distance -// -void ESUTIL_API esPerspective(ESMatrix *result, float fovy, float aspect, float nearZ, float farZ); - -// -/// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result -/// \param result Specifies the input matrix. new matrix is returned in result. -/// \param left, right Coordinates for the left and right vertical clipping planes -/// \param bottom, top Coordinates for the bottom and top horizontal clipping planes -/// \param nearZ, farZ Distances to the near and far depth clipping planes. These values are negative if plane is behind the viewer -// -void ESUTIL_API esOrtho(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ); - -// -/// \brief perform the following operation - result matrix = srcA matrix * srcB matrix -/// \param result Returns multiplied matrix -/// \param srcA, srcB Input matrices to be multiplied -// -void ESUTIL_API esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB); - -// -//// \brief return an indentity matrix -//// \param result returns identity matrix -// -void ESUTIL_API esMatrixLoadIdentity(ESMatrix *result); - -void ESUTIL_API esMatrixInverse3x3(ESMatrix *result, ESMatrix *input); -void ESUTIL_API esMatrixTranspose(ESMatrix *result, ESMatrix *input); - -#ifdef __cplusplus -} -#endif - -#endif // ESUTIL_H +//
+// Book: OpenGL(R) ES 2.0 Programming Guide
+// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
+// ISBN-10: 0321502795
+// ISBN-13: 9780321502797
+// Publisher: Addison-Wesley Professional
+// URLs: http://safari.informit.com/9780321563835
+// http://www.opengles-book.com
+//
+
+//
+/// \file ESUtil.h
+/// \brief A utility library for OpenGL ES. This library provides a
+/// basic common framework for the example applications in the
+/// OpenGL ES 2.0 Programming Guide.
+//
+#ifndef ESUTIL_H
+#define ESUTIL_H
+
+///
+// Includes
+//
+#include <GLES2/gl2.h>
+#include <EGL/egl.h>
+
+#ifdef __cplusplus
+
+extern "C" {
+#endif
+
+
+///
+// Macros
+//
+#define ESUTIL_API
+#define ESCALLBACK
+
+
+/// esCreateWindow flag - RGB color buffer
+#define ES_WINDOW_RGB 0
+/// esCreateWindow flag - ALPHA color buffer
+#define ES_WINDOW_ALPHA 1
+/// esCreateWindow flag - depth buffer
+#define ES_WINDOW_DEPTH 2
+/// esCreateWindow flag - stencil buffer
+#define ES_WINDOW_STENCIL 4
+/// esCreateWindow flat - multi-sample buffer
+#define ES_WINDOW_MULTISAMPLE 8
+
+
+///
+// Types
+//
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+typedef struct _escontext
+{
+ /// Put your user data here...
+ void* userData;
+
+ /// Window width
+ GLint width;
+
+ /// Window height
+ GLint height;
+
+ /// Window handle
+ EGLNativeWindowType hWnd;
+
+ /// EGL display
+ EGLDisplay eglDisplay;
+
+ /// EGL context
+ EGLContext eglContext;
+
+ /// EGL surface
+ EGLSurface eglSurface;
+
+ /// Exit flag
+ int terminate;
+
+ /// Callbacks
+ void (ESCALLBACK *drawFunc) ( struct _escontext * );
+ void (ESCALLBACK *keyFunc) ( struct _escontext *, unsigned char, int, int );
+ void (ESCALLBACK *updateFunc) ( struct _escontext *, float deltaTime );
+} ESContext;
+
+
+///
+// Public Functions
+//
+
+//
+///
+/// \brief Initialize ES framework context. This must be called before calling any other functions.
+/// \param esContext Application context
+//
+void ESUTIL_API esInitContext ( ESContext *esContext );
+
+//
+/// \brief Create a window with the specified parameters
+/// \param esContext Application context
+/// \param title Name for title bar of window
+/// \param width Width in pixels of window to create
+/// \param height Height in pixels of window to create
+/// \param flags Bitfield for the window creation flags
+/// ES_WINDOW_RGB - specifies that the color buffer should have R,G,B channels
+/// ES_WINDOW_ALPHA - specifies that the color buffer should have alpha
+/// ES_WINDOW_DEPTH - specifies that a depth buffer should be created
+/// ES_WINDOW_STENCIL - specifies that a stencil buffer should be created
+/// ES_WINDOW_MULTISAMPLE - specifies that a multi-sample buffer should be created
+/// \return GL_TRUE if window creation is succesful, GL_FALSE otherwise
+GLboolean ESUTIL_API esCreateWindow ( ESContext *esContext, const char *title, GLint width, GLint height, GLuint flags );
+
+//
+/// \brief Start the main loop for the OpenGL ES application
+/// \param esContext Application context
+//
+void ESUTIL_API esMainLoop ( ESContext *esContext );
+
+//
+/// \brief Register a draw callback function to be used to render each frame
+/// \param esContext Application context
+/// \param drawFunc Draw callback function that will be used to render the scene
+//
+void ESUTIL_API esRegisterDrawFunc ( ESContext *esContext, void (ESCALLBACK *drawFunc) ( ESContext* ) );
+
+//
+/// \brief Register an update callback function to be used to update on each time step
+/// \param esContext Application context
+/// \param updateFunc Update callback function that will be used to render the scene
+//
+void ESUTIL_API esRegisterUpdateFunc ( ESContext *esContext, void (ESCALLBACK *updateFunc) ( ESContext*, float ) );
+
+//
+/// \brief Register an keyboard input processing callback function
+/// \param esContext Application context
+/// \param keyFunc Key callback function for application processing of keyboard input
+//
+void ESUTIL_API esRegisterKeyFunc ( ESContext *esContext,
+ void (ESCALLBACK *drawFunc) ( ESContext*, unsigned char, int, int ) );
+//
+/// \brief Log a message to the debug output for the platform
+/// \param formatStr Format string for error log.
+//
+void ESUTIL_API esLogMessage ( const char *formatStr, ... );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // ESUTIL_H
diff --git a/native/lib/etna.c b/native/lib/etna.c index 9975a99..c351a54 100644 --- a/native/lib/etna.c +++ b/native/lib/etna.c @@ -110,9 +110,8 @@ static int initialize_gpu_context(gcoCONTEXT vctx) int etna_create(etna_ctx **ctx_out) { if(ctx_out == NULL) return ETNA_INVALID_ADDR; - etna_ctx *ctx = malloc(sizeof(etna_ctx)); + etna_ctx *ctx = ETNA_NEW(etna_ctx); if(ctx == NULL) return ETNA_OUT_OF_MEMORY; - memset(ctx, 0, sizeof(etna_ctx)); if(initialize_gpu_context(&ctx->ctx) != ETNA_OK) { diff --git a/native/lib/etna.h b/native/lib/etna.h index f37029b..348dd7e 100644 --- a/native/lib/etna.h +++ b/native/lib/etna.h @@ -57,6 +57,9 @@ #define BEGIN_COMMIT_CLEARANCE 32 #define END_COMMIT_CLEARANCE 24 +#define ETNA_NEW(type) calloc(1, sizeof(type)) +#define ETNA_FREE(ptr) free(ptr) + /** Structure definitions */ typedef enum _etna_status { ETNA_OK, diff --git a/native/lib/etna_bswap.c b/native/lib/etna_bswap.c new file mode 100644 index 0000000..529a9c1 --- /dev/null +++ b/native/lib/etna_bswap.c @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2012-2013 Etnaviv Project + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include "etna_bswap.h" + +#include "viv.h" +#include "etna.h" + +#include <stdio.h> + +static int etna_bswap_init_buffer(etna_bswap_buffer *buf) +{ + pthread_mutex_init(&buf->available_mutex, NULL); + pthread_cond_init(&buf->available_cond, NULL); + + buf->is_available = 1; + if(viv_user_signal_create(0, &buf->sig_id_ready) != 0) + { +#ifdef DEBUG + fprintf(stderr, "Cannot create user signal for framebuffer sync\n"); +#endif + return ETNA_INTERNAL_ERROR; + } + return ETNA_OK; +} + +static void etna_bswap_destroy_buffer(etna_bswap_buffer *buf) +{ + (void)pthread_mutex_destroy(&buf->available_mutex); + (void)pthread_cond_destroy(&buf->available_cond); + (void)viv_user_signal_destroy(buf->sig_id_ready); +} + +static void etna_bswap_thread(etna_bswap_buffers *bufs) +{ + int cur = 0; + while(!bufs->terminate) + { + /* wait for "buffer ready" signal for buffer X (and clear it) */ + if(viv_user_signal_wait(bufs->buf[cur].sig_id_ready, SIG_WAIT_INDEFINITE) != 0) + { +#ifdef DEBUG + fprintf(stderr, "Error waiting for framebuffer sync signal\n"); +#endif + return; // ? + } + /* switch buffers */ + bufs->set_buffer(bufs->userptr, cur); + bufs->frontbuffer = cur; + /* X = (X+1)%buffers */ + cur = (cur+1) % ETNA_BSWAP_NUM_BUFFERS; + /* set "buffer available" for buffer X, signal condition */ + pthread_mutex_lock(&bufs->buf[cur].available_mutex); + bufs->buf[cur].is_available = 1; + pthread_cond_signal(&bufs->buf[cur].available_cond); + pthread_mutex_unlock(&bufs->buf[cur].available_mutex); + } +} + +int etna_bswap_create(etna_bswap_buffers **bufs_out, int (*set_buffer)(void *, int), void *userptr) +{ + if(bufs_out == NULL) + return ETNA_INVALID_ADDR; + etna_bswap_buffers *bufs = ETNA_NEW(etna_bswap_buffers); + if(bufs == NULL) + return ETNA_INTERNAL_ERROR; + bufs->set_buffer = set_buffer; + bufs->userptr = userptr; + bufs->backbuffer = bufs->frontbuffer = 0; + bufs->terminate = false; + for(int idx=0; idx<ETNA_BSWAP_NUM_BUFFERS; ++idx) + etna_bswap_init_buffer(&bufs->buf[idx]); + pthread_create(&bufs->thread, NULL, (void * (*)(void *))&etna_bswap_thread, bufs); + + *bufs_out = bufs; + return ETNA_OK; +} + +int etna_bswap_free(etna_bswap_buffers *bufs) +{ + bufs->terminate = true; + /* signal ready signals, to prevent thread from waiting forever for buffer to become ready */ + for(int idx=0; idx<ETNA_BSWAP_NUM_BUFFERS; ++idx) + (void)viv_user_signal_signal(bufs->buf[idx].sig_id_ready, 1); + (void)pthread_join(bufs->thread, NULL); + for(int idx=0; idx<ETNA_BSWAP_NUM_BUFFERS; ++idx) + etna_bswap_destroy_buffer(&bufs->buf[idx]); + ETNA_FREE(bufs); + return ETNA_OK; +} + +/* wait until current backbuffer is available to render to */ +int etna_bswap_wait_available(etna_bswap_buffers *bufs) +{ + etna_bswap_buffer *buf = &bufs->buf[bufs->backbuffer]; + /* Wait until buffer buf is available */ + pthread_mutex_lock(&buf->available_mutex); + while(!buf->is_available) + { + pthread_cond_wait(&buf->available_cond, &buf->available_mutex); + } + pthread_mutex_unlock(&buf->available_mutex); + return ETNA_OK; +} + +/* queue buffer swap when GPU ready with rendering to buf */ +int etna_bswap_queue_swap(etna_bswap_buffers *bufs) +{ + if(viv_event_queue_signal(bufs->buf[bufs->backbuffer].sig_id_ready, gcvKERNEL_PIXEL) != 0) + { +#ifdef DEBUG + fprintf(stderr, "Unable to queue framebuffer sync signal\n"); +#endif + return ETNA_INTERNAL_ERROR; + } + bufs->backbuffer = (bufs->backbuffer + 1) % ETNA_BSWAP_NUM_BUFFERS; + return ETNA_OK; +} + + diff --git a/native/lib/etna_bswap.h b/native/lib/etna_bswap.h new file mode 100644 index 0000000..0b72086 --- /dev/null +++ b/native/lib/etna_bswap.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2012-2013 Etnaviv Project + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/* Automatic buffer swapping */ +#ifndef H_ETNA_BUFSWAP +#define H_ETNA_BUFSWAP + +#include <pthread.h> +#include <stdbool.h> + +#define ETNA_BSWAP_NUM_BUFFERS 2 + +typedef struct _etna_bswap_buffer { + pthread_mutex_t available_mutex; + pthread_cond_t available_cond; + bool is_available; + int sig_id_ready; +} etna_bswap_buffer; + +typedef struct _etna_bswap_buffers { + pthread_t thread; + int backbuffer, frontbuffer; + bool terminate; + + int (*set_buffer)(void *, int); + void *userptr; + etna_bswap_buffer buf[ETNA_BSWAP_NUM_BUFFERS]; +} etna_bswap_buffers; + +int etna_bswap_create(etna_bswap_buffers **bufs_out, int (*set_buffer)(void *, int), void *userptr); + +int etna_bswap_free(etna_bswap_buffers *bufs); + +int etna_bswap_wait_available(etna_bswap_buffers *bufs); + +int etna_bswap_queue_swap(etna_bswap_buffers *bufs); + +#endif + diff --git a/native/lib/etna_fb.c b/native/lib/etna_fb.c index 143b0d1..76b94b4 100644 --- a/native/lib/etna_fb.c +++ b/native/lib/etna_fb.c @@ -87,8 +87,8 @@ int fb_open(int num, fb_info *out) out->map = mmap(NULL, out->fb_fix.smem_len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); printf(" mmap: %p\n", out->map); - if(out->num_buffers > FB_MAX_BUFFERS) - out->num_buffers = FB_MAX_BUFFERS; + if(out->num_buffers > ETNA_FB_MAX_BUFFERS) + out->num_buffers = ETNA_FB_MAX_BUFFERS; for(int idx=0; idx<out->num_buffers; ++idx) { out->physical[idx] = out->fb_fix.smem_start + idx * out->buffer_stride; @@ -111,3 +111,9 @@ int fb_set_buffer(fb_info *fb, int buffer) return 0; } +int fb_close(fb_info *fb) +{ + close(fb->fd); + return 0; +} + diff --git a/native/lib/etna_fb.h b/native/lib/etna_fb.h index 233b849..7097679 100644 --- a/native/lib/etna_fb.h +++ b/native/lib/etna_fb.h @@ -27,13 +27,13 @@ #include <stdint.h> #include <linux/fb.h> -#define FB_MAX_BUFFERS (4) +#define ETNA_FB_MAX_BUFFERS (4) typedef struct { int fd; int num_buffers; - size_t physical[FB_MAX_BUFFERS]; - void *logical[FB_MAX_BUFFERS]; + size_t physical[ETNA_FB_MAX_BUFFERS]; + void *logical[ETNA_FB_MAX_BUFFERS]; size_t stride; size_t buffer_stride; struct fb_var_screeninfo fb_var; @@ -47,5 +47,8 @@ int fb_open(int num, fb_info *out); /* Set currently visible buffer id */ int fb_set_buffer(fb_info *fb, int buffer); +/* Close framebuffer */ +int fb_close(fb_info *fb); + #endif diff --git a/native/lib/etna_mem.c b/native/lib/etna_mem.c index a5ce84a..80fc65e 100644 --- a/native/lib/etna_mem.c +++ b/native/lib/etna_mem.c @@ -30,8 +30,7 @@ int etna_vidmem_alloc_linear(etna_vidmem **mem_out, size_t bytes, gceSURF_TYPE type, gcePOOL pool, bool lock) { if(mem_out == NULL) return ETNA_INVALID_ADDR; - etna_vidmem *mem = malloc(sizeof(etna_vidmem)); - memset(mem, 0, sizeof(etna_vidmem)); + etna_vidmem *mem = ETNA_NEW(etna_vidmem); if(mem == NULL) return ETNA_OUT_OF_MEMORY; mem->type = type; @@ -101,8 +100,7 @@ int etna_vidmem_free(etna_vidmem *mem) int etna_usermem_map(etna_usermem **mem_out, void *memory, size_t size) { if(mem_out == NULL) return ETNA_INVALID_ADDR; - etna_usermem *mem = malloc(sizeof(etna_usermem)); - memset(mem, 0, sizeof(etna_usermem)); + etna_usermem *mem = ETNA_NEW(etna_usermem); mem->memory = memory; mem->size = size; diff --git a/native/lib/flightrecorder.cpp b/native/lib/flightrecorder.cpp index 0ed81cc..43069dd 100644 --- a/native/lib/flightrecorder.cpp +++ b/native/lib/flightrecorder.cpp @@ -30,8 +30,13 @@ #include <sys/stat.h> #include <string.h> #include <fcntl.h> +#include <stdint.h> +#include <stdlib.h> -//#include <stdio.h> +//#define DEBUG +#ifdef DEBUG +#include <stdio.h> +#endif #include <vector> #include <string> @@ -64,7 +69,7 @@ typedef std::vector<fdr_parameters> ParameterList; inline void write_record_type(int fd, uint8_t record_type) { - write(fd, &record_type, sizeof(uint8_t)); + (void)write(fd, &record_type, sizeof(uint8_t)); } class Event { @@ -76,7 +81,8 @@ public: ParameterList parameters; Event(const char *event_type): valid(true) { - strlcpy(this->event_type, event_type, ID_LEN); + strncpy(this->event_type, event_type, ID_LEN); + this->event_type[ID_LEN-1] = 0; } ~Event() {} @@ -85,7 +91,8 @@ public: flightrec_status add_parameter(const char *name, size_t value) { fdr_parameters params = {}; - strlcpy(params.name, name, ID_LEN); + strncpy(params.name, name, ID_LEN); + params.name[ID_LEN-1] = 0; params.value = value; parameters.push_back(params); return FDR_OK; @@ -122,9 +129,9 @@ class FlightRecorder { void write_mem_range(size_t start, size_t end) { write_record_type(fd, RTYPE_RANGE_DATA); - write(fd, &start, sizeof(size_t)); - write(fd, &end, sizeof(size_t)); - write(fd, (void*)start, end - start); + (void)write(fd, &start, sizeof(size_t)); + (void)write(fd, &end, sizeof(size_t)); + (void)write(fd, (void*)start, end - start); } /* Binary diff between two memory areas. @@ -135,7 +142,9 @@ class FlightRecorder { size_t mismatch_start = 0; size_t mismatch_end = 0; bool in_difference = false; +#ifdef DEBUG //printf("bdiff %08x %08x %08x %08x\n", (uint32_t)from, (uint32_t)to, (uint32_t)size, (uint32_t)granularity); +#endif for(size_t ptr = 0; ptr < size; ptr += granularity) { size_t compsize = std::min(size-ptr, granularity); @@ -182,7 +191,9 @@ class FlightRecorder { * so that we can compare against it later. */ void *block = malloc(i->end - i->start); memcpy(block, (void*)i->start, i->end - i->start); - +#ifdef DEBUG + printf("storing %p: %p %p\n", block, i->start, i->end); +#endif stored.insert(std::make_pair(*i, block)); } else { if(j->first.start != i->start || j->first.end != i->end) @@ -245,12 +256,15 @@ public: flightrec_status add_monitored_range(size_t addr_start, size_t addr_end) { pthread_mutex_lock(&mutex); +#ifdef DEBUG + printf("-> add_monitored_range %p %p\n", addr_start, addr_end); +#endif std::pair<MemIntervalSet::iterator, bool> rv = persistent.insert(MemInterval(addr_start, addr_end)); if(rv.second) { write_record_type(fd, RTYPE_ADD_UPDATED_RANGE); - write(fd, &addr_start, sizeof(size_t)); - write(fd, &addr_end, sizeof(size_t)); + (void)write(fd, &addr_start, sizeof(size_t)); + (void)write(fd, &addr_end, sizeof(size_t)); } pthread_mutex_unlock(&mutex); return rv.second ? FDR_OK : FDR_OVERLAP; @@ -264,8 +278,8 @@ public: if(ret) { write_record_type(fd, RTYPE_REMOVE_UPDATED_RANGE); - write(fd, &addr_start, sizeof(size_t)); - write(fd, &addr_end, sizeof(size_t)); + (void)write(fd, &addr_start, sizeof(size_t)); + (void)write(fd, &addr_end, sizeof(size_t)); } pthread_mutex_unlock(&mutex); return ret ? FDR_OK : FDR_NOT_FOUND; @@ -284,24 +298,24 @@ public: for(MemIntervalSet::const_iterator i=context->temp.begin(); i!=context->temp.end(); ++i) { write_record_type(fd, RTYPE_RANGE_TEMP_DATA); - write(fd, &i->start, sizeof(size_t)); - write(fd, &i->end, sizeof(size_t)); - write(fd, (void*)i->start, i->end - i->start); + (void)write(fd, &i->start, sizeof(size_t)); + (void)write(fd, &i->end, sizeof(size_t)); + (void)write(fd, (void*)i->start, i->end - i->start); } write_record_type(fd, RTYPE_EVENT); uint8_t name_len = strlen(context->event_type); - write(fd, &name_len, sizeof(uint8_t)); - write(fd, context->event_type, name_len); + (void)write(fd, &name_len, sizeof(uint8_t)); + (void)write(fd, context->event_type, name_len); /* log parameters */ - write(fd, &num_parameters, sizeof(uint32_t)); + (void)write(fd, &num_parameters, sizeof(uint32_t)); for(size_t i=0; i<num_parameters; ++i) { uint8_t name_len = strlen(context->parameters[i].name); - write(fd, &name_len, sizeof(uint8_t)); - write(fd, context->parameters[i].name, name_len); - write(fd, &context->parameters[i].value, sizeof(size_t)); + (void)write(fd, &name_len, sizeof(uint8_t)); + (void)write(fd, context->parameters[i].name, name_len); + (void)write(fd, &context->parameters[i].value, sizeof(size_t)); } delete context; pthread_mutex_unlock(&mutex); @@ -312,8 +326,8 @@ public: { pthread_mutex_lock(&mutex); write_record_type(fd, RTYPE_COMMENT); - write(fd, &size, sizeof(size_t)); - write(fd, data, size); + (void)write(fd, &size, sizeof(size_t)); + (void)write(fd, data, size); pthread_mutex_unlock(&mutex); return FDR_OK; } @@ -348,6 +362,8 @@ flightrec_status fdr_remove_monitored_range(flightrec_t self, void *addr_start, flightrec_event_t fdr_new_event(flightrec_t self, const char *event_type) { + if(self == NULL) + return NULL; Event *rv = new Event(event_type); if(rv->is_valid()) { return (flightrec_event_t) rv; diff --git a/native/lib/viv_hook.c b/native/lib/viv_hook.c index cbe9875..a33bf67 100644 --- a/native/lib/viv_hook.c +++ b/native/lib/viv_hook.c @@ -44,6 +44,9 @@ #include <sys/stat.h> #include <sys/mman.h> #include <stdarg.h> +#include <stdint.h> +#include <string.h> +#include <sys/ioctl.h> flightrec_t _fdr; @@ -170,14 +173,12 @@ void log_interface_in(flightrec_event_t evctx, gcsHAL_INTERFACE *id) case gcvHAL_COMMIT: fdr_event_add_oneshot_range(evctx, id->u.Commit.commandBuffer, sizeof(struct _gcoCMDBUF)); //fdr_event_add_oneshot_range(evctx, id->u.Commit.commandBuffer->logical, id->u.Commit.commandBuffer->offset); -#ifndef V4 +#ifndef GCABI_v4 fdr_event_add_oneshot_range(evctx, id->u.Commit.contextBuffer, sizeof(struct _gcoCONTEXT)); if(id->u.Commit.contextBuffer->map) /* state map */ fdr_event_add_oneshot_range(evctx, id->u.Commit.contextBuffer->map, id->u.Commit.contextBuffer->stateCount*4); if(id->u.Commit.contextBuffer->buffer) /* context command temp buffer */ fdr_event_add_oneshot_range(evctx, id->u.Commit.contextBuffer->buffer, id->u.Commit.contextBuffer->bufferSize); - //if(id->u.Commit.contextBuffer->logical) /* context command gpu buffer */ - // fdr_event_add_oneshot_range(evctx, id->u.Commit.contextBuffer->logical, id->u.Commit.contextBuffer->bufferSize); #endif break; case gcvHAL_EVENT_COMMIT: { /* log entire event chain */ @@ -279,7 +280,6 @@ int my_ioctl(int d, int request, vivante_ioctl_data_t *ptr) fdr_event_add_oneshot_range(evctx, ptr->in_buf, ptr->in_buf_size); log_interface_in(evctx, ptr->in_buf); fdr_log_event(_fdr, evctx); - /* if gcvHAL_LOCK_VIDEO_MEMORY, look up size in node */ } ret = ioctl(d, request, ptr); if(request == IOCTL_GCHAL_INTERFACE) @@ -303,14 +303,13 @@ void the_hook(const char *filename) char *mali_path = NULL; // path to libMali.so void *mali_base = NULL; - _fdr = fdr_open("/mnt/sdcard/egl2.fdr"); + _fdr = fdr_open(filename); if(parse_maps("libGAL.so", &mali_path, &mali_base)) { fprintf(stderr, "Could not find libMali library in process map\n"); return; } - printf("Mali base is %p\n", mali_base); printf("Hooking %s at %p\n", mali_path, mali_base); if(elf_hook(mali_path, mali_base, "open", &my_open) == NULL) @@ -339,5 +338,6 @@ void the_hook(const char *filename) void close_hook() { fdr_close(_fdr); + _fdr = 0; } diff --git a/native/lib/write_bmp.c b/native/lib/write_bmp.c index 5038e30..8e898df 100644 --- a/native/lib/write_bmp.c +++ b/native/lib/write_bmp.c @@ -107,7 +107,7 @@ bmp_dump32(char *buffer, unsigned width, unsigned height, bool bgra, const char { int fd; - fd = open(filename, O_WRONLY| O_TRUNC | O_CREAT); + fd = open(filename, O_WRONLY| O_TRUNC | O_CREAT, 0666); if (fd == -1) { printf("Failed to open %s: %s\n", filename, strerror(errno)); return; diff --git a/native/replay/Makefile b/native/replay/Makefile index 4174a69..401eab2 100644 --- a/native/replay/Makefile +++ b/native/replay/Makefile @@ -2,14 +2,12 @@ TOP=.. include $(TOP)/Makefile.inc -CXXABI = armeabi-v7a -COMMON_FLAGS = -I$(TOP)/lib -I$(TOP)/include_v2 -g -std=c99 -fPIC -I../resources -I ../include -CFLAGS += $(COMMON_FLAGS) -CXXFLAGS += $(COMMON_FLAGS) -I$(NDK)/sources/cxx-stl/gnu-libstdc++/4.6/include -I$(NDK)/sources/cxx-stl/gnu-libstdc++/4.6/libs/$(CXXABI)/include -LDFLAGS += -L$(NDK)/sources/cxx-stl/gnu-libstdc++/4.6/libs/$(CXXABI) -lgnustl_static - -TARGETS = cube cube_companion cube_etna ps_sandbox_etna etna_test reset -GL_LIBS = -L$(TOP)/lib -L$(TOP)/lib/egl -Xlinker --allow-shlib-undefined -lm +COMMON_FLAGS = -I$(TOP)/lib -I$(TOP)/include_$(GCABI) -g -std=c99 -fPIC -I../resources -I ../include -DGC_$(GCABI) +CFLAGS += $(COMMON_FLAGS) +CXXFLAGS += $(COMMON_FLAGS) +LDFLAGS += -lm + +TARGETS = cube cube_companion cube_etna ps_sandbox_etna etna_test reset viv_info COMPANION_OBJS = ../resources/companion_array.o ../resources/companion_mesh.o ../resources/companion_texture.o all: $(TARGETS) @@ -19,20 +17,23 @@ clean: rm -f $(TARGETS) cube: cube.o ../lib/write_bmp.o ../lib/viv.o - $(CC) $(CFLAGS) -o $@ $^ $(GL_LIBS) $(LDFLAGS) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) cube_companion: cube_companion.o ../lib/write_bmp.o ../lib/viv.o $(COMPANION_OBJS) - $(CC) $(CFLAGS) -o $@ $^ $(GL_LIBS) $(LDFLAGS) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) cube_etna: cube_etna.o ../lib/write_bmp.o ../lib/viv.o ../lib/esTransform.o - $(CC) $(CFLAGS) -o $@ $^ $(GL_LIBS) $(LDFLAGS) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) ps_sandbox_etna: ps_sandbox_etna.o ../lib/write_bmp.o ../lib/viv.o ../lib/esTransform.o - $(CC) $(CFLAGS) -o $@ $^ $(GL_LIBS) $(LDFLAGS) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) etna_test: etna_test.o ../lib/write_bmp.o ../lib/viv.o ../lib/esTransform.o ../lib/etna.o ../lib/etna_rs.o ../lib/etna_mem.o - $(CC) $(CFLAGS) -o $@ $^ $(GL_LIBS) $(LDFLAGS) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) reset: reset.o ../lib/viv.o - $(CC) $(CFLAGS) -o $@ $^ $(GL_LIBS) $(LDFLAGS) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) + +viv_info: viv_info.o + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) diff --git a/native/replay/cube.c b/native/replay/cube.c index b46106e..68a77fe 100644 --- a/native/replay/cube.c +++ b/native/replay/cube.c @@ -7,6 +7,7 @@ #include <sys/stat.h> #include <sys/mman.h> #include <stdarg.h> +#include <string.h> #include "write_bmp.h" #include "viv.h" diff --git a/native/replay/cube_etna.c b/native/replay/cube_etna.c index f4f2d25..365653c 100644 --- a/native/replay/cube_etna.c +++ b/native/replay/cube_etna.c @@ -13,7 +13,7 @@ #include "etna/cmdstream.xml.h" #include "write_bmp.h" #include "viv.h" -#include "esUtil.h" +#include "esTransform.h" /* Print generated command buffer */ //#define CMD_DEBUG diff --git a/native/replay/etna_test.c b/native/replay/etna_test.c index e0511a5..f621a8b 100644 --- a/native/replay/etna_test.c +++ b/native/replay/etna_test.c @@ -20,7 +20,7 @@ #include "etna_rs.h" #include "etna_mem.h" -#include "esUtil.h" +#include "esTransform.h" GLfloat vVertices[] = { -1.0f, -1.0f, +0.0f, diff --git a/native/replay/ps_sandbox_etna.c b/native/replay/ps_sandbox_etna.c index b7e21d5..5ca1eee 100644 --- a/native/replay/ps_sandbox_etna.c +++ b/native/replay/ps_sandbox_etna.c @@ -13,7 +13,7 @@ #include "etna/cmdstream.xml.h" #include "write_bmp.h" #include "viv.h" -#include "esUtil.h" +#include "esTransform.h" /* Print generated command buffer */ //#define CMD_DEBUG diff --git a/native/replay/viv_info.c b/native/replay/viv_info.c new file mode 100644 index 0000000..1c847bb --- /dev/null +++ b/native/replay/viv_info.c @@ -0,0 +1,339 @@ +/* Get info about vivante device */ +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <stdbool.h> +#include <string.h> + +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/ioctl.h> +#include <fcntl.h> +#include <unistd.h> + +#include "gc_hal_base.h" +#include "gc_hal.h" +#include "gc_hal_driver.h" + +const char *galcore_device = "/dev/galcore"; + +typedef struct +{ + void *in_buf; + uint32_t in_buf_size; + void *out_buf; + uint32_t out_buf_size; +} vivante_ioctl_data_t; + +const char *vivante_chipFeatures[32] = { + /*0 */ "FAST_CLEAR", + /*1 */ "SPECIAL_ANTI_ALIASING", + /*2 */ "PIPE_3D", + /*3 */ "DXT_TEXTURE_COMPRESSION", + /*4 */ "DEBUG_MODE", + /*5 */ "Z_COMPRESSION", + /*6 */ "YUV420_SCALER", + /*7 */ "MSAA", + /*8 */ "DC", + /*9 */ "PIPE_2D", + /*10*/ "ETC1_TEXTURE_COMPRESSION", + /*11*/ "FAST_SCALER", + /*12*/ "HIGH_DYNAMIC_RANGE", + /*13*/ "YUV420_TILER", + /*14*/ "MODULE_CG", + /*15*/ "MIN_AREA", + /*16*/ "NO_EARLY_Z", + /*17*/ "NO_422_TEXTURE", + /*18*/ "BUFFER_INTERLEAVING", + /*19*/ "BYTE_WRITE_2D", + /*20*/ "NO_SCALER", + /*21*/ "YUY2_AVERAGING", + /*22*/ "HALF_PE_CACHE", + /*23*/ "HALF_TX_CACHE", + /*24*/ "YUY2_RENDER_TARGET", + /*25*/ "MEM32", + /*26*/ "PIPE_VG", + /*27*/ "VGTS", + /*28*/ "FE20", + /*29*/ "BYTE_WRITE_3D", + /*30*/ "RS_YUV_TARGET", + /*31*/ "32_BIT_INDICES" +}; + +const char *vivante_chipMinorFeatures0[32] = { + /*0 */ "FLIP_Y", + /*1 */ "DUAL_RETURN_BUS", + /*2 */ "ENDIANNESS_CONFIG", + /*3 */ "TEXTURE_8K", + /*4 */ "CORRECT_TEXTURE_CONVERTER", + /*5 */ "SPECIAL_MSAA_LOD", + /*6 */ "FAST_CLEAR_FLUSH", + /*7 */ "2DPE20", + /*8 */ "CORRECT_AUTO_DISABLE", + /*9 */ "RENDERTARGET_8K", + /*10*/ "2BITPERTILE", + /*11*/ "SEPARATE_TILE_STATUS_WHEN_INTERLEAVED", + /*12*/ "SUPER_TILED", + /*13*/ "VG_20", + /*14*/ "TS_EXTENDED_COMMANDS", + /*15*/ "COMPRESSION_FIFO_FIXED", + /*16*/ "HAS_SIGN_FLOOR_CEIL", + /*17*/ "VG_FILTER", + /*18*/ "VG_21", + /*19*/ "SHADER_HAS_W", + /*20*/ "HAS_SQRT_TRIG", + /*21*/ "MORE_MINOR_FEATURES", + /*22*/ "MC20", + /*23*/ "MSAA_SIDEBAND", + /*24*/ "BUG_FIXES0", + /*25*/ "VAA", + /*26*/ "BYPASS_IN_MSAA", + /*27*/ "HZ", + /*28*/ "NEW_TEXTURE", + /*29*/ "2D_A8_TARGET", + /*30*/ "CORRECT_STENCIL", + /*31*/ "ENHANCE_VR" +}; + +const char *vivante_chipMinorFeatures1[32] = { + /*0 */ "RSUV_SWIZZLE", + /*1 */ "V2_COMPRESSION", + /*2 */ "VG_DOUBLE_BUFFER", + /*3 */ "EXTRA_EVENT_STATES", + /*4 */ "NO_STRIPING_NEEDED", + /*5 */ "TEXTURE_STRIDE", + /*6 */ "BUG_FIXES3", + /*7 */ "AUTO_DISABLE", + /*8 */ "AUTO_RESTART_TS", + /*9 */ "DISABLE_PE_GATING", + /*10*/ "L2_WINDOWING", + /*11*/ "HALF_FLOAT", + /*12*/ "PIXEL_DITHER", + /*13*/ "TWO_STENCIL_REFERENCE", + /*14*/ "EXTENDED_PIXEL_FORMAT", + /*15*/ "CORRECT_MIN_MAX_DEPTH", + /*16*/ "2D_DITHER", + /*17*/ "BUG_FIXES5", + /*18*/ "NEW_2D", + /*19*/ "NEW_FP", + /*20*/ "TEXTURE_ALIGN_4", + /*21*/ "NON_POWER_OF_TWO", + /*22*/ "LINEAR_TEXTURE_SUPPORT", + /*23*/ "HALTI0", + /*24*/ "CORRECT_OVERFLOW_VG", + /*25*/ "NEGATIVE_LOG_FIX", + /*26*/ "RESOLVE_OFFSET", + /*27*/ "OK_TO_GATE_AXI_CLOCK", + /*28*/ "MMU_VERSION", + /*29*/ "WIDE_LINE", + /*30*/ "UBUG_FIXES6", + /*31*/ "FC_FLUSH_STALL" +}; + +const char *vivante_chipMinorFeatures2[32] = { + /*0 */ "LINE_LOOP", + /*1 */ "LOGIC_OP", + /*2 */ "UNKNOWN_2", + /*3 */ "SUPERTILED_TEXTURE", + /*4 */ "UNKNOWN_4", + /*5 */ "RECT_PRIMITIVE", + /*6 */ "COMPOSITION", + /*7 */ "CORRECT_AUTO_DISABLE_COUNT", + /*8 */ "UNKNOWN_8", + /*9 */ "UNKNOWN_9", + /*10*/ "UNKNOWN_10", + /*11*/ "SAMPLERBASE_16", + /*12*/ "UNKNOWN_12", + /*13*/ "UNKNOWN_13", + /*14*/ "UNKNOWN_14", + /*15*/ "EXTRA_TEXTURE_STATE", + /*16*/ "FULL_DIRECTFB", + /*17*/ "2D_OPF", + /*18*/ "THREAD_WALKER_IN_PS", + /*19*/ "TILE_FILLER", + /*20*/ "UNKNOWN_20", + /*21*/ "2D_MULTI_SOURCE_BLIT", + /*22*/ "UNKNOWN_22", + /*23*/ "UNKNOWN_23", + /*24*/ "UNKNOWN_24", + /*25*/ "MIXED_STREAMS", + /*26*/ "2D_420_L2CACHE", + /*27*/ "UNKNOWN_27", + /*28*/ "2D_NO_INDEX8_BRUSH", + /*29*/ "TEXTURE_TILED_READ", + /*30*/ "UNKNOWN_30", + /*31*/ "UNKNOWN_31" +}; + +const char *vivante_power_state(gceCHIPPOWERSTATE state) +{ + switch(state) + { + case gcvPOWER_ON: return "ON"; + case gcvPOWER_OFF: return "OFF"; + case gcvPOWER_IDLE: return "IDLE"; + case gcvPOWER_SUSPEND: return "SUSPEND"; +#ifndef GC_dove + case gcvPOWER_ON_BROADCAST: return "ON_BROADCAST"; +#endif + case gcvPOWER_SUSPEND_ATPOWERON: return "SUSPEND_ATPOWERON"; + case gcvPOWER_OFF_ATPOWERON: return "OFF_ATPOWERON"; + case gcvPOWER_IDLE_BROADCAST: return "IDLE_BROADCAST"; + case gcvPOWER_SUSPEND_BROADCAST: return "SUSPEND_BROADCAST"; + case gcvPOWER_OFF_BROADCAST: return "OFF_BROADCAST"; + case gcvPOWER_OFF_RECOVERY: return "OFF_RECOVERY"; + default: + return "UNKNOWN"; + } +} + +int main() +{ + gcsHAL_INTERFACE id = {}; + vivante_ioctl_data_t ic = {}; + int fd = -1; + int rv = 0; + + fd = open(galcore_device, O_RDWR); + if(fd < 0) + { + perror("Cannot open device"); + exit(1); + } + + memset((void*)&id, 0, sizeof(id)); + id.command = gcvHAL_QUERY_CHIP_IDENTITY; + +#ifndef GC_dove + // Size must be 64 to work on Rockchip + ic.in_buf = &id; + ic.in_buf_size = 64;//sizeof(id); + ic.out_buf = &id; + ic.out_buf_size = 64;//sizeof(id); +#else + ic.in_buf = &id; + ic.in_buf_size = sizeof(id); + ic.out_buf = &id; + ic.out_buf_size = sizeof(id); +#endif + printf("gcsHAL_INTERFACE size real %i sending %i\n", sizeof(id), ic.in_buf_size); + + rv = ioctl(fd, IOCTL_GCHAL_INTERFACE, &ic); + if(rv < 0) + { + perror("Ioctl error"); + exit(1); + } + + printf("* Chip identity:\n"); + printf("Chip model: %08x\n", id.u.QueryChipIdentity.chipModel); + printf("Chip revision: %08x\n", id.u.QueryChipIdentity.chipRevision); + printf("Chip features: 0x%08x\n", id.u.QueryChipIdentity.chipFeatures); + for(int i=0; i<32; ++i) + { + bool flag = id.u.QueryChipIdentity.chipFeatures & (1 << i); + printf(" %c %s\n", flag?'+':'-', vivante_chipFeatures[i]); + } + printf("\n"); + printf("Chip minor features 0: 0x%08x\n", id.u.QueryChipIdentity.chipMinorFeatures); + for(int i=0; i<32; ++i) + { + bool flag = id.u.QueryChipIdentity.chipMinorFeatures & (1 << i); + printf(" %c %s\n", flag?'+':'-', vivante_chipMinorFeatures0[i]); + } + printf("\n"); + printf("Chip minor features 1: 0x%08x\n", id.u.QueryChipIdentity.chipMinorFeatures1); + for(int i=0; i<32; ++i) + { + bool flag = id.u.QueryChipIdentity.chipMinorFeatures1 & (1 << i); + printf(" %c %s\n", flag?'+':'-', vivante_chipMinorFeatures1[i]); + } + printf("\n"); +#ifndef GC_dove + printf("Chip minor features 2: 0x%08x\n", id.u.QueryChipIdentity.chipMinorFeatures2); + for(int i=0; i<32; ++i) + { + bool flag = id.u.QueryChipIdentity.chipMinorFeatures2 & (1 << i); + printf(" %c %s\n", flag?'+':'-', vivante_chipMinorFeatures2[i]); + } +#endif + printf("\n"); + //printf("Chip minor features 3: 0x%08x\n", id.u.QueryChipIdentity.chipMinorFeatures3); + printf("Stream count: 0x%08x\n", id.u.QueryChipIdentity.streamCount); + printf("Register max: 0x%08x\n", id.u.QueryChipIdentity.registerMax); + printf("Thread count: 0x%08x\n", id.u.QueryChipIdentity.threadCount); + printf("Shader core count: 0x%08x\n", id.u.QueryChipIdentity.shaderCoreCount); + printf("Vertex cache size: 0x%08x\n", id.u.QueryChipIdentity.vertexCacheSize); + printf("Vertex output buffer size: 0x%08x\n", id.u.QueryChipIdentity.vertexOutputBufferSize); + printf("\n"); + /*printf("Pixel pipes: 0x%08x\n", id.u.QueryChipIdentity.pixelPipes); + printf("Instruction count: 0x%08x\n", id.u.QueryChipIdentity.instructionCount); + printf("Num constants: 0x%08x\n", id.u.QueryChipIdentity.numConstants); + printf("Buffer size: 0x%08x\n", id.u.QueryChipIdentity.bufferSize); + */ + // + memset((void*)&id, 0, sizeof(id)); + id.command = gcvHAL_QUERY_VIDEO_MEMORY; + + rv = ioctl(fd, IOCTL_GCHAL_INTERFACE, &ic); + if(rv < 0) + { + perror("Ioctl error"); + exit(1); + } + + printf("* Video memory:\n"); + printf("Internal physical: 0x%08x\n", (unsigned)id.u.QueryVideoMemory.internalPhysical); + printf("Internal size: 0x%08x\n", (unsigned)id.u.QueryVideoMemory.internalSize); + printf("External physical: %08x\n", (unsigned)id.u.QueryVideoMemory.externalPhysical); + printf("External size: 0x%08x\n", (unsigned)id.u.QueryVideoMemory.externalSize); + printf("Contiguous physical: 0x%08x\n", (unsigned)id.u.QueryVideoMemory.contiguousPhysical); + printf("Contiguous size: 0x%08x\n", (unsigned)id.u.QueryVideoMemory.contiguousSize); + printf("\n"); + + memset((void*)&id, 0, sizeof(id)); + id.command = gcvHAL_QUERY_POWER_MANAGEMENT_STATE; + rv = ioctl(fd, IOCTL_GCHAL_INTERFACE, &ic); + if(rv < 0) + { + perror("Ioctl error"); + exit(1); + } + + printf("* Power management:\n"); + printf("Power state: %s\n", vivante_power_state(id.u.QueryPowerManagement.state)); + printf("Is idle: %s\n", id.u.QueryPowerManagement.isIdle?"yes":"no"); + printf("\n"); + + memset((void*)&id, 0, sizeof(id)); + id.command = gcvHAL_QUERY_KERNEL_SETTINGS; + rv = ioctl(fd, IOCTL_GCHAL_INTERFACE, &ic); + if(rv < 0) + { + perror("Ioctl error"); + exit(1); + } + + printf("* Kernel settings\n"); + printf("Use realtime signal: %08x\n", id.u.QueryKernelSettings.settings.signal); + printf("\n"); + + id.command = gcvHAL_GET_BASE_ADDRESS; + memset((void*)&id, 0, sizeof(id)); + rv = ioctl(fd, IOCTL_GCHAL_INTERFACE, &ic); + if(rv < 0) + { + perror("Ioctl error"); + exit(1); + } + printf("* Base address\n"); + printf("Physical address of internal memory: %08x\n", id.u.GetBaseAddress.baseAddress); + printf("\n"); + + + close(fd); + + + return 0; +} + diff --git a/rnndb/state.xml b/rnndb/state.xml index 682f376..597f6fd 100644 --- a/rnndb/state.xml +++ b/rnndb/state.xml @@ -1303,7 +1303,7 @@ xsi:schemaLocation="http://nouveau.freedesktop.org/ rules-ng.xsd"> <!-- PIPE_3D states --> <stripe name="VS" brief="Vertex shader states"> - <doc>The vertex shader to use is configured here.</doc> + <doc>The vertex shader to be used for 3D rendering is configured here.</doc> <reg32 offset="0x00800" name="END_PC" value="0x00000000" brief="End instruction number"> <doc>index of last instruction + 1</doc> </reg32> @@ -1477,7 +1477,8 @@ xsi:schemaLocation="http://nouveau.freedesktop.org/ rules-ng.xsd"> </stripe> <stripe name="PE" brief="Pixel Engine states"> - <doc>The Pixel Engine takes care of fragment (pixel) processing. + <doc>The Pixel Engine takes care of writing pixels to the framebuffer, doing + blending, depth testing and alpha testing if needed. Some flags can be set either per group of bits, or all at once, by using masking flags. Each group of state flags has a masking flag that when set prevents overwriting the flags in that group. @@ -1881,8 +1882,8 @@ xsi:schemaLocation="http://nouveau.freedesktop.org/ rules-ng.xsd"> </bitfield> <bitfield high="30" low="21" name="BIAS" type="fixedp" brief="LOD bias"> <doc> - This fixed-point value is added to the computed LOD level. It appears that it can also be - negative by using two's complement arithmetic. + This fixed-point value is added to the computed LOD level when BIAS_ENABLE is on. + It appears that it can also be negative by using two's complement arithmetic. </doc> </bitfield> </bitset> diff --git a/tools/data/gcs_hal_interface_dove.json b/tools/data/gcs_hal_interface_dove.json new file mode 100644 index 0000000..4e2a334 --- /dev/null +++ b/tools/data/gcs_hal_interface_dove.json @@ -0,0 +1,3091 @@ +{ + "_gceCHIPMODEL": { + "byte_size": 4, + "enumerators": [ + { + "name": "gcv300", + "value": 768 + }, + { + "name": "gcv400", + "value": 1024 + }, + { + "name": "gcv410", + "value": 1040 + }, + { + "name": "gcv450", + "value": 1104 + }, + { + "name": "gcv500", + "value": 1280 + }, + { + "name": "gcv530", + "value": 1328 + }, + { + "name": "gcv600", + "value": 1536 + }, + { + "name": "gcv700", + "value": 1792 + }, + { + "name": "gcv800", + "value": 2048 + }, + { + "name": "gcv860", + "value": 2144 + }, + { + "name": "gcv1000", + "value": 4096 + } + ], + "kind": "enumeration_type", + "name": "_gceCHIPMODEL" + }, + "_gceCHIPPOWERSTATE": { + "byte_size": 4, + "enumerators": [ + { + "name": "gcvPOWER_ON", + "value": 0 + }, + { + "name": "gcvPOWER_OFF", + "value": 1 + }, + { + "name": "gcvPOWER_IDLE", + "value": 2 + }, + { + "name": "gcvPOWER_SUSPEND", + "value": 3 + }, + { + "name": "gcvPOWER_SUSPEND_ATPOWERON", + "value": 4 + }, + { + "name": "gcvPOWER_OFF_ATPOWERON", + "value": 5 + }, + { + "name": "gcvPOWER_IDLE_BROADCAST", + "value": 6 + }, + { + "name": "gcvPOWER_SUSPEND_BROADCAST", + "value": 7 + }, + { + "name": "gcvPOWER_OFF_BROADCAST", + "value": 8 + }, + { + "name": "gcvPOWER_OFF_RECOVERY", + "value": 9 + } + ], + "kind": "enumeration_type", + "name": "_gceCHIPPOWERSTATE" + }, + "_gceHAL_COMMAND_CODES": { + "byte_size": 4, + "enumerators": [ + { + "name": "gcvHAL_QUERY_VIDEO_MEMORY", + "value": 0 + }, + { + "name": "gcvHAL_QUERY_CHIP_IDENTITY", + "value": 1 + }, + { + "name": "gcvHAL_ALLOCATE_NON_PAGED_MEMORY", + "value": 2 + }, + { + "name": "gcvHAL_FREE_NON_PAGED_MEMORY", + "value": 3 + }, + { + "name": "gcvHAL_ALLOCATE_CONTIGUOUS_MEMORY", + "value": 4 + }, + { + "name": "gcvHAL_FREE_CONTIGUOUS_MEMORY", + "value": 5 + }, + { + "name": "gcvHAL_ALLOCATE_VIDEO_MEMORY", + "value": 6 + }, + { + "name": "gcvHAL_ALLOCATE_LINEAR_VIDEO_MEMORY", + "value": 7 + }, + { + "name": "gcvHAL_FREE_VIDEO_MEMORY", + "value": 8 + }, + { + "name": "gcvHAL_MAP_MEMORY", + "value": 9 + }, + { + "name": "gcvHAL_UNMAP_MEMORY", + "value": 10 + }, + { + "name": "gcvHAL_MAP_USER_MEMORY", + "value": 11 + }, + { + "name": "gcvHAL_UNMAP_USER_MEMORY", + "value": 12 + }, + { + "name": "gcvHAL_LOCK_VIDEO_MEMORY", + "value": 13 + }, + { + "name": "gcvHAL_UNLOCK_VIDEO_MEMORY", + "value": 14 + }, + { + "name": "gcvHAL_EVENT_COMMIT", + "value": 15 + }, + { + "name": "gcvHAL_USER_SIGNAL", + "value": 16 + }, + { + "name": "gcvHAL_SIGNAL", + "value": 17 + }, + { + "name": "gcvHAL_WRITE_DATA", + "value": 18 + }, + { + "name": "gcvHAL_COMMIT", + "value": 19 + }, + { + "name": "gcvHAL_STALL", + "value": 20 + }, + { + "name": "gcvHAL_READ_REGISTER", + "value": 21 + }, + { + "name": "gcvHAL_WRITE_REGISTER", + "value": 22 + }, + { + "name": "gcvHAL_GET_PROFILE_SETTING", + "value": 23 + }, + { + "name": "gcvHAL_SET_PROFILE_SETTING", + "value": 24 + }, + { + "name": "gcvHAL_READ_ALL_PROFILE_REGISTERS", + "value": 25 + }, + { + "name": "gcvHAL_PROFILE_REGISTERS_2D", + "value": 26 + }, + { + "name": "gcvHAL_SET_POWER_MANAGEMENT_STATE", + "value": 27 + }, + { + "name": "gcvHAL_QUERY_POWER_MANAGEMENT_STATE", + "value": 28 + }, + { + "name": "gcvHAL_GET_BASE_ADDRESS", + "value": 29 + }, + { + "name": "gcvHAL_SET_IDLE", + "value": 30 + }, + { + "name": "gcvHAL_QUERY_KERNEL_SETTINGS", + "value": 31 + }, + { + "name": "gcvHAL_RESET", + "value": 32 + }, + { + "name": "gcvHAL_MAP_PHYSICAL", + "value": 33 + }, + { + "name": "gcvHAL_DEBUG", + "value": 34 + }, + { + "name": "gcvHAL_CACHE", + "value": 35 + }, + { + "name": "gcvHAL_GC_OFF", + "value": 36 + }, + { + "name": "gcvHAL_GC_ON", + "value": 37 + } + ], + "kind": "enumeration_type", + "name": "_gceHAL_COMMAND_CODES" + }, + "_gceKERNEL_WHERE": { + "byte_size": 4, + "enumerators": [ + { + "name": "gcvKERNEL_COMMAND", + "value": 0 + }, + { + "name": "gcvKERNEL_VERTEX", + "value": 1 + }, + { + "name": "gcvKERNEL_TRIANGLE", + "value": 2 + }, + { + "name": "gcvKERNEL_TEXTURE", + "value": 3 + }, + { + "name": "gcvKERNEL_PIXEL", + "value": 4 + } + ], + "kind": "enumeration_type", + "name": "_gceKERNEL_WHERE" + }, + "_gceOBJECT_TYPE": { + "byte_size": 4, + "enumerators": [ + { + "name": "gcvOBJ_UNKNOWN", + "value": 0 + }, + { + "name": "gcvOBJ_2D", + "value": 538985522 + }, + { + "name": "gcvOBJ_3D", + "value": 538985523 + }, + { + "name": "gcvOBJ_ATTRIBUTE", + "value": 1381258305 + }, + { + "name": "gcvOBJ_BRUSHCACHE", + "value": 609571394 + }, + { + "name": "gcvOBJ_BRUSHNODE", + "value": 1851085378 + }, + { + "name": "gcvOBJ_BRUSH", + "value": 1867862594 + }, + { + "name": "gcvOBJ_BUFFER", + "value": 1380341058 + }, + { + "name": "gcvOBJ_COMMAND", + "value": 541347139 + }, + { + "name": "gcvOBJ_COMMANDBUFFER", + "value": 1111772483 + }, + { + "name": "gcvOBJ_CONTEXT", + "value": 1415074883 + }, + { + "name": "gcvOBJ_CONTEXTBUFFER", + "value": 1113084995 + }, + { + "name": "gcvOBJ_DEVICE", + "value": 542524740 + }, + { + "name": "gcvOBJ_DUMP", + "value": 1347245380 + }, + { + "name": "gcvOBJ_EVENT", + "value": 1414420037 + }, + { + "name": "gcvOBJ_FUNCTION", + "value": 1129207110 + }, + { + "name": "gcvOBJ_HAL", + "value": 541868360 + }, + { + "name": "gcvOBJ_HARDWARE", + "value": 1146241352 + }, + { + "name": "gcvOBJ_HEAP", + "value": 1346454856 + }, + { + "name": "gcvOBJ_INDEX", + "value": 1480871497 + }, + { + "name": "gcvOBJ_INTERRUPT", + "value": 1381256777 + }, + { + "name": "gcvOBJ_KERNEL", + "value": 1314014539 + }, + { + "name": "gcvOBJ_MEMORYBUFFER", + "value": 1112360269 + }, + { + "name": "gcvOBJ_MMU", + "value": 542461261 + }, + { + "name": "gcvOBJ_OS", + "value": 538989391 + }, + { + "name": "gcvOBJ_OUTPUT", + "value": 1347704143 + }, + { + "name": "gcvOBJ_PAINT", + "value": 542395984 + }, + { + "name": "gcvOBJ_PATH", + "value": 1213481296 + }, + { + "name": "gcvOBJ_QUEUE", + "value": 541414737 + }, + { + "name": "gcvOBJ_SAMPLER", + "value": 1347240275 + }, + { + "name": "gcvOBJ_SHADER", + "value": 1380206675 + }, + { + "name": "gcvOBJ_STREAM", + "value": 1297241171 + }, + { + "name": "gcvOBJ_SURF", + "value": 1179800915 + }, + { + "name": "gcvOBJ_TEXTURE", + "value": 1381259348 + }, + { + "name": "gcvOBJ_UNIFORM", + "value": 1179209301 + }, + { + "name": "gcvOBJ_VARIABLE", + "value": 1230127446 + }, + { + "name": "gcvOBJ_VERTEX", + "value": 1481921110 + }, + { + "name": "gcvOBJ_VIDMEM", + "value": 1296387414 + }, + { + "name": "gcvOBJ_VG", + "value": 538986326 + } + ], + "kind": "enumeration_type", + "name": "_gceOBJECT_TYPE" + }, + "_gcePOOL": { + "byte_size": 4, + "enumerators": [ + { + "name": "gcvPOOL_UNKNOWN", + "value": 0 + }, + { + "name": "gcvPOOL_DEFAULT", + "value": 1 + }, + { + "name": "gcvPOOL_LOCAL", + "value": 2 + }, + { + "name": "gcvPOOL_LOCAL_INTERNAL", + "value": 3 + }, + { + "name": "gcvPOOL_LOCAL_EXTERNAL", + "value": 4 + }, + { + "name": "gcvPOOL_UNIFIED", + "value": 5 + }, + { + "name": "gcvPOOL_SYSTEM", + "value": 6 + }, + { + "name": "gcvPOOL_VIRTUAL", + "value": 7 + }, + { + "name": "gcvPOOL_USER", + "value": 8 + }, + { + "name": "gcvPOOL_CONTIGUOUS", + "value": 9 + } + ], + "kind": "enumeration_type", + "name": "_gcePOOL" + }, + "_gceSIGNAL_TYPE": { + "byte_size": 4, + "enumerators": [ + { + "name": "gcvSIGNAL_NOPE", + "value": 0 + }, + { + "name": "gcvSIGNAL_CONTEXT_GCU", + "value": 1 + }, + { + "name": "gcvSIGNAL_CONTEXT", + "value": 2 + }, + { + "name": "gcvSIGNAL_FENCE_GCU", + "value": 3 + }, + { + "name": "gcvSIGNAL_FENCE", + "value": 4 + }, + { + "name": "gcvSIGNAL_DISPLAY_START", + "value": 5 + }, + { + "name": "gcvSIGNAL_DISPLAY_STOP", + "value": 6 + }, + { + "name": "gcvSIGNAL_WORKER_THREAD", + "value": 7 + }, + { + "name": "gcvSIGNAL_SYNC", + "value": 8 + }, + { + "name": "gcvSIGNAL_SURFACE", + "value": 9 + }, + { + "name": "gcvSIGNAL_TEXTURE", + "value": 16 + }, + { + "name": "gcvSIGNAL_STREAM", + "value": 17 + }, + { + "name": "gcvSIGNAL_INDEX_GROUP", + "value": 18 + }, + { + "name": "gcvSIGNAL_RESERVE_MEM_GROUP", + "value": 19 + }, + { + "name": "gcvSIGNAL_CMD_BUFFER", + "value": 20 + }, + { + "name": "gcvSIGNAL_CONTEXT_BUFFER", + "value": 21 + }, + { + "name": "gcvSIGNAL_INDEX_DYNAMIC", + "value": 22 + }, + { + "name": "gcvSIGNAL_STREAM_DYNAMIC", + "value": 23 + }, + { + "name": "gcvSIGNAL_STALL", + "value": 24 + }, + { + "name": "gcvSIGNAL_RESERVED", + "value": 25 + } + ], + "kind": "enumeration_type", + "name": "_gceSIGNAL_TYPE" + }, + "_gceSTATUS": { + "byte_size": 4, + "enumerators": [ + { + "name": "gcvSTATUS_OK", + "value": 0 + }, + { + "name": "gcvSTATUS_FALSE", + "value": 0 + }, + { + "name": "gcvSTATUS_TRUE", + "value": 1 + }, + { + "name": "gcvSTATUS_NO_MORE_DATA", + "value": 2 + }, + { + "name": "gcvSTATUS_CACHED", + "value": 3 + }, + { + "name": "gcvSTATUS_MIPMAP_TOO_LARGE", + "value": 4 + }, + { + "name": "gcvSTATUS_NAME_NOT_FOUND", + "value": 5 + }, + { + "name": "gcvSTATUS_NOT_OUR_INTERRUPT", + "value": 6 + }, + { + "name": "gcvSTATUS_MISMATCH", + "value": 7 + }, + { + "name": "gcvSTATUS_MIPMAP_TOO_SMALL", + "value": 8 + }, + { + "name": "gcvSTATUS_LARGER", + "value": 9 + }, + { + "name": "gcvSTATUS_SMALLER", + "value": 10 + }, + { + "name": "gcvSTATUS_CHIP_NOT_READY", + "value": 11 + }, + { + "name": "gcvSTATUS_NEED_CONVERSION", + "value": 12 + }, + { + "name": "gcvSTATUS_SKIP", + "value": 13 + }, + { + "name": "gcvSTATUS_DATA_TOO_LARGE", + "value": 14 + }, + { + "name": "gcvSTATUS_INVALID_CONFIG", + "value": 15 + }, + { + "name": "gcvSTATUS_CHANGED", + "value": 16 + }, + { + "name": "gcvSTATUS_INVALID_ARGUMENT", + "value": -1 + }, + { + "name": "gcvSTATUS_INVALID_OBJECT", + "value": -2 + }, + { + "name": "gcvSTATUS_OUT_OF_MEMORY", + "value": -3 + }, + { + "name": "gcvSTATUS_MEMORY_LOCKED", + "value": -4 + }, + { + "name": "gcvSTATUS_MEMORY_UNLOCKED", + "value": -5 + }, + { + "name": "gcvSTATUS_HEAP_CORRUPTED", + "value": -6 + }, + { + "name": "gcvSTATUS_GENERIC_IO", + "value": -7 + }, + { + "name": "gcvSTATUS_INVALID_ADDRESS", + "value": -8 + }, + { + "name": "gcvSTATUS_CONTEXT_LOSSED", + "value": -9 + }, + { + "name": "gcvSTATUS_TOO_COMPLEX", + "value": -10 + }, + { + "name": "gcvSTATUS_BUFFER_TOO_SMALL", + "value": -11 + }, + { + "name": "gcvSTATUS_INTERFACE_ERROR", + "value": -12 + }, + { + "name": "gcvSTATUS_NOT_SUPPORTED", + "value": -13 + }, + { + "name": "gcvSTATUS_MORE_DATA", + "value": -14 + }, + { + "name": "gcvSTATUS_TIMEOUT", + "value": -15 + }, + { + "name": "gcvSTATUS_OUT_OF_RESOURCES", + "value": -16 + }, + { + "name": "gcvSTATUS_INVALID_DATA", + "value": -17 + }, + { + "name": "gcvSTATUS_INVALID_MIPMAP", + "value": -18 + }, + { + "name": "gcvSTATUS_NOT_FOUND", + "value": -19 + }, + { + "name": "gcvSTATUS_NOT_ALIGNED", + "value": -20 + }, + { + "name": "gcvSTATUS_INVALID_REQUEST", + "value": -21 + }, + { + "name": "gcvSTATUS_GPU_NOT_RESPONDING", + "value": -22 + }, + { + "name": "gcvSTATUS_GLOBAL_TYPE_MISMATCH", + "value": -1000 + }, + { + "name": "gcvSTATUS_TOO_MANY_ATTRIBUTES", + "value": -1001 + }, + { + "name": "gcvSTATUS_TOO_MANY_UNIFORMS", + "value": -1002 + }, + { + "name": "gcvSTATUS_TOO_MANY_VARYINGS", + "value": -1003 + }, + { + "name": "gcvSTATUS_UNDECLARED_VARYING", + "value": -1004 + }, + { + "name": "gcvSTATUS_VARYING_TYPE_MISMATCH", + "value": -1005 + }, + { + "name": "gcvSTATUS_MISSING_MAIN", + "value": -1006 + }, + { + "name": "gcvSTATUS_NAME_MISMATCH", + "value": -1007 + }, + { + "name": "gcvSTATUS_INVALID_INDEX", + "value": -1008 + } + ], + "kind": "enumeration_type", + "name": "_gceSTATUS" + }, + "_gceSURF_FORMAT": { + "byte_size": 4, + "enumerators": [ + { + "name": "gcvSURF_UNKNOWN", + "value": 0 + }, + { + "name": "gcvSURF_INDEX1", + "value": 100 + }, + { + "name": "gcvSURF_INDEX4", + "value": 101 + }, + { + "name": "gcvSURF_INDEX8", + "value": 102 + }, + { + "name": "gcvSURF_A2R2G2B2", + "value": 200 + }, + { + "name": "gcvSURF_R3G3B2", + "value": 201 + }, + { + "name": "gcvSURF_A8R3G3B2", + "value": 202 + }, + { + "name": "gcvSURF_X4R4G4B4", + "value": 203 + }, + { + "name": "gcvSURF_A4R4G4B4", + "value": 204 + }, + { + "name": "gcvSURF_R4G4B4A4", + "value": 205 + }, + { + "name": "gcvSURF_X1R5G5B5", + "value": 206 + }, + { + "name": "gcvSURF_A1R5G5B5", + "value": 207 + }, + { + "name": "gcvSURF_R5G5B5A1", + "value": 208 + }, + { + "name": "gcvSURF_R5G6B5", + "value": 209 + }, + { + "name": "gcvSURF_R8G8B8", + "value": 210 + }, + { + "name": "gcvSURF_X8R8G8B8", + "value": 211 + }, + { + "name": "gcvSURF_A8R8G8B8", + "value": 212 + }, + { + "name": "gcvSURF_R8G8B8A8", + "value": 213 + }, + { + "name": "gcvSURF_G8R8G8B8", + "value": 214 + }, + { + "name": "gcvSURF_R8G8B8G8", + "value": 215 + }, + { + "name": "gcvSURF_X2R10G10B10", + "value": 216 + }, + { + "name": "gcvSURF_A2R10G10B10", + "value": 217 + }, + { + "name": "gcvSURF_X12R12G12B12", + "value": 218 + }, + { + "name": "gcvSURF_A12R12G12B12", + "value": 219 + }, + { + "name": "gcvSURF_X16R16G16B16", + "value": 220 + }, + { + "name": "gcvSURF_A16R16G16B16", + "value": 221 + }, + { + "name": "gcvSURF_R8G8B8X8", + "value": 222 + }, + { + "name": "gcvSURF_R5G5B5X1", + "value": 223 + }, + { + "name": "gcvSURF_R4G4B4X4", + "value": 224 + }, + { + "name": "gcvSURF_A4B4G4R4", + "value": 300 + }, + { + "name": "gcvSURF_A1B5G5R5", + "value": 301 + }, + { + "name": "gcvSURF_B5G6R5", + "value": 302 + }, + { + "name": "gcvSURF_B8G8R8", + "value": 303 + }, + { + "name": "gcvSURF_X8B8G8R8", + "value": 304 + }, + { + "name": "gcvSURF_A8B8G8R8", + "value": 305 + }, + { + "name": "gcvSURF_A2B10G10R10", + "value": 306 + }, + { + "name": "gcvSURF_A16B16G16R16", + "value": 307 + }, + { + "name": "gcvSURF_G16R16", + "value": 308 + }, + { + "name": "gcvSURF_B4G4R4A4", + "value": 309 + }, + { + "name": "gcvSURF_B5G5R5A1", + "value": 310 + }, + { + "name": "gcvSURF_B8G8R8X8", + "value": 311 + }, + { + "name": "gcvSURF_B8G8R8A8", + "value": 312 + }, + { + "name": "gcvSURF_X4B4G4R4", + "value": 313 + }, + { + "name": "gcvSURF_X1B5G5R5", + "value": 314 + }, + { + "name": "gcvSURF_B4G4R4X4", + "value": 315 + }, + { + "name": "gcvSURF_B5G5R5X1", + "value": 316 + }, + { + "name": "gcvSURF_DXT1", + "value": 400 + }, + { + "name": "gcvSURF_DXT2", + "value": 401 + }, + { + "name": "gcvSURF_DXT3", + "value": 402 + }, + { + "name": "gcvSURF_DXT4", + "value": 403 + }, + { + "name": "gcvSURF_DXT5", + "value": 404 + }, + { + "name": "gcvSURF_CXV8U8", + "value": 405 + }, + { + "name": "gcvSURF_ETC1", + "value": 406 + }, + { + "name": "gcvSURF_YUY2", + "value": 500 + }, + { + "name": "gcvSURF_UYVY", + "value": 501 + }, + { + "name": "gcvSURF_YV12", + "value": 502 + }, + { + "name": "gcvSURF_I420", + "value": 503 + }, + { + "name": "gcvSURF_NV12", + "value": 504 + }, + { + "name": "gcvSURF_NV21", + "value": 505 + }, + { + "name": "gcvSURF_NV16", + "value": 506 + }, + { + "name": "gcvSURF_NV61", + "value": 507 + }, + { + "name": "gcvSURF_YVYU", + "value": 508 + }, + { + "name": "gcvSURF_VYUY", + "value": 509 + }, + { + "name": "gcvSURF_D16", + "value": 600 + }, + { + "name": "gcvSURF_D24S8", + "value": 601 + }, + { + "name": "gcvSURF_D32", + "value": 602 + }, + { + "name": "gcvSURF_D24X8", + "value": 603 + }, + { + "name": "gcvSURF_A4", + "value": 700 + }, + { + "name": "gcvSURF_A8", + "value": 701 + }, + { + "name": "gcvSURF_A12", + "value": 702 + }, + { + "name": "gcvSURF_A16", + "value": 703 + }, + { + "name": "gcvSURF_A32", + "value": 704 + }, + { + "name": "gcvSURF_A1", + "value": 705 + }, + { + "name": "gcvSURF_L4", + "value": 800 + }, + { + "name": "gcvSURF_L8", + "value": 801 + }, + { + "name": "gcvSURF_L12", + "value": 802 + }, + { + "name": "gcvSURF_L16", + "value": 803 + }, + { + "name": "gcvSURF_L32", + "value": 804 + }, + { + "name": "gcvSURF_L1", + "value": 805 + }, + { + "name": "gcvSURF_A4L4", + "value": 900 + }, + { + "name": "gcvSURF_A2L6", + "value": 901 + }, + { + "name": "gcvSURF_A8L8", + "value": 902 + }, + { + "name": "gcvSURF_A4L12", + "value": 903 + }, + { + "name": "gcvSURF_A12L12", + "value": 904 + }, + { + "name": "gcvSURF_A16L16", + "value": 905 + }, + { + "name": "gcvSURF_L6V5U5", + "value": 1000 + }, + { + "name": "gcvSURF_V8U8", + "value": 1001 + }, + { + "name": "gcvSURF_X8L8V8U8", + "value": 1002 + }, + { + "name": "gcvSURF_Q8W8V8U8", + "value": 1003 + }, + { + "name": "gcvSURF_A2W10V10U10", + "value": 1004 + }, + { + "name": "gcvSURF_V16U16", + "value": 1005 + }, + { + "name": "gcvSURF_Q16W16V16U16", + "value": 1006 + }, + { + "name": "gcvSURF_R16F", + "value": 1100 + }, + { + "name": "gcvSURF_G16R16F", + "value": 1101 + }, + { + "name": "gcvSURF_A16B16G16R16F", + "value": 1102 + }, + { + "name": "gcvSURF_R32F", + "value": 1103 + }, + { + "name": "gcvSURF_G32R32F", + "value": 1104 + }, + { + "name": "gcvSURF_A32B32G32R32F", + "value": 1105 + } + ], + "kind": "enumeration_type", + "name": "_gceSURF_FORMAT" + }, + "_gceSURF_TYPE": { + "byte_size": 4, + "enumerators": [ + { + "name": "gcvSURF_TYPE_UNKNOWN", + "value": 0 + }, + { + "name": "gcvSURF_INDEX", + "value": 1 + }, + { + "name": "gcvSURF_VERTEX", + "value": 2 + }, + { + "name": "gcvSURF_TEXTURE", + "value": 3 + }, + { + "name": "gcvSURF_RENDER_TARGET", + "value": 4 + }, + { + "name": "gcvSURF_DEPTH", + "value": 5 + }, + { + "name": "gcvSURF_BITMAP", + "value": 6 + }, + { + "name": "gcvSURF_TILE_STATUS", + "value": 7 + }, + { + "name": "gcvSURF_MASK", + "value": 8 + }, + { + "name": "gcvSURF_SCISSOR", + "value": 9 + }, + { + "name": "gcvSURF_HIERARCHICAL_DEPTH", + "value": 10 + }, + { + "name": "gcvSURF_NUM_TYPES", + "value": 11 + }, + { + "name": "gcvSURF_NO_TILE_STATUS", + "value": 256 + }, + { + "name": "gcvSURF_RENDER_TARGET_NO_TILE_STATUS", + "value": 260 + }, + { + "name": "gcvSURF_DEPTH_NO_TILE_STATUS", + "value": 261 + } + ], + "kind": "enumeration_type", + "name": "_gceSURF_TYPE" + }, + "_gceUSER_SIGNAL_COMMAND_CODES": { + "byte_size": 4, + "enumerators": [ + { + "name": "gcvUSER_SIGNAL_CREATE", + "value": 0 + }, + { + "name": "gcvUSER_SIGNAL_DESTROY", + "value": 1 + }, + { + "name": "gcvUSER_SIGNAL_SIGNAL", + "value": 2 + }, + { + "name": "gcvUSER_SIGNAL_WAIT", + "value": 3 + } + ], + "kind": "enumeration_type", + "name": "_gceUSER_SIGNAL_COMMAND_CODES" + }, + "_gcoCMDBUF": { + "byte_size": 36, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "object", + "offset": 0, + "type": "_gcsOBJECT" + }, + { + "indirection": 1, + "name": "os", + "offset": 4, + "type": "_gcoOS" + }, + { + "indirection": 1, + "name": "hardware", + "offset": 8, + "type": "_gcoHARDWARE" + }, + { + "indirection": 1, + "name": "physical", + "offset": 12, + "type": "void" + }, + { + "indirection": 1, + "name": "logical", + "offset": 16, + "type": "void" + }, + { + "indirection": 0, + "name": "bytes", + "offset": 20, + "type": "long unsigned int" + }, + { + "indirection": 0, + "name": "startOffset", + "offset": 24, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "offset", + "offset": 28, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "free", + "offset": 32, + "type": "long unsigned int" + } + ], + "name": "_gcoCMDBUF" + }, + "_gcoCONTEXT": { + "byte_size": 216, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "object", + "offset": 0, + "type": "_gcsOBJECT" + }, + { + "indirection": 1, + "name": "os", + "offset": 4, + "type": "_gcoOS" + }, + { + "indirection": 1, + "name": "hardware", + "offset": 8, + "type": "_gcoHARDWARE" + }, + { + "indirection": 0, + "name": "id", + "offset": 16, + "type": "long long unsigned int" + }, + { + "indirection": 1, + "name": "map", + "offset": 24, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "stateCount", + "offset": 28, + "type": "long unsigned int" + }, + { + "indirection": 1, + "name": "hint", + "offset": 32, + "type": "unsigned char" + }, + { + "indirection": 0, + "name": "hintValue", + "offset": 36, + "type": "unsigned char" + }, + { + "indirection": 0, + "name": "hintCount", + "offset": 40, + "type": "long unsigned int" + }, + { + "indirection": 1, + "name": "buffer", + "offset": 44, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "pipe3DIndex", + "offset": 48, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "pipe2DIndex", + "offset": 52, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "linkIndex", + "offset": 56, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "inUseIndex", + "offset": 60, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "bufferSize", + "offset": 64, + "type": "long unsigned int" + }, + { + "indirection": 0, + "name": "ctxbufArray", + "offset": 68, + "type": "array_type_7022" + }, + { + "indirection": 0, + "name": "ctxbufSignal", + "offset": 108, + "type": "array_type_7038" + }, + { + "indirection": 0, + "name": "ctxbufSize", + "offset": 148, + "type": "int" + }, + { + "indirection": 0, + "name": "ctxbufIndex", + "offset": 152, + "type": "int" + }, + { + "indirection": 1, + "name": "logical", + "offset": 156, + "type": "void" + }, + { + "indirection": 1, + "name": "link", + "offset": 160, + "type": "void" + }, + { + "indirection": 0, + "name": "initialPipe", + "offset": 164, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "entryPipe", + "offset": 168, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "currentPipe", + "offset": 172, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "postCommit", + "offset": 176, + "type": "int" + }, + { + "indirection": 1, + "name": "inUse", + "offset": 180, + "type": "int" + }, + { + "indirection": 0, + "name": "lastAddress", + "offset": 184, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "lastSize", + "offset": 188, + "type": "long unsigned int" + }, + { + "indirection": 0, + "name": "lastIndex", + "offset": 192, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "lastFixed", + "offset": 196, + "type": "int" + }, + { + "indirection": 1, + "name": "hintArray", + "offset": 200, + "type": "unsigned int" + }, + { + "indirection": 1, + "name": "hintIndex", + "offset": 204, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "skipContext", + "offset": 208, + "type": "int" + } + ], + "name": "_gcoCONTEXT" + }, + "_gcoHARDWARE": { + "byte_size": null, + "kind": "structure_type", + "members": [], + "name": "_gcoHARDWARE" + }, + "_gcoOS": { + "byte_size": null, + "kind": "structure_type", + "members": [], + "name": "_gcoOS" + }, + "_gcsHAL_ALLOCATE_CONTIGUOUS_MEMORY": { + "byte_size": 12, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "bytes", + "offset": 0, + "type": "long unsigned int" + }, + { + "indirection": 1, + "name": "physical", + "offset": 4, + "type": "void" + }, + { + "indirection": 1, + "name": "logical", + "offset": 8, + "type": "void" + } + ], + "name": "_gcsHAL_ALLOCATE_CONTIGUOUS_MEMORY" + }, + "_gcsHAL_ALLOCATE_LINEAR_VIDEO_MEMORY": { + "byte_size": 20, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "bytes", + "offset": 0, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "alignment", + "offset": 4, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "type", + "offset": 8, + "type": "_gceSURF_TYPE" + }, + { + "indirection": 0, + "name": "pool", + "offset": 12, + "type": "_gcePOOL" + }, + { + "indirection": 1, + "name": "node", + "offset": 16, + "type": "_gcuVIDMEM_NODE" + } + ], + "name": "_gcsHAL_ALLOCATE_LINEAR_VIDEO_MEMORY" + }, + "_gcsHAL_ALLOCATE_NON_PAGED_MEMORY": { + "byte_size": 12, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "bytes", + "offset": 0, + "type": "long unsigned int" + }, + { + "indirection": 1, + "name": "physical", + "offset": 4, + "type": "void" + }, + { + "indirection": 1, + "name": "logical", + "offset": 8, + "type": "void" + } + ], + "name": "_gcsHAL_ALLOCATE_NON_PAGED_MEMORY" + }, + "_gcsHAL_ALLOCATE_VIDEO_MEMORY": { + "byte_size": 28, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "width", + "offset": 0, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "height", + "offset": 4, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "depth", + "offset": 8, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "format", + "offset": 12, + "type": "_gceSURF_FORMAT" + }, + { + "indirection": 0, + "name": "type", + "offset": 16, + "type": "_gceSURF_TYPE" + }, + { + "indirection": 0, + "name": "pool", + "offset": 20, + "type": "_gcePOOL" + }, + { + "indirection": 1, + "name": "node", + "offset": 24, + "type": "_gcuVIDMEM_NODE" + } + ], + "name": "_gcsHAL_ALLOCATE_VIDEO_MEMORY" + }, + "_gcsHAL_CACHE": { + "byte_size": 16, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "invalidate", + "offset": 0, + "type": "int" + }, + { + "indirection": 1, + "name": "process", + "offset": 4, + "type": "void" + }, + { + "indirection": 1, + "name": "logical", + "offset": 8, + "type": "void" + }, + { + "indirection": 0, + "name": "bytes", + "offset": 12, + "type": "long unsigned int" + } + ], + "name": "_gcsHAL_CACHE" + }, + "_gcsHAL_COMMIT": { + "byte_size": 12, + "kind": "structure_type", + "members": [ + { + "indirection": 1, + "name": "commandBuffer", + "offset": 0, + "type": "_gcoCMDBUF" + }, + { + "indirection": 1, + "name": "contextBuffer", + "offset": 4, + "type": "_gcoCONTEXT" + }, + { + "indirection": 1, + "name": "process", + "offset": 8, + "type": "void" + } + ], + "name": "_gcsHAL_COMMIT" + }, + "_gcsHAL_DEBUG": { + "byte_size": 96, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "set", + "offset": 0, + "type": "int" + }, + { + "indirection": 0, + "name": "level", + "offset": 4, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "zones", + "offset": 8, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "enable", + "offset": 12, + "type": "int" + }, + { + "indirection": 0, + "name": "message", + "offset": 16, + "type": "array_type_6517" + } + ], + "name": "_gcsHAL_DEBUG" + }, + "_gcsHAL_EVENT_COMMIT": { + "byte_size": 4, + "kind": "structure_type", + "members": [ + { + "indirection": 1, + "name": "queue", + "offset": 0, + "type": "_gcsQUEUE" + } + ], + "name": "_gcsHAL_EVENT_COMMIT" + }, + "_gcsHAL_FREE_CONTIGUOUS_MEMORY": { + "byte_size": 12, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "bytes", + "offset": 0, + "type": "long unsigned int" + }, + { + "indirection": 1, + "name": "physical", + "offset": 4, + "type": "void" + }, + { + "indirection": 1, + "name": "logical", + "offset": 8, + "type": "void" + } + ], + "name": "_gcsHAL_FREE_CONTIGUOUS_MEMORY" + }, + "_gcsHAL_FREE_NON_PAGED_MEMORY": { + "byte_size": 12, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "bytes", + "offset": 0, + "type": "long unsigned int" + }, + { + "indirection": 1, + "name": "physical", + "offset": 4, + "type": "void" + }, + { + "indirection": 1, + "name": "logical", + "offset": 8, + "type": "void" + } + ], + "name": "_gcsHAL_FREE_NON_PAGED_MEMORY" + }, + "_gcsHAL_FREE_VIDEO_MEMORY": { + "byte_size": 4, + "kind": "structure_type", + "members": [ + { + "indirection": 1, + "name": "node", + "offset": 0, + "type": "_gcuVIDMEM_NODE" + } + ], + "name": "_gcsHAL_FREE_VIDEO_MEMORY" + }, + "_gcsHAL_GET_BASE_ADDRESS": { + "byte_size": 4, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "baseAddress", + "offset": 0, + "type": "unsigned int" + } + ], + "name": "_gcsHAL_GET_BASE_ADDRESS" + }, + "_gcsHAL_GET_PROFILE_SETTING": { + "byte_size": 132, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "enable", + "offset": 0, + "type": "int" + }, + { + "indirection": 0, + "name": "fileName", + "offset": 4, + "type": "array_type_6164" + } + ], + "name": "_gcsHAL_GET_PROFILE_SETTING" + }, + "_gcsHAL_INTERFACE": { + "byte_size": 216, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "command", + "offset": 0, + "type": "_gceHAL_COMMAND_CODES" + }, + { + "indirection": 0, + "name": "status", + "offset": 4, + "type": "_gceSTATUS" + }, + { + "indirection": 1, + "name": "handle", + "offset": 8, + "type": "void" + }, + { + "indirection": 0, + "name": "pid", + "offset": 12, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "u", + "offset": 16, + "type": "_u" + } + ], + "name": "_gcsHAL_INTERFACE" + }, + "_gcsHAL_LOCK_VIDEO_MEMORY": { + "byte_size": 12, + "kind": "structure_type", + "members": [ + { + "indirection": 1, + "name": "node", + "offset": 0, + "type": "_gcuVIDMEM_NODE" + }, + { + "indirection": 0, + "name": "address", + "offset": 4, + "type": "unsigned int" + }, + { + "indirection": 1, + "name": "memory", + "offset": 8, + "type": "void" + } + ], + "name": "_gcsHAL_LOCK_VIDEO_MEMORY" + }, + "_gcsHAL_MAP_MEMORY": { + "byte_size": 12, + "kind": "structure_type", + "members": [ + { + "indirection": 1, + "name": "physical", + "offset": 0, + "type": "void" + }, + { + "indirection": 0, + "name": "bytes", + "offset": 4, + "type": "long unsigned int" + }, + { + "indirection": 1, + "name": "logical", + "offset": 8, + "type": "void" + } + ], + "name": "_gcsHAL_MAP_MEMORY" + }, + "_gcsHAL_MAP_PHYSICAL": { + "byte_size": 8, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "map", + "offset": 0, + "type": "int" + }, + { + "indirection": 1, + "name": "physical", + "offset": 4, + "type": "void" + } + ], + "name": "_gcsHAL_MAP_PHYSICAL" + }, + "_gcsHAL_MAP_USER_MEMORY": { + "byte_size": 16, + "kind": "structure_type", + "members": [ + { + "indirection": 1, + "name": "memory", + "offset": 0, + "type": "void" + }, + { + "indirection": 0, + "name": "size", + "offset": 4, + "type": "long unsigned int" + }, + { + "indirection": 1, + "name": "info", + "offset": 8, + "type": "void" + }, + { + "indirection": 0, + "name": "address", + "offset": 12, + "type": "unsigned int" + } + ], + "name": "_gcsHAL_MAP_USER_MEMORY" + }, + "_gcsHAL_PROFILE_REGISTERS_2D": { + "byte_size": 4, + "kind": "structure_type", + "members": [ + { + "indirection": 1, + "name": "hwProfile2D", + "offset": 0, + "type": "gcs2D_PROFILE" + } + ], + "name": "_gcsHAL_PROFILE_REGISTERS_2D" + }, + "_gcsHAL_QUERY_CHIP_IDENTITY": { + "byte_size": 44, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "chipModel", + "offset": 0, + "type": "_gceCHIPMODEL" + }, + { + "indirection": 0, + "name": "chipRevision", + "offset": 4, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "chipFeatures", + "offset": 8, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "chipMinorFeatures", + "offset": 12, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "chipMinorFeatures1", + "offset": 16, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "streamCount", + "offset": 20, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "registerMax", + "offset": 24, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "threadCount", + "offset": 28, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "shaderCoreCount", + "offset": 32, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "vertexCacheSize", + "offset": 36, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "vertexOutputBufferSize", + "offset": 40, + "type": "unsigned int" + } + ], + "name": "_gcsHAL_QUERY_CHIP_IDENTITY" + }, + "_gcsHAL_QUERY_KERNEL_SETTINGS": { + "byte_size": 4, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "settings", + "offset": 0, + "type": "_gcsKERNEL_SETTINGS" + } + ], + "name": "_gcsHAL_QUERY_KERNEL_SETTINGS" + }, + "_gcsHAL_QUERY_POWER_MANAGEMENT": { + "byte_size": 8, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "state", + "offset": 0, + "type": "_gceCHIPPOWERSTATE" + }, + { + "indirection": 0, + "name": "isIdle", + "offset": 4, + "type": "int" + } + ], + "name": "_gcsHAL_QUERY_POWER_MANAGEMENT" + }, + "_gcsHAL_QUERY_VIDEO_MEMORY": { + "byte_size": 24, + "kind": "structure_type", + "members": [ + { + "indirection": 1, + "name": "internalPhysical", + "offset": 0, + "type": "void" + }, + { + "indirection": 0, + "name": "internalSize", + "offset": 4, + "type": "long unsigned int" + }, + { + "indirection": 1, + "name": "externalPhysical", + "offset": 8, + "type": "void" + }, + { + "indirection": 0, + "name": "externalSize", + "offset": 12, + "type": "long unsigned int" + }, + { + "indirection": 1, + "name": "contiguousPhysical", + "offset": 16, + "type": "void" + }, + { + "indirection": 0, + "name": "contiguousSize", + "offset": 20, + "type": "long unsigned int" + } + ], + "name": "_gcsHAL_QUERY_VIDEO_MEMORY" + }, + "_gcsHAL_READ_ALL_PROFILE_REGISTERS": { + "byte_size": 200, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "counters", + "offset": 0, + "type": "_gcsPROFILER_COUNTERS" + } + ], + "name": "_gcsHAL_READ_ALL_PROFILE_REGISTERS" + }, + "_gcsHAL_READ_REGISTER": { + "byte_size": 8, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "address", + "offset": 0, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "data", + "offset": 4, + "type": "unsigned int" + } + ], + "name": "_gcsHAL_READ_REGISTER" + }, + "_gcsHAL_SET_POWER_MANAGEMENT": { + "byte_size": 4, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "state", + "offset": 0, + "type": "_gceCHIPPOWERSTATE" + } + ], + "name": "_gcsHAL_SET_POWER_MANAGEMENT" + }, + "_gcsHAL_SET_PROFILE_SETTING": { + "byte_size": 132, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "enable", + "offset": 0, + "type": "int" + }, + { + "indirection": 0, + "name": "fileName", + "offset": 4, + "type": "array_type_6164" + } + ], + "name": "_gcsHAL_SET_PROFILE_SETTING" + }, + "_gcsHAL_SIGNAL": { + "byte_size": 16, + "kind": "structure_type", + "members": [ + { + "indirection": 1, + "name": "signal", + "offset": 0, + "type": "void" + }, + { + "indirection": 1, + "name": "auxSignal", + "offset": 4, + "type": "void" + }, + { + "indirection": 1, + "name": "process", + "offset": 8, + "type": "void" + }, + { + "indirection": 0, + "name": "fromWhere", + "offset": 12, + "type": "_gceKERNEL_WHERE" + } + ], + "name": "_gcsHAL_SIGNAL" + }, + "_gcsHAL_UNLOCK_VIDEO_MEMORY": { + "byte_size": 12, + "kind": "structure_type", + "members": [ + { + "indirection": 1, + "name": "node", + "offset": 0, + "type": "_gcuVIDMEM_NODE" + }, + { + "indirection": 0, + "name": "type", + "offset": 4, + "type": "_gceSURF_TYPE" + }, + { + "indirection": 0, + "name": "asynchroneous", + "offset": 8, + "type": "int" + } + ], + "name": "_gcsHAL_UNLOCK_VIDEO_MEMORY" + }, + "_gcsHAL_UNMAP_MEMORY": { + "byte_size": 12, + "kind": "structure_type", + "members": [ + { + "indirection": 1, + "name": "physical", + "offset": 0, + "type": "void" + }, + { + "indirection": 0, + "name": "bytes", + "offset": 4, + "type": "long unsigned int" + }, + { + "indirection": 1, + "name": "logical", + "offset": 8, + "type": "void" + } + ], + "name": "_gcsHAL_UNMAP_MEMORY" + }, + "_gcsHAL_UNMAP_USER_MEMORY": { + "byte_size": 16, + "kind": "structure_type", + "members": [ + { + "indirection": 1, + "name": "memory", + "offset": 0, + "type": "void" + }, + { + "indirection": 0, + "name": "size", + "offset": 4, + "type": "long unsigned int" + }, + { + "indirection": 1, + "name": "info", + "offset": 8, + "type": "void" + }, + { + "indirection": 0, + "name": "address", + "offset": 12, + "type": "unsigned int" + } + ], + "name": "_gcsHAL_UNMAP_USER_MEMORY" + }, + "_gcsHAL_USER_SIGNAL": { + "byte_size": 24, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "command", + "offset": 0, + "type": "_gceUSER_SIGNAL_COMMAND_CODES" + }, + { + "indirection": 0, + "name": "id", + "offset": 4, + "type": "int" + }, + { + "indirection": 0, + "name": "manualReset", + "offset": 8, + "type": "int" + }, + { + "indirection": 0, + "name": "signalType", + "offset": 12, + "type": "_gceSIGNAL_TYPE" + }, + { + "indirection": 0, + "name": "wait", + "offset": 16, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "state", + "offset": 20, + "type": "int" + } + ], + "name": "_gcsHAL_USER_SIGNAL" + }, + "_gcsHAL_WRITE_DATA": { + "byte_size": 12, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "address", + "offset": 0, + "type": "unsigned int" + }, + { + "indirection": 1, + "name": "kernelAddress", + "offset": 4, + "type": "void" + }, + { + "indirection": 0, + "name": "data", + "offset": 8, + "type": "unsigned int" + } + ], + "name": "_gcsHAL_WRITE_DATA" + }, + "_gcsHAL_WRITE_REGISTER": { + "byte_size": 8, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "address", + "offset": 0, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "data", + "offset": 4, + "type": "unsigned int" + } + ], + "name": "_gcsHAL_WRITE_REGISTER" + }, + "_gcsKERNEL_SETTINGS": { + "byte_size": 4, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "signal", + "offset": 0, + "type": "int" + } + ], + "name": "_gcsKERNEL_SETTINGS" + }, + "_gcsOBJECT": { + "byte_size": 4, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "type", + "offset": 0, + "type": "_gceOBJECT_TYPE" + } + ], + "name": "_gcsOBJECT" + }, + "_gcsPROFILER_COUNTERS": { + "byte_size": 200, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "gpuClock", + "offset": 0, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "axiClock", + "offset": 4, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "shaderClock", + "offset": 8, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "gpuClockStart", + "offset": 12, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "gpuClockEnd", + "offset": 16, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "gpuCyclesCounter", + "offset": 20, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "gpuTotalRead64BytesPerFrame", + "offset": 24, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "gpuTotalWrite64BytesPerFrame", + "offset": 28, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "pe_pixel_count_killed_by_color_pipe", + "offset": 32, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "pe_pixel_count_killed_by_depth_pipe", + "offset": 36, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "pe_pixel_count_drawn_by_color_pipe", + "offset": 40, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "pe_pixel_count_drawn_by_depth_pipe", + "offset": 44, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "ps_inst_counter", + "offset": 48, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "rendered_pixel_counter", + "offset": 52, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "vs_inst_counter", + "offset": 56, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "rendered_vertice_counter", + "offset": 60, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "vtx_branch_inst_counter", + "offset": 64, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "vtx_texld_inst_counter", + "offset": 68, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "pxl_branch_inst_counter", + "offset": 72, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "pxl_texld_inst_counter", + "offset": 76, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "pa_input_vtx_counter", + "offset": 80, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "pa_input_prim_counter", + "offset": 84, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "pa_output_prim_counter", + "offset": 88, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "pa_depth_clipped_counter", + "offset": 92, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "pa_trivial_rejected_counter", + "offset": 96, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "pa_culled_counter", + "offset": 100, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "se_culled_triangle_count", + "offset": 104, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "se_culled_lines_count", + "offset": 108, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "ra_valid_pixel_count", + "offset": 112, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "ra_total_quad_count", + "offset": 116, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "ra_valid_quad_count_after_early_z", + "offset": 120, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "ra_total_primitive_count", + "offset": 124, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "ra_pipe_cache_miss_counter", + "offset": 128, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "ra_prefetch_cache_miss_counter", + "offset": 132, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "ra_eez_culled_counter", + "offset": 136, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "tx_total_bilinear_requests", + "offset": 140, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "tx_total_trilinear_requests", + "offset": 144, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "tx_total_discarded_texture_requests", + "offset": 148, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "tx_total_texture_requests", + "offset": 152, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "tx_mem_read_count", + "offset": 156, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "tx_mem_read_in_8B_count", + "offset": 160, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "tx_cache_miss_count", + "offset": 164, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "tx_cache_hit_texel_count", + "offset": 168, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "tx_cache_miss_texel_count", + "offset": 172, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "mc_total_read_req_8B_from_pipeline", + "offset": 176, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "mc_total_read_req_8B_from_IP", + "offset": 180, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "mc_total_write_req_8B_from_pipeline", + "offset": 184, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "hi_axi_cycles_read_request_stalled", + "offset": 188, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "hi_axi_cycles_write_request_stalled", + "offset": 192, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "hi_axi_cycles_write_data_stalled", + "offset": 196, + "type": "unsigned int" + } + ], + "name": "_gcsPROFILER_COUNTERS" + }, + "_gcsQUEUE": { + "byte_size": 220, + "kind": "structure_type", + "members": [ + { + "indirection": 1, + "name": "next", + "offset": 0, + "type": "_gcsQUEUE" + }, + { + "indirection": 0, + "name": "iface", + "offset": 4, + "type": "_gcsHAL_INTERFACE" + } + ], + "name": "_gcsQUEUE" + }, + "_gcuVIDMEM_NODE": { + "byte_size": null, + "kind": "union_type", + "members": [], + "name": "_gcuVIDMEM_NODE" + }, + "_u": { + "byte_size": 200, + "kind": "union_type", + "members": [ + { + "indirection": 0, + "name": "GetBaseAddress", + "offset": 0, + "type": "_gcsHAL_GET_BASE_ADDRESS" + }, + { + "indirection": 0, + "name": "QueryVideoMemory", + "offset": 0, + "type": "_gcsHAL_QUERY_VIDEO_MEMORY" + }, + { + "indirection": 0, + "name": "QueryChipIdentity", + "offset": 0, + "type": "_gcsHAL_QUERY_CHIP_IDENTITY" + }, + { + "indirection": 0, + "name": "MapMemory", + "offset": 0, + "type": "_gcsHAL_MAP_MEMORY" + }, + { + "indirection": 0, + "name": "UnmapMemory", + "offset": 0, + "type": "_gcsHAL_UNMAP_MEMORY" + }, + { + "indirection": 0, + "name": "AllocateLinearVideoMemory", + "offset": 0, + "type": "_gcsHAL_ALLOCATE_LINEAR_VIDEO_MEMORY" + }, + { + "indirection": 0, + "name": "AllocateVideoMemory", + "offset": 0, + "type": "_gcsHAL_ALLOCATE_VIDEO_MEMORY" + }, + { + "indirection": 0, + "name": "FreeVideoMemory", + "offset": 0, + "type": "_gcsHAL_FREE_VIDEO_MEMORY" + }, + { + "indirection": 0, + "name": "LockVideoMemory", + "offset": 0, + "type": "_gcsHAL_LOCK_VIDEO_MEMORY" + }, + { + "indirection": 0, + "name": "UnlockVideoMemory", + "offset": 0, + "type": "_gcsHAL_UNLOCK_VIDEO_MEMORY" + }, + { + "indirection": 0, + "name": "AllocateNonPagedMemory", + "offset": 0, + "type": "_gcsHAL_ALLOCATE_NON_PAGED_MEMORY" + }, + { + "indirection": 0, + "name": "FreeNonPagedMemory", + "offset": 0, + "type": "_gcsHAL_FREE_NON_PAGED_MEMORY" + }, + { + "indirection": 0, + "name": "Event", + "offset": 0, + "type": "_gcsHAL_EVENT_COMMIT" + }, + { + "indirection": 0, + "name": "Commit", + "offset": 0, + "type": "_gcsHAL_COMMIT" + }, + { + "indirection": 0, + "name": "MapUserMemory", + "offset": 0, + "type": "_gcsHAL_MAP_USER_MEMORY" + }, + { + "indirection": 0, + "name": "UnmapUserMemory", + "offset": 0, + "type": "_gcsHAL_UNMAP_USER_MEMORY" + }, + { + "indirection": 0, + "name": "UserSignal", + "offset": 0, + "type": "_gcsHAL_USER_SIGNAL" + }, + { + "indirection": 0, + "name": "Signal", + "offset": 0, + "type": "_gcsHAL_SIGNAL" + }, + { + "indirection": 0, + "name": "WriteData", + "offset": 0, + "type": "_gcsHAL_WRITE_DATA" + }, + { + "indirection": 0, + "name": "AllocateContiguousMemory", + "offset": 0, + "type": "_gcsHAL_ALLOCATE_CONTIGUOUS_MEMORY" + }, + { + "indirection": 0, + "name": "FreeContiguousMemory", + "offset": 0, + "type": "_gcsHAL_FREE_CONTIGUOUS_MEMORY" + }, + { + "indirection": 0, + "name": "ReadRegisterData", + "offset": 0, + "type": "_gcsHAL_READ_REGISTER" + }, + { + "indirection": 0, + "name": "WriteRegisterData", + "offset": 0, + "type": "_gcsHAL_WRITE_REGISTER" + }, + { + "indirection": 0, + "name": "GetProfileSetting", + "offset": 0, + "type": "_gcsHAL_GET_PROFILE_SETTING" + }, + { + "indirection": 0, + "name": "SetProfileSetting", + "offset": 0, + "type": "_gcsHAL_SET_PROFILE_SETTING" + }, + { + "indirection": 0, + "name": "RegisterProfileData", + "offset": 0, + "type": "_gcsHAL_READ_ALL_PROFILE_REGISTERS" + }, + { + "indirection": 0, + "name": "RegisterProfileData2D", + "offset": 0, + "type": "_gcsHAL_PROFILE_REGISTERS_2D" + }, + { + "indirection": 0, + "name": "SetPowerManagement", + "offset": 0, + "type": "_gcsHAL_SET_POWER_MANAGEMENT" + }, + { + "indirection": 0, + "name": "QueryPowerManagement", + "offset": 0, + "type": "_gcsHAL_QUERY_POWER_MANAGEMENT" + }, + { + "indirection": 0, + "name": "QueryKernelSettings", + "offset": 0, + "type": "_gcsHAL_QUERY_KERNEL_SETTINGS" + }, + { + "indirection": 0, + "name": "MapPhysical", + "offset": 0, + "type": "_gcsHAL_MAP_PHYSICAL" + }, + { + "indirection": 0, + "name": "Debug", + "offset": 0, + "type": "_gcsHAL_DEBUG" + }, + { + "indirection": 0, + "name": "Cache", + "offset": 0, + "type": "_gcsHAL_CACHE" + } + ], + "name": "_u" + }, + "array_type_6164": { + "indirection": 0, + "kind": "array_type", + "length": 128, + "name": "array_type_6164", + "type": "char" + }, + "array_type_6517": { + "indirection": 0, + "kind": "array_type", + "length": 80, + "name": "array_type_6517", + "type": "char" + }, + "array_type_7022": { + "indirection": 1, + "kind": "array_type", + "length": 10, + "name": "array_type_7022", + "type": "_gcoCTXBUF" + }, + "array_type_7038": { + "indirection": 1, + "kind": "array_type", + "length": 10, + "name": "array_type_7038", + "type": "void" + }, + "gcs2D_PROFILE": { + "byte_size": 8, + "kind": "structure_type", + "members": [ + { + "indirection": 0, + "name": "cycleCount", + "offset": 0, + "type": "unsigned int" + }, + { + "indirection": 0, + "name": "pixelsRendered", + "offset": 4, + "type": "unsigned int" + } + ], + "name": "gcs2D_PROFILE" + }, + "int": { + "byte_size": 4, + "encoding": "signed", + "kind": "base_type", + "name": "int" + }, + "long long unsigned int": { + "byte_size": 8, + "encoding": "unsigned", + "kind": "base_type", + "name": "long long unsigned int" + }, + "long unsigned int": { + "byte_size": 4, + "encoding": "unsigned", + "kind": "base_type", + "name": "long unsigned int" + }, + "unsigned char": { + "byte_size": 1, + "encoding": "unsigned_char", + "kind": "base_type", + "name": "unsigned char" + }, + "unsigned int": { + "byte_size": 4, + "encoding": "unsigned", + "kind": "base_type", + "name": "unsigned int" + } +} |