diff --git a/deps/vitaGL/.clang-format b/deps/vitaGL/.clang-format deleted file mode 100644 index 466a0cff41..0000000000 --- a/deps/vitaGL/.clang-format +++ /dev/null @@ -1,99 +0,0 @@ ---- -Language: Cpp -# BasedOnStyle: WebKit -AccessModifierOffset: -4 -AlignAfterOpenBracket: DontAlign -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlines: Right -AlignOperands: false -AlignTrailingComments: false -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: true -AllowShortFunctionsOnASingleLine: All -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: false -BinPackArguments: true -BinPackParameters: true -BraceWrapping: - AfterClass: false - AfterControlStatement: false - AfterEnum: false - AfterFunction: true - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - BeforeCatch: false - BeforeElse: false - IndentBraces: false -BreakBeforeBinaryOperators: All -BreakBeforeBraces: Attach -BreakBeforeInheritanceComma: false -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -BreakConstructorInitializers: BeforeComma -BreakAfterJavaFieldAnnotations: false -BreakStringLiterals: true -ColumnLimit: 0 -CommentPragmas: '^ IWYU pragma:' -CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: false -DerivePointerAlignment: false -DisableFormat: false -ExperimentalAutoDetectBinPacking: false -FixNamespaceComments: true -ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] -IncludeCategories: - - Regex: '^"(llvm|llvm-c|clang|clang-c)/' - Priority: 2 - - Regex: '^(<|"(gtest|isl|json)/)' - Priority: 3 - - Regex: '.*' - Priority: 1 -IncludeIsMainRegex: '$' -IndentCaseLabels: false -IndentWidth: 4 -IndentWrappedFunctionNames: false -JavaScriptQuotes: Leave -JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: false -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -ObjCBlockIndentWidth: 4 -ObjCSpaceAfterProperty: true -ObjCSpaceBeforeProtocolList: true -PenaltyBreakAssignment: 2 -PenaltyBreakBeforeFirstCallParameter: 19 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakString: 1000 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 60 -PointerAlignment: Right -ReflowComments: true -SortIncludes: true -SpaceAfterCStyleCast: false -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeParens: ControlStatements -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInContainerLiterals: true -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -TabWidth: 4 -UseTab: Always -... diff --git a/deps/vitaGL/.gitattributes b/deps/vitaGL/.gitattributes deleted file mode 100644 index bdb0cabc87..0000000000 --- a/deps/vitaGL/.gitattributes +++ /dev/null @@ -1,17 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto - -# Custom for Visual Studio -*.cs diff=csharp - -# Standard to msysgit -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain diff --git a/deps/vitaGL/.gitignore b/deps/vitaGL/.gitignore deleted file mode 100644 index 23410e348b..0000000000 --- a/deps/vitaGL/.gitignore +++ /dev/null @@ -1,57 +0,0 @@ -*.vpk -*.elf -*.velf -*.bin -*.sfo - -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# ========================= -# Operating System Files -# ========================= - -# OSX -# ========================= - -.DS_Store -.AppleDouble -.LSOverride - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -# Vita build stuffs -*.a -*.o diff --git a/deps/vitaGL/LICENSE.txt b/deps/vitaGL/LICENSE.txt deleted file mode 100644 index 0a041280bd..0000000000 --- a/deps/vitaGL/LICENSE.txt +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/deps/vitaGL/Makefile b/deps/vitaGL/Makefile deleted file mode 100644 index d19550a1fb..0000000000 --- a/deps/vitaGL/Makefile +++ /dev/null @@ -1,69 +0,0 @@ -TARGET := libvitaGL -SOURCES := source source/utils -SHADERS := shaders - -LIBS = -lc -lm -lSceGxm_stub -lSceDisplay_stub - -ifeq ($(HAVE_SBRK),1) -SOURCES += source/hacks -endif - -CFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.c)) -CGFILES := $(foreach dir,$(SHADERS), $(wildcard $(dir)/*.cg)) -HEADERS := $(CGFILES:.cg=.h) -OBJS := $(CFILES:.c=.o) - -PREFIX = arm-vita-eabi -CC = $(PREFIX)-gcc -AR = $(PREFIX)-gcc-ar -CFLAGS = -g -Wl,-q -O2 -ffast-math -mtune=cortex-a9 -mfpu=neon -flto -ftree-vectorize -DTRANSPOSE_MATRICES -ASFLAGS = $(CFLAGS) - -all: $(TARGET).a - -$(TARGET).a: $(OBJS) - $(AR) -rc $@ $^ - -%_f.h: - psp2cgc -profile sce_fp_psp2 $(@:_f.h=_f.cg) -Wperf -fastprecision -O3 -o $(@:_f.h=_f.gxp) - bin2c $(@:_f.h=_f.gxp) source/shaders/$(notdir $(@)) $(notdir $(@:_f.h=_f)) - @rm -rf $(@:_f.h=_f.gxp) - -%_v.h: - psp2cgc -profile sce_vp_psp2 $(@:_v.h=_v.cg) -Wperf -fastprecision -O3 -o $(@:_v.h=_v.gxp) - bin2c $(@:_v.h=_v.gxp) source/shaders/$(notdir $(@:_v.h=_v.h)) $(notdir $(@:_v.h=_v)) - @rm -rf $(@:_v.h=_v.gxp) - -shaders: $(HEADERS) - -clean: - @rm -rf $(TARGET).a $(TARGET).elf $(OBJS) - @make -C samples/sample1 clean - @make -C samples/sample2 clean - @make -C samples/sample3 clean - @make -C samples/sample4 clean - @make -C samples/sample5 clean - @make -C samples/sample6 clean - @make -C samples/sample7 clean - -install: $(TARGET).a - @mkdir -p $(VITASDK)/$(PREFIX)/lib/ - cp $(TARGET).a $(VITASDK)/$(PREFIX)/lib/ - @mkdir -p $(VITASDK)/$(PREFIX)/include/ - cp source/vitaGL.h $(VITASDK)/$(PREFIX)/include/ - -samples: $(TARGET).a - @make -C samples/sample1 - cp "samples/sample1/vitaGL-Sample001.vpk" . - @make -C samples/sample2 - cp "samples/sample2/vitaGL-Sample002.vpk" . - @make -C samples/sample3 - cp "samples/sample3/vitaGL-Sample003.vpk" . - @make -C samples/sample4 - cp "samples/sample4/vitaGL-Sample004.vpk" . - @make -C samples/sample5 - cp "samples/sample5/vitaGL-Sample005.vpk" . - @make -C samples/sample6 - cp "samples/sample6/vitaGL-Sample006.vpk" . - @make -C samples/sample7 - cp "samples/sample7/vitaGL-Sample007.vpk" . diff --git a/deps/vitaGL/README.md b/deps/vitaGL/README.md deleted file mode 100644 index 1553b77a75..0000000000 --- a/deps/vitaGL/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# vitaGL -vitaGL is a wrapper between openGL and sceGxm. It allows to use a subset of openGL functions with fully hardware acceleration by translating the code to sceGxm equivalent. - -# Samples - -You can find samples in the *samples* folder in this repository. - -# Help and Troubleshooting - -If you plan to use vitaGL for one of your projects, you can find an official channel to get help with it on Vita Nuova discord server: https://discord.gg/PyCaBx9 - -# Projects actually using vitaGL - -Here you can find a list of projects using vitaGL: - -Direct OpenGL Usage:
-[vitaQuake](https://vitadb.rinnegatamante.it/#/info/10) - Port of Quake I and mission packs
-[vitaQuakeII](https://vitadb.rinnegatamante.it/#/info/278) -Port of Quake II and mission packs
-[vitaQuakeIII](https://vitadb.rinnegatamante.it/#/info/375) - Port of ioquake3 (Quake III: Arena, Quake III: Team Arena, OpenArena)
-[vitaRTCW](https://vitadb.rinnegatamante.it/#/info/459) - Port of iortcw (Return to Castle Wolfenstein)
-[vitaHexenII](https://vitadb.rinnegatamante.it/#/info/196) - Port of Hexen II
-[vitaXash3D](https://vitadb.rinnegatamante.it/#/info/365) - Port of Xash3D (Half Life, Counter Strike 1.6)
-[Fade to Black](https://vitadb.rinnegatamante.it/#/info/367) - Port of Fade to Black
-[vitaVoyager](https://vitadb.rinnegatamante.it/#/info/367) - Port of lilium-voyager (Star Trek Voyager: Elite Force)
- -Libraries:
-[sdl12_gl](https://github.com/Rinnegatamante/SDL-Vita/tree/sdl12_gl/src) - SDL 1.2 Vita port adapted to work with vitaGL as renderer
-[imgui_vita](https://github.com/Rinnegatamante/imgui-vita) - Port of dear imGui
- -sdl12_gl Apps:
-[SuperMarioWar](https://vitadb.rinnegatamante.it/#/info/422) - Port of Super Mario War
-[ZeldaOLB](https://vitadb.rinnegatamante.it/#/info/265) - Port of Zelda: Oni Link Begins
-[ZeldaROTH](https://vitadb.rinnegatamante.it/#/info/109) - Port of Zelda: Return of the Hylian
-[Zelda3T](https://vitadb.rinnegatamante.it/#/info/334) - Port of Zelda: Time to Triumph
-[ZeldaNSQ](https://vitadb.rinnegatamante.it/#/info/350) - Port of Zelda: Navi's Quest
-[vitaWolfen](https://vitadb.rinnegatamante.it/#/info/31) - Port of Wolf4SDL
-[meritous](https://vitadb.rinnegatamante.it/#/info/411) - Port of meritous
diff --git a/deps/vitaGL/format.bat b/deps/vitaGL/format.bat deleted file mode 100644 index dab6c9f4a1..0000000000 --- a/deps/vitaGL/format.bat +++ /dev/null @@ -1,6 +0,0 @@ -@echo off -cd source -for /f %%f in ('dir *.c *.h /b/s') do ( - echo.%%f | findstr /C:"\\shaders\\">nul || (clang-format -i %%f) -) -cd .. diff --git a/deps/vitaGL/samples/sample1/Makefile b/deps/vitaGL/samples/sample1/Makefile deleted file mode 100644 index 006a1677b1..0000000000 --- a/deps/vitaGL/samples/sample1/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -SAMPLE_NUM := 001 -TARGET := vitaGL-Sample$(SAMPLE_NUM) -SOURCES := . - -INCLUDES := include - -LIBS = -lvitaGL -lSceLibKernel_stub -lScePvf_stub -lmathneon \ - -lSceAppMgr_stub -lSceAppUtil_stub -lScePgf_stub \ - -ljpeg -lfreetype -lc -lSceCommonDialog_stub -lpng16 -lm -lz \ - -lSceGxm_stub -lSceDisplay_stub -lSceSysmodule_stub \ - -CFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.c)) -CPPFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.cpp)) -BINFILES := $(foreach dir,$(DATA), $(wildcard $(dir)/*.bin)) -OBJS := $(addsuffix .o,$(BINFILES)) $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) - -PREFIX = arm-vita-eabi -CC = $(PREFIX)-gcc -CXX = $(PREFIX)-g++ -CFLAGS = -g -Wl,-q -O2 -ftree-vectorize -CXXFLAGS = $(CFLAGS) -fno-exceptions -std=gnu++11 -fpermissive -ASFLAGS = $(CFLAGS) - -all: $(TARGET).vpk - -$(TARGET).vpk: eboot.bin - vita-mksfoex -s TITLE_ID=VITAGL$(SAMPLE_NUM) "$(TARGET)" param.sfo - vita-pack-vpk -s param.sfo -b eboot.bin -a texture.bmp=texture.bmp $@ - -eboot.bin: $(TARGET).velf - vita-make-fself -s $< eboot.bin - -%.velf: %.elf - vita-elf-create $< $@ - -$(TARGET).elf: $(OBJS) - $(CC) $(CFLAGS) $^ $(LIBS) -o $@ - -clean: - @rm -rf *.velf *.elf *.vpk $(OBJS) param.sfo eboot.bin diff --git a/deps/vitaGL/samples/sample1/main.c b/deps/vitaGL/samples/sample1/main.c deleted file mode 100644 index 45898dd51f..0000000000 --- a/deps/vitaGL/samples/sample1/main.c +++ /dev/null @@ -1,67 +0,0 @@ -// Drawing a fullscreen image on screen with glBegin/glEnd - -#include -#include -#include - -GLenum texture_format = GL_RGB; -GLuint texture = 0; - -int main(){ - - // Initializing graphics device - vglInit(0x800000); - - // Loading BMP image to use as texture - SceUID fd = sceIoOpen("app0:texture.bmp", SCE_O_RDONLY, 0777); - uint16_t w, h; - sceIoLseek(fd, 0x12, SCE_SEEK_SET); - sceIoRead(fd, &w, sizeof(uint16_t)); - sceIoLseek(fd, 0x16, SCE_SEEK_SET); - sceIoRead(fd, &h, sizeof(uint16_t)); - sceIoLseek(fd, 0x26, SCE_SEEK_SET); - uint8_t *buffer = (uint8_t*)malloc(w * h * 3); - sceIoRead(fd, buffer, w * h * 3); - sceIoClose(fd); - - glClearColor(0.50, 0, 0, 0); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, 960, 544, 0, -1, 1); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - // Initializing openGL texture - glGenTextures(1, &texture); - glBindTexture(GL_TEXTURE_2D, texture); - - glTexImage2D(GL_TEXTURE_2D, 0, texture_format, w, h, 0, texture_format, GL_UNSIGNED_BYTE, buffer); - - glEnable(GL_TEXTURE_2D); - - for (;;){ - vglStartRendering(); - glClear(GL_COLOR_BUFFER_BIT); - glBindTexture(GL_TEXTURE_2D, texture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glBegin(GL_QUADS); - - // Note: BMP images are vertically flipped - glTexCoord2i(0, 1); - glVertex3f(0, 0, 0); - glTexCoord2i(1, 1); - glVertex3f(960, 0, 0); - glTexCoord2i(1, 0); - glVertex3f(960, 544, 0); - glTexCoord2i(0, 0); - glVertex3f(0, 544, 0); - - glEnd(); - vglStopRendering(); - glLoadIdentity(); - } - - vglEnd(); - -} \ No newline at end of file diff --git a/deps/vitaGL/samples/sample1/texture.bmp b/deps/vitaGL/samples/sample1/texture.bmp deleted file mode 100644 index cfcc30313b..0000000000 Binary files a/deps/vitaGL/samples/sample1/texture.bmp and /dev/null differ diff --git a/deps/vitaGL/samples/sample2/Makefile b/deps/vitaGL/samples/sample2/Makefile deleted file mode 100644 index bdbdbd8e39..0000000000 --- a/deps/vitaGL/samples/sample2/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -SAMPLE_NUM := 002 -TARGET := vitaGL-Sample$(SAMPLE_NUM) -SOURCES := . - -INCLUDES := include - -LIBS = -lvitaGL -lc -lSceCommonDialog_stub -lm -lSceGxm_stub -lSceDisplay_stub -lmathneon - -CFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.c)) -CPPFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.cpp)) -BINFILES := $(foreach dir,$(DATA), $(wildcard $(dir)/*.bin)) -OBJS := $(addsuffix .o,$(BINFILES)) $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) - -PREFIX = arm-vita-eabi -CC = $(PREFIX)-gcc -CXX = $(PREFIX)-g++ -CFLAGS = -g -Wl,-q -O2 -ftree-vectorize -CXXFLAGS = $(CFLAGS) -fno-exceptions -std=gnu++11 -fpermissive -ASFLAGS = $(CFLAGS) - -all: $(TARGET).vpk - -debug: CFLAGS += -DDEBUG_BUILD -debug: all - -$(TARGET).vpk: eboot.bin - vita-mksfoex -s TITLE_ID=VITAGL$(SAMPLE_NUM) "$(TARGET)" param.sfo - vita-pack-vpk -s param.sfo -b eboot.bin $@ - -eboot.bin: $(TARGET).velf - vita-make-fself -s $< eboot.bin - -%.velf: %.elf - cp $< $<.unstripped.elf - vita-elf-create $< $@ - -$(TARGET).elf: $(OBJS) - $(CC) $(CFLAGS) $^ $(LIBS) -o $@ - -clean: - @rm -rf *.velf *.elf *.vpk $(OBJS) param.sfo eboot.bin - diff --git a/deps/vitaGL/samples/sample2/main.c b/deps/vitaGL/samples/sample2/main.c deleted file mode 100644 index 79b2746f44..0000000000 --- a/deps/vitaGL/samples/sample2/main.c +++ /dev/null @@ -1,39 +0,0 @@ -// Drawing a triangle on screen with vertex array - -#include - -float colors[] = {1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0}; -float vertices[] = {100, 100, 0, 150, 100, 0, 100, 150, 0}; - -int main(){ - - // Initializing graphics device - vglInit(0x800000); - - glClearColor (0.50f, 0.0f, 0.0f, 1.0f); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, 960, 544, 0, -1, 1); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - for (;;){ - vglStartRendering(); - glClear(GL_COLOR_BUFFER_BIT); - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, vertices); - glColorPointer(3, GL_FLOAT, 0, colors); - glDrawArrays(GL_TRIANGLES, 0, 3); - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - - vglStopRendering(); - - glLoadIdentity(); - } - - vglEnd(); - -} \ No newline at end of file diff --git a/deps/vitaGL/samples/sample3/Makefile b/deps/vitaGL/samples/sample3/Makefile deleted file mode 100644 index 887e53b8b7..0000000000 --- a/deps/vitaGL/samples/sample3/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -SAMPLE_NUM := 003 -TARGET := vitaGL-Sample$(SAMPLE_NUM) -SOURCES := . - -INCLUDES := include - -LIBS = -lvitaGL -lSceLibKernel_stub -lSceAppMgr_stub -lSceAppUtil_stub -lmathneon \ - -lc -lSceCommonDialog_stub -lm -lSceGxm_stub -lSceDisplay_stub -lSceSysmodule_stub \ - -CFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.c)) -CPPFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.cpp)) -BINFILES := $(foreach dir,$(DATA), $(wildcard $(dir)/*.bin)) -OBJS := $(addsuffix .o,$(BINFILES)) $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) - -PREFIX = arm-vita-eabi -CC = $(PREFIX)-gcc -CXX = $(PREFIX)-g++ -CFLAGS = -g -Wl,-q -O2 -ftree-vectorize -CXXFLAGS = $(CFLAGS) -fno-exceptions -std=gnu++11 -fpermissive -ASFLAGS = $(CFLAGS) - -all: $(TARGET).vpk - -$(TARGET).vpk: eboot.bin - vita-mksfoex -s TITLE_ID=VITAGL$(SAMPLE_NUM) "$(TARGET)" param.sfo - vita-pack-vpk -s param.sfo -b eboot.bin $@ - -eboot.bin: $(TARGET).velf - vita-make-fself -s $< eboot.bin - -%.velf: %.elf - vita-elf-create $< $@ - -$(TARGET).elf: $(OBJS) - $(CC) $(CFLAGS) $^ $(LIBS) -o $@ - -clean: - @rm -rf *.velf *.elf *.vpk $(OBJS) param.sfo eboot.bin diff --git a/deps/vitaGL/samples/sample3/main.c b/deps/vitaGL/samples/sample3/main.c deleted file mode 100644 index 97cb9f186e..0000000000 --- a/deps/vitaGL/samples/sample3/main.c +++ /dev/null @@ -1,36 +0,0 @@ -// Drawing a colored quad with glBegin/glEnd - -#include - -int main(){ - - // Initializing graphics device - vglInit(0x800000); - - glClearColor(0.0, 0.0, 0.0, 0.0); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, 960, 544, 0, -1, 1); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - for (;;){ - vglStartRendering(); - glClear(GL_COLOR_BUFFER_BIT); - glBegin(GL_QUADS); - glColor3f(1.0, 0.0, 0.0); - glVertex3f(400, 0, 0); - glColor3f(1.0, 1.0, 0.0); - glVertex3f(800, 0, 0); - glColor3f(0.0, 1.0, 0.0); - glVertex3f(800, 400, 0); - glColor3f(1.0, 0.0, 1.0); - glVertex3f(400, 400, 0); - glEnd(); - vglStopRendering(); - glLoadIdentity(); - } - - vglEnd(); - -} diff --git a/deps/vitaGL/samples/sample4/Makefile b/deps/vitaGL/samples/sample4/Makefile deleted file mode 100644 index 5a2d34a73b..0000000000 --- a/deps/vitaGL/samples/sample4/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -SAMPLE_NUM := 004 -TARGET := vitaGL-Sample$(SAMPLE_NUM) -SOURCES := . - -INCLUDES := include - -LIBS = -lvitaGL -lc -lSceCommonDialog_stub -lm -lSceGxm_stub -lSceDisplay_stub -lmathneon - -CFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.c)) -CPPFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.cpp)) -BINFILES := $(foreach dir,$(DATA), $(wildcard $(dir)/*.bin)) -OBJS := $(addsuffix .o,$(BINFILES)) $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) - -PREFIX = arm-vita-eabi -CC = $(PREFIX)-gcc -CXX = $(PREFIX)-g++ -CFLAGS = -g -Wl,-q -O2 -ftree-vectorize -CXXFLAGS = $(CFLAGS) -fno-exceptions -std=gnu++11 -fpermissive -ASFLAGS = $(CFLAGS) - -all: $(TARGET).vpk - -$(TARGET).vpk: eboot.bin - vita-mksfoex -s TITLE_ID=VITAGL$(SAMPLE_NUM) "$(TARGET)" param.sfo - vita-pack-vpk -s param.sfo -b eboot.bin $@ - -eboot.bin: $(TARGET).velf - vita-make-fself -s $< eboot.bin - -%.velf: %.elf - vita-elf-create $< $@ - -$(TARGET).elf: $(OBJS) - $(CC) $(CFLAGS) $^ $(LIBS) -o $@ - -clean: - @rm -rf *.velf *.elf *.vpk $(OBJS) param.sfo eboot.bin diff --git a/deps/vitaGL/samples/sample4/main.c b/deps/vitaGL/samples/sample4/main.c deleted file mode 100644 index c1ff0fda96..0000000000 --- a/deps/vitaGL/samples/sample4/main.c +++ /dev/null @@ -1,38 +0,0 @@ -// Drawing a quad on screen with glDrawElements - -#include - -float colors[] = {1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0}; -float vertices[] = {100, 100, 0, 150, 100, 0, 100, 150, 0, 150, 150, 0}; -uint16_t indices[] = {0, 1, 2, 1, 2, 3}; - -int main(){ - - // Initializing graphics device - vglInit(0x800000); - - glClearColor (0.50f, 0.0f, 0.0f, 1.0f); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, 960, 544, 0, -1, 1); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - for (;;){ - vglStartRendering(); - glClear(GL_COLOR_BUFFER_BIT); - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, vertices); - glColorPointer(3, GL_FLOAT, 0, colors); - glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices); - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - vglStopRendering(); - glLoadIdentity(); - } - - vglEnd(); - -} \ No newline at end of file diff --git a/deps/vitaGL/samples/sample5/Makefile b/deps/vitaGL/samples/sample5/Makefile deleted file mode 100644 index 32f94c96c5..0000000000 --- a/deps/vitaGL/samples/sample5/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -SAMPLE_NUM := 005 -TARGET := vitaGL-Sample$(SAMPLE_NUM) -SOURCES := . - -INCLUDES := include - -LIBS = -lvitaGL -lc -lSceCommonDialog_stub -lm -lSceGxm_stub -lSceDisplay_stub -lmathneon - -CFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.c)) -CPPFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.cpp)) -BINFILES := $(foreach dir,$(DATA), $(wildcard $(dir)/*.bin)) -OBJS := $(addsuffix .o,$(BINFILES)) $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) - -PREFIX = arm-vita-eabi -CC = $(PREFIX)-gcc -CXX = $(PREFIX)-g++ -CFLAGS = -g -Wl,-q -O2 -ftree-vectorize -CXXFLAGS = $(CFLAGS) -fno-exceptions -std=gnu++11 -fpermissive -ASFLAGS = $(CFLAGS) - -all: $(TARGET).vpk - -$(TARGET).vpk: eboot.bin - vita-mksfoex -s TITLE_ID=VITAGL$(SAMPLE_NUM) "$(TARGET)" param.sfo - vita-pack-vpk -s param.sfo -b eboot.bin $@ - -eboot.bin: $(TARGET).velf - vita-make-fself -s $< eboot.bin - -%.velf: %.elf - vita-elf-create $< $@ - -$(TARGET).elf: $(OBJS) - $(CC) $(CFLAGS) $^ $(LIBS) -o $@ - -clean: - @rm -rf *.velf *.elf *.vpk $(OBJS) param.sfo eboot.bin diff --git a/deps/vitaGL/samples/sample5/main.c b/deps/vitaGL/samples/sample5/main.c deleted file mode 100644 index 5d8f35edc3..0000000000 --- a/deps/vitaGL/samples/sample5/main.c +++ /dev/null @@ -1,82 +0,0 @@ -// Drawing a rotating cube - -#include -#include - -float colors[] = {1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0}; // Colors for a face - -float vertices_front[] = {-0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f}; // Front Face -float vertices_back[] = {-0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f}; // Back Face -float vertices_left[] = {-0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f}; // Left Face -float vertices_right[] = {0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f, 0.5f}; // Right Face -float vertices_top[] = {-0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f}; // Top Face -float vertices_bottom[] = {-0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f}; // Bottom Face - -uint16_t indices[] = { - 0, 1, 2, 1, 2, 3, // Front - 4, 5, 6, 5, 6, 7, // Back - 8, 9,10, 9,10,11, // Left - 12,13,14,13,14,15, // Right - 16,17,18,17,18,19, // Top - 20,21,22,21,22,23 // Bottom -}; - -void init_perspective(float fov, float aspect, float near, float far){ - float half_height = near * tanf(((fov * M_PI) / 180.0f) * 0.5f); - float half_width = half_height * aspect; - - glFrustum(-half_width, half_width, -half_height, half_height, near, far); -} - -int main(){ - - // Initializing graphics device - vglInit(0x800000); - vglWaitVblankStart(GL_TRUE); - - // Creating colors array - float color_array[12*6]; - int i; - for (i=0;i<12*6;i++){ - color_array[i] = colors[i % 12]; - } - - // Creating vertices array - float vertex_array[12*6]; - memcpy(&vertex_array[12*0], &vertices_front[0], sizeof(float) * 12); - memcpy(&vertex_array[12*1], &vertices_back[0], sizeof(float) * 12); - memcpy(&vertex_array[12*2], &vertices_left[0], sizeof(float) * 12); - memcpy(&vertex_array[12*3], &vertices_right[0], sizeof(float) * 12); - memcpy(&vertex_array[12*4], &vertices_top[0], sizeof(float) * 12); - memcpy(&vertex_array[12*5], &vertices_bottom[0], sizeof(float) * 12); - - glClearColor (0.0f, 0.0f, 0.0f, 0.0f); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - init_perspective(90.0f, 960.f/544.0f, 0.01f, 100.0f); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0f, 0.0f, -3.0f); // Centering the cube - - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LESS); - - for (;;){ - vglStartRendering(); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, vertex_array); - glColorPointer(3, GL_FLOAT, 0, color_array); - glRotatef(1.0f, 0.0f, 0.0f, 1.0f); - glRotatef(0.5f, 0.0f, 1.0f, 0.0f); - glDrawElements(GL_TRIANGLES, 6*6, GL_UNSIGNED_SHORT, indices); - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - vglStopRendering(); - } - - vglEnd(); - -} \ No newline at end of file diff --git a/deps/vitaGL/samples/sample6/Makefile b/deps/vitaGL/samples/sample6/Makefile deleted file mode 100644 index bc0a5fe656..0000000000 --- a/deps/vitaGL/samples/sample6/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -SAMPLE_NUM := 006 -TARGET := vitaGL-Sample$(SAMPLE_NUM) -SOURCES := . - -INCLUDES := include - -LIBS = -lvitaGL -lc -lSceCommonDialog_stub -lm -lSceGxm_stub -lSceDisplay_stub -lmathneon - -CFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.c)) -CPPFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.cpp)) -BINFILES := $(foreach dir,$(DATA), $(wildcard $(dir)/*.bin)) -OBJS := $(addsuffix .o,$(BINFILES)) $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) - -PREFIX = arm-vita-eabi -CC = $(PREFIX)-gcc -CXX = $(PREFIX)-g++ -CFLAGS = -g -Wl,-q -O2 -ftree-vectorize -CXXFLAGS = $(CFLAGS) -fno-exceptions -std=gnu++11 -fpermissive -ASFLAGS = $(CFLAGS) - -all: $(TARGET).vpk - -$(TARGET).vpk: eboot.bin - vita-mksfoex -s TITLE_ID=VITAGL$(SAMPLE_NUM) "$(TARGET)" param.sfo - vita-pack-vpk -s param.sfo -b eboot.bin $@ - -eboot.bin: $(TARGET).velf - vita-make-fself -s $< eboot.bin - -%.velf: %.elf - vita-elf-create $< $@ - -$(TARGET).elf: $(OBJS) - $(CC) $(CFLAGS) $^ $(LIBS) -o $@ - -clean: - @rm -rf *.velf *.elf *.vpk $(OBJS) param.sfo eboot.bin diff --git a/deps/vitaGL/samples/sample6/main.c b/deps/vitaGL/samples/sample6/main.c deleted file mode 100644 index 464c0be430..0000000000 --- a/deps/vitaGL/samples/sample6/main.c +++ /dev/null @@ -1,96 +0,0 @@ -// Drawing a rotating cube with VBO - -#include -#include - -#define BUF_OFFS(i) ((void*)(i)) - -float colors[] = {1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0}; // Colors for a face - -float vertices_front[] = {-0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f}; // Front Face -float vertices_back[] = {-0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f}; // Back Face -float vertices_left[] = {-0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f}; // Left Face -float vertices_right[] = {0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f, 0.5f}; // Right Face -float vertices_top[] = {-0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f}; // Top Face -float vertices_bottom[] = {-0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f}; // Bottom Face - -GLuint buffers[2]; - -uint16_t indices[] = { - 0, 1, 2, 1, 2, 3, // Front - 4, 5, 6, 5, 6, 7, // Back - 8, 9,10, 9,10,11, // Left - 12,13,14,13,14,15, // Right - 16,17,18,17,18,19, // Top - 20,21,22,21,22,23 // Bottom -}; - -void init_perspective(float fov, float aspect, float near, float far){ - float half_height = near * tanf(((fov * M_PI) / 180.0f) * 0.5f); - float half_width = half_height * aspect; - - glFrustum(-half_width, half_width, -half_height, half_height, near, far); -} - -int main(){ - - // Initializing graphics device - vglInit(0x80000); - vglWaitVblankStart(GL_TRUE); - - // Creating VBO data with vertices + colors - float vbo[12*12]; - memcpy(&vbo[12*0], &vertices_front[0], sizeof(float) * 12); - memcpy(&vbo[12*1], &vertices_back[0], sizeof(float) * 12); - memcpy(&vbo[12*2], &vertices_left[0], sizeof(float) * 12); - memcpy(&vbo[12*3], &vertices_right[0], sizeof(float) * 12); - memcpy(&vbo[12*4], &vertices_top[0], sizeof(float) * 12); - memcpy(&vbo[12*5], &vertices_bottom[0], sizeof(float) * 12); - memcpy(&vbo[12*6], &colors[0], sizeof(float) * 12); - memcpy(&vbo[12*7], &colors[0], sizeof(float) * 12); - memcpy(&vbo[12*8], &colors[0], sizeof(float) * 12); - memcpy(&vbo[12*9], &colors[0], sizeof(float) * 12); - memcpy(&vbo[12*10], &colors[0], sizeof(float) * 12); - memcpy(&vbo[12*11], &colors[0], sizeof(float) * 12); - - // Creating two buffers for colors, vertices and indices - glGenBuffers(2, buffers); - - // Setting up VBO - glBindBuffer(GL_ARRAY_BUFFER, buffers[0]); - glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 12 * 12, vbo, GL_STATIC_DRAW); - - // Setting up indices array - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[1]); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint16_t) * 6 * 6, indices, GL_STATIC_DRAW); - - glClearColor (0.0f, 0.0f, 0.0f, 0.0f); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - init_perspective(90.0f, 960.f/544.0f, 0.01f, 100.0f); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0f, 0.0f, -3.0f); // Centering the cube - - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LESS); - - for (;;){ - vglStartRendering(); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, BUF_OFFS(0)); - glColorPointer(3, GL_FLOAT, 0, BUF_OFFS(12*6*sizeof(float))); - glRotatef(1.0f, 0.0f, 0.0f, 1.0f); - glRotatef(0.5f, 1.0f, 0.0f, 0.0f); - glDrawElements(GL_TRIANGLES, 6*6, GL_UNSIGNED_SHORT, BUF_OFFS(0)); - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - vglStopRendering(); - } - - vglEnd(); - -} \ No newline at end of file diff --git a/deps/vitaGL/samples/sample7/Makefile b/deps/vitaGL/samples/sample7/Makefile deleted file mode 100644 index 8b33dfa4f8..0000000000 --- a/deps/vitaGL/samples/sample7/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -SAMPLE_NUM := 007 -TARGET := vitaGL-Sample$(SAMPLE_NUM) -SOURCES := . - -INCLUDES := include - -LIBS = -lvitaGL -lSceLibKernel_stub -lScePvf_stub \ - -lSceAppMgr_stub -lSceAppUtil_stub -lScePgf_stub \ - -ljpeg -lfreetype -lc -lSceCommonDialog_stub -lpng16 -lm -lz \ - -lSceGxm_stub -lSceDisplay_stub -lSceSysmodule_stub -lmathneon - -CFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.c)) -CPPFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.cpp)) -BINFILES := $(foreach dir,$(DATA), $(wildcard $(dir)/*.bin)) -OBJS := $(addsuffix .o,$(BINFILES)) $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) - -PREFIX = arm-vita-eabi -CC = $(PREFIX)-gcc -CXX = $(PREFIX)-g++ -CFLAGS = -g -Wl,-q -O2 -ftree-vectorize -CXXFLAGS = $(CFLAGS) -fno-exceptions -std=gnu++11 -fpermissive -ASFLAGS = $(CFLAGS) - -all: $(TARGET).vpk - -$(TARGET).vpk: eboot.bin - vita-mksfoex -s TITLE_ID=VITAGL$(SAMPLE_NUM) "$(TARGET)" param.sfo - vita-pack-vpk -s param.sfo -b eboot.bin -a texture.bmp=texture.bmp $@ - -eboot.bin: $(TARGET).velf - vita-make-fself -s $< eboot.bin - -%.velf: %.elf - vita-elf-create $< $@ - -$(TARGET).elf: $(OBJS) - $(CC) $(CFLAGS) $^ $(LIBS) -o $@ - -clean: - @rm -rf *.velf *.elf *.vpk $(OBJS) param.sfo eboot.bin diff --git a/deps/vitaGL/samples/sample7/main.c b/deps/vitaGL/samples/sample7/main.c deleted file mode 100644 index 556bdad738..0000000000 --- a/deps/vitaGL/samples/sample7/main.c +++ /dev/null @@ -1,91 +0,0 @@ -// Drawing a fullscreen image on screen with glBegin/glEnd - -#include -#include -#include - -GLenum texture_format = GL_RGB; -GLuint texture = 0; - -float colors[] = {0.4, 0.1, 0.3, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0}; -float vertices[] = {100, 100, 0, 150, 100, 0, 100, 150, 0}; - -int main(){ - - // Initializing graphics device - vglInit(0x800000); - - // Loading BMP image to use as texture - SceUID fd = sceIoOpen("app0:texture.bmp", SCE_O_RDONLY, 0777); - uint16_t w, h; - sceIoLseek(fd, 0x12, SCE_SEEK_SET); - sceIoRead(fd, &w, sizeof(uint16_t)); - sceIoLseek(fd, 0x16, SCE_SEEK_SET); - sceIoRead(fd, &h, sizeof(uint16_t)); - sceIoLseek(fd, 0x26, SCE_SEEK_SET); - uint8_t *buffer = (uint8_t*)malloc(w * h * 3); - sceIoRead(fd, buffer, w * h * 3); - sceIoClose(fd); - - glClearColor(0.50, 0, 0, 0); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, 960, 544, 0, -1, 1); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - // Initializing openGL texture - glGenTextures(1, &texture); - glBindTexture(GL_TEXTURE_2D, texture); - glTexImage2D(GL_TEXTURE_2D, 0, texture_format, w, h, 0, texture_format, GL_UNSIGNED_BYTE, buffer); - glEnable(GL_TEXTURE_2D); - - // Initializing framebuffer - GLuint fb; - glGenFramebuffers(1, &fb); - glBindFramebuffer(GL_FRAMEBUFFER, fb); - - // Binding texture to framebuffer - glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture, 0); - - // Drawing on texture - vglStartRendering(); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, vertices); - glColorPointer(3, GL_FLOAT, 0, colors); - glDrawArrays(GL_TRIANGLES, 0, 3); - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - vglStopRendering(); - glFinish(); - glLoadIdentity(); - - glBindFramebuffer(GL_FRAMEBUFFER, 0); - - for (;;){ - vglStartRendering(); - glClear(GL_COLOR_BUFFER_BIT); - glBindTexture(GL_TEXTURE_2D, texture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glBegin(GL_QUADS); - - // Note: BMP images are vertically flipped - glTexCoord2i(0, 1); - glVertex3f(0, 0, 0); - glTexCoord2i(1, 1); - glVertex3f(960, 0, 0); - glTexCoord2i(1, 0); - glVertex3f(960, 544, 0); - glTexCoord2i(0, 0); - glVertex3f(0, 544, 0); - - glEnd(); - vglStopRendering(); - glLoadIdentity(); - } - - vglEnd(); - -} \ No newline at end of file diff --git a/deps/vitaGL/samples/sample7/texture.bmp b/deps/vitaGL/samples/sample7/texture.bmp deleted file mode 100644 index cfcc30313b..0000000000 Binary files a/deps/vitaGL/samples/sample7/texture.bmp and /dev/null differ diff --git a/deps/vitaGL/shaders/clear_f.cg b/deps/vitaGL/shaders/clear_f.cg deleted file mode 100644 index aa28edf821..0000000000 --- a/deps/vitaGL/shaders/clear_f.cg +++ /dev/null @@ -1,4 +0,0 @@ -float4 main(uniform float4 u_clear_color) : COLOR -{ - return u_clear_color; -} diff --git a/deps/vitaGL/shaders/clear_v.cg b/deps/vitaGL/shaders/clear_v.cg deleted file mode 100644 index c4b09c8647..0000000000 --- a/deps/vitaGL/shaders/clear_v.cg +++ /dev/null @@ -1,5 +0,0 @@ -float4 main(float2 position) : POSITION -{ - return float4(position, 1.f, 1.f); -} - diff --git a/deps/vitaGL/shaders/disable_color_buffer_f.cg b/deps/vitaGL/shaders/disable_color_buffer_f.cg deleted file mode 100644 index 0202ff51c2..0000000000 --- a/deps/vitaGL/shaders/disable_color_buffer_f.cg +++ /dev/null @@ -1,5 +0,0 @@ -float main( - uniform float depth_clear) : DEPTH -{ - return depth_clear; -} diff --git a/deps/vitaGL/shaders/rgb_v.cg b/deps/vitaGL/shaders/rgb_v.cg deleted file mode 100644 index ee1495b727..0000000000 --- a/deps/vitaGL/shaders/rgb_v.cg +++ /dev/null @@ -1,11 +0,0 @@ -void main( - float3 aPosition, - float3 aColor, - column_major uniform float4x4 wvp, - float4 out vPosition: POSITION, - float4 out vColor: COLOR) -{ - vPosition = mul(float4(aPosition, 1.f), wvp); - vColor = float4(aColor, 1.0); -} - diff --git a/deps/vitaGL/shaders/rgba_f.cg b/deps/vitaGL/shaders/rgba_f.cg deleted file mode 100644 index 39ef1af00c..0000000000 --- a/deps/vitaGL/shaders/rgba_f.cg +++ /dev/null @@ -1,4 +0,0 @@ -float4 main(float4 vColor : COLOR) : COLOR -{ - return vColor; -} diff --git a/deps/vitaGL/shaders/rgba_v.cg b/deps/vitaGL/shaders/rgba_v.cg deleted file mode 100644 index 93786fd01e..0000000000 --- a/deps/vitaGL/shaders/rgba_v.cg +++ /dev/null @@ -1,11 +0,0 @@ -void main( - float3 aPosition, - float4 aColor, - column_major uniform float4x4 wvp, - float4 out vPosition: POSITION, - float4 out vColor: COLOR) -{ - vPosition = mul(float4(aPosition, 1.f), wvp); - vColor = aColor; -} - diff --git a/deps/vitaGL/shaders/texture2d_f.cg b/deps/vitaGL/shaders/texture2d_f.cg deleted file mode 100644 index b8e7bbe736..0000000000 --- a/deps/vitaGL/shaders/texture2d_f.cg +++ /dev/null @@ -1,69 +0,0 @@ -float4 main( - float2 vTexcoord : TEXCOORD0, - float vFog : FOG, - uniform sampler2D tex, - uniform float alphaCut, - uniform int alphaOp, - uniform float4 tintColor, - uniform int texEnv, - uniform int fog_mode, - uniform float4 fogColor, - uniform float4 texEnvColor - ) -{ - float4 texColor = tex2D(tex, vTexcoord); - - // Texture Environment - if (texEnv < 4){ - if (texEnv == 0){ // GL_MODULATE - texColor = texColor * tintColor; - }else if (texEnv == 1){ // GL_DECAL - texColor.rgb = lerp(tintColor.rgb, texColor.rgb, texColor.a); - texColor.a = tintColor.a; - }else if (texEnv == 2){ // GL_BLEND - texColor.rgb = lerp(tintColor.rgb, texEnvColor.rgb, texColor.rgb); - texColor.a = texColor.a * tintColor.a; - }else{ // GL_ADD - texColor.rgb = clamp(texColor.rgb + tintColor.rgb, 0.0, 1.0); - texColor.a = texColor.a * tintColor.a; - } - } - - // Alpha Test - if (alphaOp < 7){ - if (alphaOp == 0){ - if (texColor.a < alphaCut){ - discard; - } - }else if (alphaOp == 1){ - if (texColor.a <= alphaCut){ - discard; - } - }else if (alphaOp == 2){ - if (texColor.a == alphaCut){ - discard; - } - }else if (alphaOp == 3){ - if (texColor.a != alphaCut){ - discard; - } - }else if (alphaOp == 4){ - if (texColor.a > alphaCut){ - discard; - } - }else if (alphaOp == 5){ - if (texColor.a >= alphaCut){ - discard; - } - }else{ - discard; - } - } - - // Fogging - if (fog_mode < 3){ - texColor.rgb = lerp(fogColor.rgb, texColor.rgb, vFog); - } - - return texColor; -} diff --git a/deps/vitaGL/shaders/texture2d_rgba_f.cg b/deps/vitaGL/shaders/texture2d_rgba_f.cg deleted file mode 100644 index 27dcea63f6..0000000000 --- a/deps/vitaGL/shaders/texture2d_rgba_f.cg +++ /dev/null @@ -1,69 +0,0 @@ -float4 main( - float2 vTexcoord : TEXCOORD0, - float4 vColor : COLOR, - float vFog : FOG, - uniform sampler2D tex, - uniform float alphaCut, - uniform int alphaOp, - uniform int texEnv, - uniform int fog_mode, - uniform float4 fogColor, - uniform float4 texEnvColor - ) -{ - float4 texColor = tex2D(tex, vTexcoord); - - // Texture Environment - if (texEnv < 4){ - if (texEnv == 0){ // GL_MODULATE - texColor = texColor * vColor; - }else if (texEnv == 1){ // GL_DECAL - texColor.rgb = lerp(vColor.rgb, texColor.rgb, texColor.a); - texColor.a = vColor.a; - }else if (texEnv == 2){ // GL_BLEND - texColor.rgb = lerp(vColor.rgb, texEnvColor.rgb, texColor.rgb); - texColor.a = texColor.a * vColor.a; - }else{ // GL_ADD - texColor.rgb = clamp(texColor.rgb + vColor.rgb, 0.0, 1.0); - texColor.a = texColor.a * vColor.a; - } - } - - // Alpha Test - if (alphaOp < 7){ - if (alphaOp == 0){ - if (texColor.a < alphaCut){ - discard; - } - }else if (alphaOp == 1){ - if (texColor.a <= alphaCut){ - discard; - } - }else if (alphaOp == 2){ - if (texColor.a == alphaCut){ - discard; - } - }else if (alphaOp == 3){ - if (texColor.a != alphaCut){ - discard; - } - }else if (alphaOp == 4){ - if (texColor.a > alphaCut){ - discard; - } - }else if (alphaOp == 5){ - if (texColor.a >= alphaCut){ - discard; - } - }else{ - discard; - } - } - - // Fogging - if (fog_mode < 3){ - texColor.rgb = lerp(fogColor.rgb, texColor.rgb, vFog); - } - - return texColor; -} diff --git a/deps/vitaGL/shaders/texture2d_rgba_v.cg b/deps/vitaGL/shaders/texture2d_rgba_v.cg deleted file mode 100644 index 51d454b025..0000000000 --- a/deps/vitaGL/shaders/texture2d_rgba_v.cg +++ /dev/null @@ -1,47 +0,0 @@ -void main( - float3 position, - float2 texcoord, - float4 color, - column_major uniform float4x4 wvp, - uniform int fog_mode, - uniform int clip_plane0, // In the future this can turn into an array to support other planes - uniform float4 clip_plane0_eq, // In the future this can turn into an array to support other planes - uniform float4x4 modelview, - uniform float fog_near, - uniform float fog_far, - uniform float fog_density, - float4 out vPosition : POSITION, - float out vFog : FOG, - float2 out vTexcoord : TEXCOORD0, - float4 out vColor : COLOR, - float out vClip : CLP0) -{ - float4 pos4 = float4(position, 1.f); - - // User clip planes - if (clip_plane0 < 1) { - vClip = 1.f; - } else { - float4 modelpos = mul(modelview, pos4); - vClip = dot(modelpos, clip_plane0_eq); - } - - vPosition = mul(pos4, wvp); - if (fog_mode > 2) { // Fogging disabled - vFog = 1.0f; - } else { - float dist = length(vPosition.xyz); - if (fog_mode == 0) { // GL_LINEAR - vFog = (fog_far - dist) / (fog_far - fog_near); - } else if (fog_mode == 1) { // GL_EXP - vFog = exp(-fog_density * dist); - } else { // GL_EXP2 - const float LOG2 = -1.442695; - float d = fog_density * dist; - vFog = exp(d * d * LOG2); - } - vFog = clamp(vFog, 0.0, 1.0); - } - vTexcoord = texcoord; - vColor = color; -} diff --git a/deps/vitaGL/shaders/texture2d_v.cg b/deps/vitaGL/shaders/texture2d_v.cg deleted file mode 100644 index 3dc7a2d999..0000000000 --- a/deps/vitaGL/shaders/texture2d_v.cg +++ /dev/null @@ -1,44 +0,0 @@ -void main( - float3 position, - float2 texcoord, - column_major uniform float4x4 wvp, - uniform int fog_mode, - uniform int clip_plane0, // In the future this can turn into an array to support other planes - uniform float4 clip_plane0_eq, // In the future this can turn into an array to support other planes - uniform float4x4 modelview, - uniform float fog_near, - uniform float fog_far, - uniform float fog_density, - float4 out vPosition : POSITION, - float out vFog : FOG, - float2 out vTexcoord : TEXCOORD0, - float out vClip : CLP0) -{ - float4 pos4 = float4(position, 1.f); - - // User clip planes - if (clip_plane0 < 1) { - vClip = 1.f; - } else { - float4 modelpos = mul(modelview, pos4); - vClip = dot(modelpos, clip_plane0_eq); - } - - vPosition = mul(pos4, wvp); - if (fog_mode > 2){ // Fogging disabled - vFog = 1.0f; - }else{ - float dist = length(vPosition.xyz); - if (fog_mode == 0){ // GL_LINEAR - vFog = (fog_far - dist) / (fog_far - fog_near); - }else if (fog_mode == 1){ // GL_EXP - vFog = exp(-fog_density * dist); - }else{ // GL_EXP2 - const float LOG2 = -1.442695; - float d = fog_density * dist; - vFog = exp(d * d * LOG2); - } - vFog = clamp(vFog, 0.0, 1.0); - } - vTexcoord = texcoord; -} diff --git a/deps/vitaGL/source/custom_shaders.c b/deps/vitaGL/source/custom_shaders.c deleted file mode 100644 index 3590e0139c..0000000000 --- a/deps/vitaGL/source/custom_shaders.c +++ /dev/null @@ -1,429 +0,0 @@ -/* - * custom_shaders.c: - * Implementation for custom shaders feature - */ - -#include "shared.h" - -#define MAX_CUSTOM_SHADERS 32 // Maximum number of linkable custom shaders -#define MAX_SHADER_PARAMS 16 // Maximum number of parameters per custom shader - -// Internal stuffs -void *frag_uniforms = NULL; -void *vert_uniforms = NULL; - -GLuint cur_program = 0; // Current in use custom program (0 = No custom program) - -// Uniform struct -typedef struct uniform { - GLboolean isVertex; - const SceGxmProgramParameter *ptr; - void *chain; -} uniform; - -// Generic shader struct -typedef struct shader { - GLenum type; - GLboolean valid; - SceGxmShaderPatcherId id; - const SceGxmProgram *prog; -} shader; - -// Program struct holding vertex/fragment shader info -typedef struct program { - shader *vshader; - shader *fshader; - GLboolean valid; - SceGxmVertexAttribute attr[16]; - SceGxmVertexStream stream[16]; - SceGxmVertexProgram *vprog; - SceGxmFragmentProgram *fprog; - GLuint attr_num; - const SceGxmProgramParameter *wvp; - uniform *uniforms; - uniform *last_uniform; -} program; - -// Internal shaders array -static shader shaders[MAX_CUSTOM_SHADERS]; - -// Internal programs array -static program progs[MAX_CUSTOM_SHADERS / 2]; - -void resetCustomShaders(void) { - // Init custom shaders - int i; - for (i = 0; i < MAX_CUSTOM_SHADERS; i++) { - shaders[i].valid = 0; - progs[i >> 1].valid = 0; - } -} - -void changeCustomShadersBlend(SceGxmBlendInfo *blend_info) { - int j; - for (j = 0; j < MAX_CUSTOM_SHADERS / 2; j++) { - program *p = &progs[j]; - if (p->valid) { - sceGxmShaderPatcherCreateFragmentProgram(gxm_shader_patcher, - p->fshader->id, - SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4, - msaa_mode, - blend_info, - p->vshader->prog, - &p->fprog); - } - } -} - -void reloadCustomShader(void) { - if (cur_program == 0) - return; - program *p = &progs[cur_program - 1]; - sceGxmSetVertexProgram(gxm_context, p->vprog); - sceGxmSetFragmentProgram(gxm_context, p->fprog); -} - -void _vglDrawObjects_CustomShadersIMPL(GLenum mode, GLsizei count, GLboolean implicit_wvp) { - program *p = &progs[cur_program - 1]; - if (implicit_wvp) { - if (mvp_modified) { - matrix4x4_multiply(mvp_matrix, projection_matrix, modelview_matrix); - mvp_modified = GL_FALSE; - } - if (vert_uniforms == NULL) - sceGxmReserveVertexDefaultUniformBuffer(gxm_context, &vert_uniforms); - if (p->wvp == NULL) - p->wvp = sceGxmProgramFindParameterByName(p->vshader->prog, "wvp"); - sceGxmSetUniformDataF(vert_uniforms, p->wvp, 0, 16, (const float *)mvp_matrix); - } -} - -/* - * ------------------------------ - * - IMPLEMENTATION STARTS HERE - - * ------------------------------ - */ - -GLuint glCreateShader(GLenum shaderType) { - // Looking for a free shader slot - GLuint i, res = 0; - for (i = 1; i <= MAX_CUSTOM_SHADERS; i++) { - if (!(shaders[i - 1].valid)) { - res = i; - break; - } - } - - // All shader slots are busy, exiting call - if (res == 0) - return res; - - // Reserving and initializing shader slot - switch (shaderType) { - case GL_FRAGMENT_SHADER: - shaders[res - 1].type = GL_FRAGMENT_SHADER; - break; - case GL_VERTEX_SHADER: - shaders[res - 1].type = GL_VERTEX_SHADER; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - shaders[res - 1].valid = GL_TRUE; - - return res; -} - -void glShaderBinary(GLsizei count, const GLuint *handles, GLenum binaryFormat, const void *binary, GLsizei length) { - // Grabbing passed shader - shader *s = &shaders[handles[0] - 1]; - - // Allocating compiled shader on RAM and registering it into sceGxmShaderPatcher - s->prog = (SceGxmProgram *)malloc(length); - memcpy((void *)s->prog, binary, length); - sceGxmShaderPatcherRegisterProgram(gxm_shader_patcher, s->prog, &s->id); - s->prog = sceGxmShaderPatcherGetProgramFromId(s->id); -} - -void glDeleteShader(GLuint shad) { - // Grabbing passed shader - shader *s = &shaders[shad - 1]; - - // Deallocating shader and unregistering it from sceGxmShaderPatcher - if (s->valid) { - sceGxmShaderPatcherForceUnregisterProgram(gxm_shader_patcher, s->id); - free((void *)s->prog); - } - s->valid = GL_FALSE; -} - -void glAttachShader(GLuint prog, GLuint shad) { - // Grabbing passed shader and program - shader *s = &shaders[shad - 1]; - program *p = &progs[prog - 1]; - - // Attaching shader to desired program - if (p->valid && s->valid) { - switch (s->type) { - case GL_VERTEX_SHADER: - p->vshader = s; - break; - case GL_FRAGMENT_SHADER: - p->fshader = s; - break; - default: - break; - } - } else - _vitagl_error = GL_INVALID_VALUE; -} - -GLuint glCreateProgram(void) { - // Looking for a free program slot - GLuint i, res = 0; - for (i = 1; i <= (MAX_CUSTOM_SHADERS / 2); i++) { - // Program slot found, reserving and initializing it - if (!(progs[i - 1].valid)) { - res = i; - progs[i - 1].valid = GL_TRUE; - progs[i - 1].attr_num = 0; - progs[i - 1].wvp = NULL; - progs[i - 1].uniforms = NULL; - progs[i - 1].last_uniform = NULL; - break; - } - } - return res; -} - -void glDeleteProgram(GLuint prog) { - // Grabbing passed program - program *p = &progs[prog - 1]; - - // Releasing both vertex and fragment programs from sceGxmShaderPatcher - if (p->valid) { - unsigned int count, i; - sceGxmShaderPatcherGetFragmentProgramRefCount(gxm_shader_patcher, p->fprog, &count); - for (i = 0; i < count; i++) { - sceGxmShaderPatcherReleaseFragmentProgram(gxm_shader_patcher, p->fprog); - sceGxmShaderPatcherReleaseVertexProgram(gxm_shader_patcher, p->vprog); - } - while (p->uniforms != NULL) { - uniform *old = p->uniforms; - p->uniforms = (uniform *)p->uniforms->chain; - free(old); - } - } - p->valid = GL_FALSE; -} - -void glLinkProgram(GLuint progr) { - // Grabbing passed program - program *p = &progs[progr - 1]; - - // Creating fragment and vertex program via sceGxmShaderPatcher - sceGxmShaderPatcherCreateVertexProgram(gxm_shader_patcher, - p->vshader->id, p->attr, p->attr_num, - p->stream, p->attr_num, &p->vprog); - sceGxmShaderPatcherCreateFragmentProgram(gxm_shader_patcher, - p->fshader->id, SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4, - msaa_mode, NULL, p->vshader->prog, - &p->fprog); -} - -void glUseProgram(GLuint prog) { - // Setting current custom program to passed program - cur_program = prog; - - // Setting in-use vertex and fragment program in sceGxm - reloadCustomShader(); -} - -GLint glGetUniformLocation(GLuint prog, const GLchar *name) { - // Grabbing passed program - program *p = &progs[prog - 1]; - - uniform *res = (uniform *)malloc(sizeof(uniform)); - res->chain = NULL; - if (p->last_uniform != NULL) - p->last_uniform->chain = (void *)res; - p->last_uniform = res; - - // Checking if parameter is a vertex or fragment related one - res->ptr = sceGxmProgramFindParameterByName(p->vshader->prog, name); - res->isVertex = GL_TRUE; - if (res->ptr == NULL) { - res->ptr = sceGxmProgramFindParameterByName(p->fshader->prog, name); - res->isVertex = GL_FALSE; - } - - return (GLint)res; -} - -void glUniform1f(GLint location, GLfloat v0) { - // Grabbing passed uniform - uniform *u = (uniform *)location; - if (u->ptr == NULL) - return; - - // Setting passed value to desired uniform - if (u->isVertex) { - if (vert_uniforms == NULL) - sceGxmReserveVertexDefaultUniformBuffer(gxm_context, &vert_uniforms); - sceGxmSetUniformDataF(vert_uniforms, u->ptr, 0, 1, &v0); - } else { - if (frag_uniforms == NULL) - sceGxmReserveFragmentDefaultUniformBuffer(gxm_context, &frag_uniforms); - sceGxmSetUniformDataF(frag_uniforms, u->ptr, 0, 1, &v0); - } -} - -void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) { - // Grabbing passed uniform - uniform *u = (uniform *)location; - if (u->ptr == NULL) - return; - - // Setting passed value to desired uniform - if (u->isVertex) { - if (vert_uniforms == NULL) - sceGxmReserveVertexDefaultUniformBuffer(gxm_context, &vert_uniforms); - sceGxmSetUniformDataF(vert_uniforms, u->ptr, 0, 2 * count, value); - } else { - if (frag_uniforms == NULL) - sceGxmReserveFragmentDefaultUniformBuffer(gxm_context, &frag_uniforms); - sceGxmSetUniformDataF(frag_uniforms, u->ptr, 0, 2 * count, value); - } -} - -void glUniform4fv(GLint location, GLsizei count, const GLfloat *value) { - // Grabbing passed uniform - uniform *u = (uniform *)location; - if (u->ptr == NULL) - return; - - // Setting passed value to desired uniform - if (u->isVertex) { - if (vert_uniforms == NULL) - sceGxmReserveVertexDefaultUniformBuffer(gxm_context, &vert_uniforms); - sceGxmSetUniformDataF(vert_uniforms, u->ptr, 0, 4 * count, value); - } else { - if (frag_uniforms == NULL) - sceGxmReserveFragmentDefaultUniformBuffer(gxm_context, &frag_uniforms); - sceGxmSetUniformDataF(frag_uniforms, u->ptr, 0, 4 * count, value); - } -} - -void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { - // Grabbing passed uniform - uniform *u = (uniform *)location; - if (u->ptr == NULL) - return; - - // Setting passed value to desired uniform - if (u->isVertex) { - if (vert_uniforms == NULL) - sceGxmReserveVertexDefaultUniformBuffer(gxm_context, &vert_uniforms); - sceGxmSetUniformDataF(vert_uniforms, u->ptr, 0, 16 * count, value); - } else { - if (frag_uniforms == NULL) - sceGxmReserveFragmentDefaultUniformBuffer(gxm_context, &frag_uniforms); - sceGxmSetUniformDataF(frag_uniforms, u->ptr, 0, 16 * count, value); - } -} - -/* - * ------------------------------ - * - VGL_EXT_gxp_shaders - - * ------------------------------ - */ - -// Equivalent of glBindAttribLocation but for sceGxm architecture -void vglBindAttribLocation(GLuint prog, GLuint index, const GLchar *name, const GLuint num, const GLenum type) { - // Grabbing passed program - program *p = &progs[prog - 1]; - SceGxmVertexAttribute *attributes = &p->attr[index]; - SceGxmVertexStream *streams = &p->stream[index]; - - // Looking for desired parameter in requested program - const SceGxmProgramParameter *param = sceGxmProgramFindParameterByName(p->vshader->prog, name); - - // Setting stream index and offset values - attributes->streamIndex = index; - attributes->offset = 0; - - // Detecting attribute format and size - int bpe; - switch (type) { - case GL_FLOAT: - attributes->format = SCE_GXM_ATTRIBUTE_FORMAT_F32; - bpe = sizeof(float); - break; - case GL_UNSIGNED_BYTE: - attributes->format = SCE_GXM_ATTRIBUTE_FORMAT_U8N; - bpe = sizeof(uint8_t); - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - - // Setting various info about the stream - attributes->componentCount = num; - attributes->regIndex = sceGxmProgramParameterGetResourceIndex(param); - streams->stride = bpe * num; - streams->indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT; - if (index >= p->attr_num) - p->attr_num = index + 1; -} - -// Equivalent of glVertexAttribLocation but for sceGxm architecture -void vglVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint count, const GLvoid *pointer) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (stride < 0) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - - // Detecting type size - int bpe; - switch (type) { - case GL_FLOAT: - bpe = sizeof(GLfloat); - break; - case GL_SHORT: - bpe = sizeof(GLshort); - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - - // Allocating enough memory on vitaGL mempool - void *ptr = gpu_pool_memalign(count * bpe * size, bpe * size); - - // Copying passed data to vitaGL mempool - if (stride == 0) - memcpy(ptr, pointer, count * bpe * size); // Faster if stride == 0 - else { - int i; - uint8_t *dst = (uint8_t *)ptr; - uint8_t *src = (uint8_t *)pointer; - for (i = 0; i < count; i++) { - memcpy(dst, src, bpe * size); - dst += (bpe * size); - src += stride; - } - } - - // Setting vertex stream to passed index in sceGxm - sceGxmSetVertexStream(gxm_context, index, ptr); -} - -void vglVertexAttribPointerMapped(GLuint index, const GLvoid *pointer) { - // Setting vertex stream to passed index in sceGxm - sceGxmSetVertexStream(gxm_context, index, pointer); -} diff --git a/deps/vitaGL/source/framebuffers.c b/deps/vitaGL/source/framebuffers.c deleted file mode 100644 index 93655a40dc..0000000000 --- a/deps/vitaGL/source/framebuffers.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * framebuffers.c: - * Implementation for framebuffers related functions - */ - -#include "shared.h" - -static framebuffer framebuffers[BUFFERS_NUM]; // Framebuffers array - -framebuffer *active_read_fb = NULL; // Current readback framebuffer in use -framebuffer *active_write_fb = NULL; // Current write framebuffer in use - -uint32_t get_color_from_texture(uint32_t type) { - uint32_t res = 0; - switch (type) { - case GL_RGB: - res = SCE_GXM_COLOR_FORMAT_U8U8U8_BGR; - break; - case GL_RGBA: - res = SCE_GXM_COLOR_FORMAT_U8U8U8U8_ABGR; - break; - case GL_LUMINANCE: - res = SCE_GXM_COLOR_FORMAT_U8_R; - break; - case GL_LUMINANCE_ALPHA: - res = SCE_GXM_COLOR_FORMAT_U8U8_GR; - break; - case GL_INTENSITY: - res = SCE_GXM_COLOR_FORMAT_U8_R; - break; - case GL_ALPHA: - res = SCE_GXM_COLOR_FORMAT_U8_A; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - return res; -} - -/* - * ------------------------------ - * - IMPLEMENTATION STARTS HERE - - * ------------------------------ - */ - -void glGenFramebuffers(GLsizei n, GLuint *ids) { - int i = 0, j = 0; -#ifndef SKIP_ERROR_HANDLING - if (n < 0) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - for (i = 0; i < BUFFERS_NUM; i++) { - if (!framebuffers[i].active) { - ids[j++] = (GLuint)&framebuffers[i]; - framebuffers[i].active = 1; - framebuffers[i].depth_buffer_addr = NULL; - framebuffers[i].stencil_buffer_addr = NULL; - } - if (j >= n) - break; - } -} - -void glDeleteFramebuffers(GLsizei n, GLuint *framebuffers) { -#ifndef SKIP_ERROR_HANDLING - if (n < 0) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - while (n > 0) { - framebuffer *fb = (framebuffer *)framebuffers[n--]; - fb->active = 0; - if (fb->target) { - sceGxmDestroyRenderTarget(fb->target); - fb->target = NULL; - } - if (fb->depth_buffer_addr) { - vitagl_mempool_free(fb->depth_buffer_addr, fb->depth_buffer_mem_type); - vitagl_mempool_free(fb->stencil_buffer_addr, fb->stencil_buffer_mem_type); - fb->depth_buffer_addr = NULL; - fb->stencil_buffer_addr = NULL; - } - } -} - -void glBindFramebuffer(GLenum target, GLuint fb) { - switch (target) { - case GL_DRAW_FRAMEBUFFER: - active_write_fb = (framebuffer *)fb; - break; - case GL_READ_FRAMEBUFFER: - active_read_fb = (framebuffer *)fb; - break; - case GL_FRAMEBUFFER: - active_write_fb = active_read_fb = (framebuffer *)fb; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} - -void glFramebufferTexture(GLenum target, GLenum attachment, GLuint tex_id, GLint level) { - // Detecting requested framebuffer - framebuffer *fb = NULL; - switch (target) { - case GL_DRAW_FRAMEBUFFER: - case GL_FRAMEBUFFER: - fb = active_write_fb; - break; - case GL_READ_FRAMEBUFFER: - fb = active_read_fb; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - - // Aliasing to make code more readable - texture_unit *tex_unit = &texture_units[server_texture_unit]; - texture *tex = &tex_unit->textures[tex_id]; - - // Extracting texture sizes - int tex_w = sceGxmTextureGetWidth(&tex->gxm_tex); - int tex_h = sceGxmTextureGetHeight(&tex->gxm_tex); - - // Detecting requested attachment - switch (attachment) { - case GL_COLOR_ATTACHMENT0: - - // Allocating colorbuffer - sceGxmColorSurfaceInit( - &fb->colorbuffer, - get_color_from_texture(tex->type), - SCE_GXM_COLOR_SURFACE_LINEAR, - msaa_mode == SCE_GXM_MULTISAMPLE_NONE ? SCE_GXM_COLOR_SURFACE_SCALE_NONE : SCE_GXM_COLOR_SURFACE_SCALE_MSAA_DOWNSCALE, - SCE_GXM_OUTPUT_REGISTER_SIZE_32BIT, - tex_w, - tex_h, - tex_w, - sceGxmTextureGetData(&tex->gxm_tex)); - - // Allocating depth and stencil buffer (FIXME: This probably shouldn't be here) - initDepthStencilBuffer(tex_w, tex_h, &fb->depthbuffer, &fb->depth_buffer_addr, &fb->stencil_buffer_addr, &fb->depth_buffer_mem_type, &fb->stencil_buffer_mem_type); - - // Creating rendertarget - SceGxmRenderTargetParams renderTargetParams; - memset(&renderTargetParams, 0, sizeof(SceGxmRenderTargetParams)); - renderTargetParams.flags = 0; - renderTargetParams.width = sceGxmTextureGetWidth(&tex->gxm_tex); - renderTargetParams.height = sceGxmTextureGetHeight(&tex->gxm_tex); - renderTargetParams.scenesPerFrame = 1; - renderTargetParams.multisampleMode = msaa_mode; - renderTargetParams.multisampleLocations = 0; - renderTargetParams.driverMemBlock = -1; - sceGxmCreateRenderTarget(&renderTargetParams, &fb->target); - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} diff --git a/deps/vitaGL/source/get_info.c b/deps/vitaGL/source/get_info.c deleted file mode 100644 index 612a0e7daa..0000000000 --- a/deps/vitaGL/source/get_info.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * get_info.c: - * Implementation for functions returning info to end user - */ - -#include "shared.h" - -// Constants returned by glGetString -static const GLubyte *vendor = "Rinnegatamante"; -static const GLubyte *renderer = "SGX543MP4+"; -static const GLubyte *version = "VitaGL 1.0"; -static const GLubyte *extensions = "VGL_EXT_gpu_objects_array VGL_EXT_gxp_shaders"; - -/* - * ------------------------------ - * - IMPLEMENTATION STARTS HERE - - * ------------------------------ - */ - -const GLubyte *glGetString(GLenum name) { - switch (name) { - case GL_VENDOR: // Vendor - return vendor; - break; - case GL_RENDERER: // Renderer - return renderer; - break; - case GL_VERSION: // openGL Version - return version; - break; - case GL_EXTENSIONS: // Supported extensions - return extensions; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - return NULL; - break; - } -} - -void glGetBooleanv(GLenum pname, GLboolean *params) { - switch (pname) { - case GL_BLEND: // Blending feature state - *params = blend_state; - break; - case GL_BLEND_DST_ALPHA: // Blend Alpha Factor for Destination - *params = (blend_dfactor_a == SCE_GXM_BLEND_FACTOR_ZERO) ? GL_FALSE : GL_TRUE; - break; - case GL_BLEND_DST_RGB: // Blend RGB Factor for Destination - *params = (blend_dfactor_rgb == SCE_GXM_BLEND_FACTOR_ZERO) ? GL_FALSE : GL_TRUE; - break; - case GL_BLEND_SRC_ALPHA: // Blend Alpha Factor for Source - *params = (blend_sfactor_a == SCE_GXM_BLEND_FACTOR_ZERO) ? GL_FALSE : GL_TRUE; - break; - case GL_BLEND_SRC_RGB: // Blend RGB Factor for Source - *params = (blend_sfactor_rgb == SCE_GXM_BLEND_FACTOR_ZERO) ? GL_FALSE : GL_TRUE; - break; - case GL_DEPTH_TEST: // Depth test state - *params = depth_test_state; - break; - case GL_ACTIVE_TEXTURE: // Active texture - *params = GL_FALSE; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} - -void glGetFloatv(GLenum pname, GLfloat *data) { - switch (pname) { - case GL_POLYGON_OFFSET_FACTOR: // Polygon offset factor - *data = pol_factor; - break; - case GL_POLYGON_OFFSET_UNITS: // Polygon offset units - *data = pol_units; - break; - case GL_MODELVIEW_MATRIX: // Modelview matrix - memcpy(data, &modelview_matrix, sizeof(matrix4x4)); - break; - case GL_ACTIVE_TEXTURE: // Active texture - *data = (1.0f * (server_texture_unit + GL_TEXTURE0)); - break; - case GL_MAX_MODELVIEW_STACK_DEPTH: // Max modelview stack depth - *data = MODELVIEW_STACK_DEPTH; - break; - case GL_MAX_PROJECTION_STACK_DEPTH: // Max projection stack depth - *data = GENERIC_STACK_DEPTH; - break; - case GL_MAX_TEXTURE_STACK_DEPTH: // Max texture stack depth - *data = GENERIC_STACK_DEPTH; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} - -void glGetIntegerv(GLenum pname, GLint *data) { - // Aliasing to make code more readable - texture_unit *server_tex_unit = &texture_units[server_texture_unit]; - - switch (pname) { - case GL_POLYGON_MODE: - data[0] = gl_polygon_mode_front; - data[1] = gl_polygon_mode_back; - break; - case GL_SCISSOR_BOX: - data[0] = region.x; - data[1] = region.y; - data[2] = region.w; - data[3] = region.h; - break; - case GL_TEXTURE_BINDING_2D: - *data = server_tex_unit->tex_id; - break; - case GL_MAX_TEXTURE_SIZE: - *data = 1024; - break; - case GL_VIEWPORT: - data[0] = gl_viewport.x; - data[1] = gl_viewport.y; - data[2] = gl_viewport.w; - data[3] = gl_viewport.h; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} - -GLboolean glIsEnabled(GLenum cap) { - GLboolean ret = GL_FALSE; - switch (cap) { - case GL_DEPTH_TEST: - ret = depth_test_state; - break; - case GL_STENCIL_TEST: - ret = stencil_test_state; - break; - case GL_BLEND: - ret = blend_state; - break; - case GL_SCISSOR_TEST: - ret = scissor_test_state; - break; - case GL_CULL_FACE: - ret = cull_face_state; - break; - case GL_POLYGON_OFFSET_FILL: - ret = pol_offset_fill; - break; - case GL_POLYGON_OFFSET_LINE: - ret = pol_offset_line; - break; - case GL_POLYGON_OFFSET_POINT: - ret = pol_offset_point; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - return ret; -} - -GLenum glGetError(void) { - GLenum ret = _vitagl_error; - _vitagl_error = GL_NO_ERROR; - return ret; -} diff --git a/deps/vitaGL/source/gxm.c b/deps/vitaGL/source/gxm.c deleted file mode 100644 index 52ee89289d..0000000000 --- a/deps/vitaGL/source/gxm.c +++ /dev/null @@ -1,384 +0,0 @@ -/* - * gxm.c: - * Implementation for setup and cleanup for sceGxm specific stuffs - */ - -#include "shared.h" - -static void *vdm_ring_buffer_addr; // VDM ring buffer memblock starting address -static void *vertex_ring_buffer_addr; // vertex ring buffer memblock starting address -static void *fragment_ring_buffer_addr; // fragment ring buffer memblock starting address -static void *fragment_usse_ring_buffer_addr; // fragment USSE ring buffer memblock starting address - -static SceGxmRenderTarget *gxm_render_target; // Display render target -static SceGxmColorSurface gxm_color_surfaces[DISPLAY_BUFFER_COUNT]; // Display color surfaces -static void *gxm_color_surfaces_addr[DISPLAY_BUFFER_COUNT]; // Display color surfaces memblock starting addresses -static SceGxmSyncObject *gxm_sync_objects[DISPLAY_BUFFER_COUNT]; // Display sync objects -static unsigned int gxm_front_buffer_index; // Display front buffer id -static unsigned int gxm_back_buffer_index; // Display back buffer id -static unsigned int gxm_scene_flags = 0; // Current gxm scene flags - -static void *gxm_shader_patcher_buffer_addr; // Shader PAtcher buffer memblock starting address -static void *gxm_shader_patcher_vertex_usse_addr; // Shader Patcher vertex USSE memblock starting address -static void *gxm_shader_patcher_fragment_usse_addr; // Shader Patcher fragment USSE memblock starting address - -static void *gxm_depth_surface_addr; // Depth surface memblock starting address -static void *gxm_stencil_surface_addr; // Stencil surface memblock starting address -static SceGxmDepthStencilSurface gxm_depth_stencil_surface; // Depth/Stencil surfaces setup for sceGxm - -SceGxmContext *gxm_context; // sceGxm context instance -GLenum _vitagl_error = GL_NO_ERROR; // Error returned by glGetError -SceGxmShaderPatcher *gxm_shader_patcher; // sceGxmShaderPatcher shader patcher instance - -matrix4x4 mvp_matrix; // ModelViewProjection Matrix -matrix4x4 projection_matrix; // Projection Matrix -matrix4x4 modelview_matrix; // ModelView Matrix - -int DISPLAY_WIDTH; // Display width in pixels -int DISPLAY_HEIGHT; // Display height in pixels -int DISPLAY_STRIDE; // Display stride in pixels -float DISPLAY_WIDTH_FLOAT; // Display width in pixels (float) -float DISPLAY_HEIGHT_FLOAT; // Display height in pixels (float) - -// sceDisplay callback data -struct display_queue_callback_data { - void *addr; -}; - -// sceGxmShaderPatcher custom allocator -static void *shader_patcher_host_alloc_cb(void *user_data, unsigned int size) { - return malloc(size); -} - -// sceGxmShaderPatcher custom deallocator -static void shader_patcher_host_free_cb(void *user_data, void *mem) { - return free(mem); -} - -// sceDisplay callback -static void display_queue_callback(const void *callbackData) { - // Populating sceDisplay framebuffer parameters - SceDisplayFrameBuf display_fb; - const struct display_queue_callback_data *cb_data = callbackData; - memset(&display_fb, 0, sizeof(SceDisplayFrameBuf)); - display_fb.size = sizeof(SceDisplayFrameBuf); - display_fb.base = cb_data->addr; - display_fb.pitch = DISPLAY_STRIDE; - display_fb.pixelformat = SCE_DISPLAY_PIXELFORMAT_A8B8G8R8; - display_fb.width = DISPLAY_WIDTH; - display_fb.height = DISPLAY_HEIGHT; - - // Setting sceDisplay framebuffer - sceDisplaySetFrameBuf(&display_fb, SCE_DISPLAY_SETBUF_NEXTFRAME); - - // Performing VSync if enabled - if (vblank) - sceDisplayWaitVblankStart(); -} - -void initGxm(void) { - // Initializing sceGxm init parameters - SceGxmInitializeParams gxm_init_params; - memset(&gxm_init_params, 0, sizeof(SceGxmInitializeParams)); - gxm_init_params.flags = 0; - gxm_init_params.displayQueueMaxPendingCount = DISPLAY_BUFFER_COUNT - 1; - gxm_init_params.displayQueueCallback = display_queue_callback; - gxm_init_params.displayQueueCallbackDataSize = sizeof(struct display_queue_callback_data); - gxm_init_params.parameterBufferSize = SCE_GXM_DEFAULT_PARAMETER_BUFFER_SIZE; - - // Initializing sceGxm - sceGxmInitialize(&gxm_init_params); -} - -void initGxmContext(void) { - vglMemType type = VGL_MEM_VRAM; - - // Allocating VDM ring buffer - vdm_ring_buffer_addr = gpu_alloc_mapped(SCE_GXM_DEFAULT_VDM_RING_BUFFER_SIZE, &type); - - // Allocating vertex ring buffer - vertex_ring_buffer_addr = gpu_alloc_mapped(SCE_GXM_DEFAULT_VERTEX_RING_BUFFER_SIZE, &type); - - // Allocating fragment ring buffer - fragment_ring_buffer_addr = gpu_alloc_mapped(SCE_GXM_DEFAULT_FRAGMENT_RING_BUFFER_SIZE, &type); - - // Allocating fragment USSE ring buffer - unsigned int fragment_usse_offset; - fragment_usse_ring_buffer_addr = gpu_fragment_usse_alloc_mapped( - SCE_GXM_DEFAULT_FRAGMENT_USSE_RING_BUFFER_SIZE, &fragment_usse_offset); - - // Setting sceGxm context parameters - SceGxmContextParams gxm_context_params; - memset(&gxm_context_params, 0, sizeof(SceGxmContextParams)); - gxm_context_params.hostMem = malloc(SCE_GXM_MINIMUM_CONTEXT_HOST_MEM_SIZE); - gxm_context_params.hostMemSize = SCE_GXM_MINIMUM_CONTEXT_HOST_MEM_SIZE; - gxm_context_params.vdmRingBufferMem = vdm_ring_buffer_addr; - gxm_context_params.vdmRingBufferMemSize = SCE_GXM_DEFAULT_VDM_RING_BUFFER_SIZE; - gxm_context_params.vertexRingBufferMem = vertex_ring_buffer_addr; - gxm_context_params.vertexRingBufferMemSize = SCE_GXM_DEFAULT_VERTEX_RING_BUFFER_SIZE; - gxm_context_params.fragmentRingBufferMem = fragment_ring_buffer_addr; - gxm_context_params.fragmentRingBufferMemSize = SCE_GXM_DEFAULT_FRAGMENT_RING_BUFFER_SIZE; - gxm_context_params.fragmentUsseRingBufferMem = fragment_usse_ring_buffer_addr; - gxm_context_params.fragmentUsseRingBufferMemSize = SCE_GXM_DEFAULT_FRAGMENT_USSE_RING_BUFFER_SIZE; - gxm_context_params.fragmentUsseRingBufferOffset = fragment_usse_offset; - - // Initializing sceGxm context - sceGxmCreateContext(&gxm_context_params, &gxm_context); -} - -void termGxmContext(void) { - // Deallocating ring buffers - vitagl_mempool_free(vdm_ring_buffer_addr, VGL_MEM_VRAM); - vitagl_mempool_free(vertex_ring_buffer_addr, VGL_MEM_VRAM); - vitagl_mempool_free(fragment_ring_buffer_addr, VGL_MEM_VRAM); - gpu_fragment_usse_free_mapped(fragment_usse_ring_buffer_addr); - - // Destroying sceGxm context - sceGxmDestroyContext(gxm_context); -} - -void createDisplayRenderTarget(void) { - // Populating sceGxmRenderTarget parameters - SceGxmRenderTargetParams render_target_params; - memset(&render_target_params, 0, sizeof(SceGxmRenderTargetParams)); - render_target_params.flags = 0; - render_target_params.width = DISPLAY_WIDTH; - render_target_params.height = DISPLAY_HEIGHT; - render_target_params.scenesPerFrame = 1; - render_target_params.multisampleMode = msaa_mode; - render_target_params.multisampleLocations = 0; - render_target_params.driverMemBlock = -1; - - // Creating render target for the display - sceGxmCreateRenderTarget(&render_target_params, &gxm_render_target); -} - -void destroyDisplayRenderTarget(void) { - // Destroying render target for the display - sceGxmDestroyRenderTarget(gxm_render_target); -} - -void initDisplayColorSurfaces(void) { - vglMemType type = VGL_MEM_VRAM; - int i; - for (i = 0; i < DISPLAY_BUFFER_COUNT; i++) { - // Allocating color surface memblock - gxm_color_surfaces_addr[i] = gpu_alloc_mapped( - ALIGN(4 * DISPLAY_STRIDE * DISPLAY_HEIGHT, 1 * 1024 * 1024), - &type); - - // Initializing allocated color surface - memset(gxm_color_surfaces_addr[i], 0, DISPLAY_STRIDE * DISPLAY_HEIGHT); - sceGxmColorSurfaceInit(&gxm_color_surfaces[i], - SCE_GXM_COLOR_FORMAT_A8B8G8R8, - SCE_GXM_COLOR_SURFACE_LINEAR, - msaa_mode == SCE_GXM_MULTISAMPLE_NONE ? SCE_GXM_COLOR_SURFACE_SCALE_NONE : SCE_GXM_COLOR_SURFACE_SCALE_MSAA_DOWNSCALE, - SCE_GXM_OUTPUT_REGISTER_SIZE_32BIT, - DISPLAY_WIDTH, - DISPLAY_HEIGHT, - DISPLAY_STRIDE, - gxm_color_surfaces_addr[i]); - - // Creating a display sync object for the allocated color surface - sceGxmSyncObjectCreate(&gxm_sync_objects[i]); - } -} - -void termDisplayColorSurfaces(void) { - // Deallocating display's color surfaces and destroying sync objects - int i; - for (i = 0; i < DISPLAY_BUFFER_COUNT; i++) { - vitagl_mempool_free(gxm_color_surfaces_addr[i], VGL_MEM_VRAM); - sceGxmSyncObjectDestroy(gxm_sync_objects[i]); - } -} - -void initDepthStencilBuffer(uint32_t w, uint32_t h, SceGxmDepthStencilSurface *surface, void **depth_buffer, void **stencil_buffer, vglMemType *depth_type, vglMemType *stencil_type) { - // Calculating sizes for depth and stencil surfaces - unsigned int depth_stencil_width = ALIGN(w, SCE_GXM_TILE_SIZEX); - unsigned int depth_stencil_height = ALIGN(h, SCE_GXM_TILE_SIZEY); - unsigned int depth_stencil_samples = depth_stencil_width * depth_stencil_height; - if (msaa_mode == SCE_GXM_MULTISAMPLE_2X) - depth_stencil_samples = depth_stencil_samples * 2; - else if (msaa_mode == SCE_GXM_MULTISAMPLE_4X) - depth_stencil_samples = depth_stencil_samples * 4; - - // Allocating depth surface - *depth_type = VGL_MEM_VRAM; - *depth_buffer = gpu_alloc_mapped(4 * depth_stencil_samples, depth_type); - - // Allocating stencil surface - *stencil_type = VGL_MEM_VRAM; - *stencil_buffer = gpu_alloc_mapped(1 * depth_stencil_samples, stencil_type); - - // Initializing depth and stencil surfaces - sceGxmDepthStencilSurfaceInit(surface, - SCE_GXM_DEPTH_STENCIL_FORMAT_DF32M_S8, - SCE_GXM_DEPTH_STENCIL_SURFACE_TILED, - msaa_mode == SCE_GXM_MULTISAMPLE_4X ? depth_stencil_width * 2 : depth_stencil_width, - *depth_buffer, - *stencil_buffer); -} - -void initDepthStencilSurfaces(void) { - vglMemType t1, t2; - initDepthStencilBuffer(DISPLAY_WIDTH, DISPLAY_HEIGHT, &gxm_depth_stencil_surface, &gxm_depth_surface_addr, &gxm_stencil_surface_addr, &t1, &t2); -} - -void termDepthStencilSurfaces(void) { - // Deallocating depth and stencil surfaces memblocks - vitagl_mempool_free(gxm_depth_surface_addr, VGL_MEM_VRAM); - vitagl_mempool_free(gxm_stencil_surface_addr, VGL_MEM_VRAM); -} - -void startShaderPatcher(void) { - // Constants for shader patcher buffers - static const unsigned int shader_patcher_buffer_size = 1024 * 1024; - static const unsigned int shader_patcher_vertex_usse_size = 1024 * 1024; - static const unsigned int shader_patcher_fragment_usse_size = 1024 * 1024; - vglMemType type = VGL_MEM_VRAM; - - // Allocating Shader Patcher buffer - gxm_shader_patcher_buffer_addr = gpu_alloc_mapped( - shader_patcher_buffer_size, &type); - - // Allocating Shader Patcher vertex USSE buffer - unsigned int shader_patcher_vertex_usse_offset; - gxm_shader_patcher_vertex_usse_addr = gpu_vertex_usse_alloc_mapped( - shader_patcher_vertex_usse_size, &shader_patcher_vertex_usse_offset); - - // Allocating Shader Patcher fragment USSE buffer - unsigned int shader_patcher_fragment_usse_offset; - gxm_shader_patcher_fragment_usse_addr = gpu_fragment_usse_alloc_mapped( - shader_patcher_fragment_usse_size, &shader_patcher_fragment_usse_offset); - - // Populating shader patcher parameters - SceGxmShaderPatcherParams shader_patcher_params; - memset(&shader_patcher_params, 0, sizeof(SceGxmShaderPatcherParams)); - shader_patcher_params.userData = NULL; - shader_patcher_params.hostAllocCallback = shader_patcher_host_alloc_cb; - shader_patcher_params.hostFreeCallback = shader_patcher_host_free_cb; - shader_patcher_params.bufferAllocCallback = NULL; - shader_patcher_params.bufferFreeCallback = NULL; - shader_patcher_params.bufferMem = gxm_shader_patcher_buffer_addr; - shader_patcher_params.bufferMemSize = shader_patcher_buffer_size; - shader_patcher_params.vertexUsseAllocCallback = NULL; - shader_patcher_params.vertexUsseFreeCallback = NULL; - shader_patcher_params.vertexUsseMem = gxm_shader_patcher_vertex_usse_addr; - shader_patcher_params.vertexUsseMemSize = shader_patcher_vertex_usse_size; - shader_patcher_params.vertexUsseOffset = shader_patcher_vertex_usse_offset; - shader_patcher_params.fragmentUsseAllocCallback = NULL; - shader_patcher_params.fragmentUsseFreeCallback = NULL; - shader_patcher_params.fragmentUsseMem = gxm_shader_patcher_fragment_usse_addr; - shader_patcher_params.fragmentUsseMemSize = shader_patcher_fragment_usse_size; - shader_patcher_params.fragmentUsseOffset = shader_patcher_fragment_usse_offset; - - // Creating shader patcher instance - sceGxmShaderPatcherCreate(&shader_patcher_params, &gxm_shader_patcher); -} - -void stopShaderPatcher(void) { - // Destroying shader patcher instance - sceGxmShaderPatcherDestroy(gxm_shader_patcher); - - // Freeing shader patcher buffers - vitagl_mempool_free(gxm_shader_patcher_buffer_addr, VGL_MEM_VRAM); - gpu_vertex_usse_free_mapped(gxm_shader_patcher_vertex_usse_addr); - gpu_fragment_usse_free_mapped(gxm_shader_patcher_fragment_usse_addr); -} - -void waitRenderingDone(void) { - // Wait for rendering to be finished - sceGxmDisplayQueueFinish(); - sceGxmFinish(gxm_context); -} - -/* - * ------------------------------ - * - IMPLEMENTATION STARTS HERE - - * ------------------------------ - */ - -void vglStartRendering(void) { - // Starting drawing scene - if (active_write_fb == NULL) { // Default framebuffer is used - sceGxmBeginScene(gxm_context, gxm_scene_flags, gxm_render_target, - NULL, NULL, - gxm_sync_objects[gxm_back_buffer_index], - &gxm_color_surfaces[gxm_back_buffer_index], - &gxm_depth_stencil_surface); - gxm_scene_flags &= ~SCE_GXM_SCENE_VERTEX_WAIT_FOR_DEPENDENCY; - } else { - gxm_scene_flags |= SCE_GXM_SCENE_FRAGMENT_SET_DEPENDENCY; - sceGxmBeginScene(gxm_context, gxm_scene_flags, active_write_fb->target, - NULL, NULL, NULL, - &active_write_fb->colorbuffer, - &active_write_fb->depthbuffer); - gxm_scene_flags |= SCE_GXM_SCENE_VERTEX_WAIT_FOR_DEPENDENCY; - gxm_scene_flags &= ~SCE_GXM_SCENE_FRAGMENT_SET_DEPENDENCY; - } - - // Setting back current viewport if enabled cause sceGxm will reset it at sceGxmEndScene call - if (scissor_test_state) { - if (viewport_mode) - sceGxmSetViewport(gxm_context, x_port, x_scale, y_port, y_scale, z_port, z_scale); - sceGxmSetRegionClip(gxm_context, SCE_GXM_REGION_CLIP_OUTSIDE, region.x, region.y, region.x + region.w, region.y + region.h); - } else if (viewport_mode) { - sceGxmSetViewport(gxm_context, x_port, x_scale, y_port, y_scale, z_port, z_scale); - sceGxmSetRegionClip(gxm_context, SCE_GXM_REGION_CLIP_OUTSIDE, gl_viewport.x, DISPLAY_HEIGHT - gl_viewport.y - gl_viewport.h, gl_viewport.x + gl_viewport.w, gl_viewport.y + gl_viewport.h); - } -} - -void vglStopRenderingInit(void) { - // Ending drawing scene - sceGxmEndScene(gxm_context, NULL, NULL); -} - -void vglStopRenderingTerm(void) { - // Waiting GPU to complete its work - sceGxmFinish(gxm_context); - - if (active_write_fb == NULL) { // Default framebuffer is used - - // Properly requesting a display update - struct display_queue_callback_data queue_cb_data; - queue_cb_data.addr = gxm_color_surfaces_addr[gxm_back_buffer_index]; - sceGxmDisplayQueueAddEntry(gxm_sync_objects[gxm_front_buffer_index], - gxm_sync_objects[gxm_back_buffer_index], &queue_cb_data); - gxm_front_buffer_index = gxm_back_buffer_index; - gxm_back_buffer_index = (gxm_back_buffer_index + 1) % DISPLAY_BUFFER_COUNT; - } - - // Resetting vitaGL mempool - gpu_pool_reset(); -} - -void vglStopRendering() { - // Ending drawing scene - vglStopRenderingInit(); - - // Updating display and resetting vitaGL mempool - vglStopRenderingTerm(); -} - -void vglUpdateCommonDialog() { - // Populating SceCommonDialog parameters - SceCommonDialogUpdateParam updateParam; - memset(&updateParam, 0, sizeof(updateParam)); - updateParam.renderTarget.colorFormat = SCE_GXM_COLOR_FORMAT_A8B8G8R8; - updateParam.renderTarget.surfaceType = SCE_GXM_COLOR_SURFACE_LINEAR; - updateParam.renderTarget.width = DISPLAY_WIDTH; - updateParam.renderTarget.height = DISPLAY_HEIGHT; - updateParam.renderTarget.strideInPixels = DISPLAY_STRIDE; - updateParam.renderTarget.colorSurfaceData = gxm_color_surfaces_addr[gxm_back_buffer_index]; - updateParam.renderTarget.depthSurfaceData = gxm_depth_surface_addr; - updateParam.displaySyncObject = gxm_sync_objects[gxm_back_buffer_index]; - - // Updating sceCommonDialog - sceCommonDialogUpdate(&updateParam); -} - -void glFinish(void) { - // Waiting for GPU to finish drawing jobs - sceGxmFinish(gxm_context); -} diff --git a/deps/vitaGL/source/hacks/sbrk.c b/deps/vitaGL/source/hacks/sbrk.c deleted file mode 100644 index d9e187b48a..0000000000 --- a/deps/vitaGL/source/hacks/sbrk.c +++ /dev/null @@ -1,67 +0,0 @@ -#include -#include -#include - -extern unsigned int _newlib_heap_size_user __attribute__((weak)); - -int _newlib_heap_memblock; -unsigned _newlib_heap_size; -static char *_newlib_heap_base, *_newlib_heap_end, *_newlib_heap_cur; -static char _newlib_sbrk_mutex[32] __attribute__((aligned(8))); - -void *_sbrk_r(struct _reent *reent, ptrdiff_t incr) { - if (sceKernelLockLwMutex((SceKernelLwMutexWork *)_newlib_sbrk_mutex, 1, 0) < 0) - goto fail; - if (!_newlib_heap_base || _newlib_heap_cur + incr >= _newlib_heap_end) { - sceKernelUnlockLwMutex((SceKernelLwMutexWork *)_newlib_sbrk_mutex, 1); - fail: - reent->_errno = ENOMEM; - return (void *)-1; - } - - char *prev_heap_end = _newlib_heap_cur; - _newlib_heap_cur += incr; - - sceKernelUnlockLwMutex((SceKernelLwMutexWork *)_newlib_sbrk_mutex, 1); - return (void *)prev_heap_end; -} - -void _init_vita_heap(void) { - // Create a mutex to use inside _sbrk_r - if (sceKernelCreateLwMutex((SceKernelLwMutexWork *)_newlib_sbrk_mutex, "sbrk mutex", 0, 0, 0) < 0) { - goto failure; - } - if (&_newlib_heap_size_user != NULL) { - _newlib_heap_size = _newlib_heap_size_user; - } else { - // Create a memblock for the heap memory, 32MB - _newlib_heap_size = 32 * 1024 * 1024; - } - _newlib_heap_memblock = sceKernelAllocMemBlock("Newlib heap", 0x0c20d060, _newlib_heap_size, 0); - if (_newlib_heap_memblock < 0) { - goto failure; - } - if (sceKernelGetMemBlockBase(_newlib_heap_memblock, (void *)&_newlib_heap_base) < 0) { - goto failure; - } - _newlib_heap_end = _newlib_heap_base + _newlib_heap_size; - _newlib_heap_cur = _newlib_heap_base; - - return; -failure: - _newlib_heap_memblock = 0; - _newlib_heap_base = 0; - _newlib_heap_cur = 0; -} - -void _free_vita_heap(void) { - // Destroy the sbrk mutex - sceKernelDeleteLwMutex((SceKernelLwMutexWork *)_newlib_sbrk_mutex); - - // Free the heap memblock to avoid memory leakage. - sceKernelFreeMemBlock(_newlib_heap_memblock); - - _newlib_heap_memblock = 0; - _newlib_heap_base = 0; - _newlib_heap_cur = 0; -} diff --git a/deps/vitaGL/source/legacy.c b/deps/vitaGL/source/legacy.c deleted file mode 100644 index 6b01e79699..0000000000 --- a/deps/vitaGL/source/legacy.c +++ /dev/null @@ -1,584 +0,0 @@ -/* - * legacy.c: - * Implementation for legacy openGL 1.0 rendering method - */ - -#include "shared.h" - -// Vertex list struct -typedef struct vertexList { - vector3f v; - void *next; -} vertexList; - -// Color vertex list struct -typedef struct rgbaList { - vector4f v; - void *next; -} rgbaList; - -// Texture coord list struct -typedef struct uvList { - vector2f v; - void *next; -} uvList; - -static vertexList *model_vertices = NULL; // Pointer to vertex list -static vertexList *last_vert = NULL; // Pointer to last element in vertex list -static rgbaList *model_color = NULL; // Pointer to color vertex list -static rgbaList *last_clr = NULL; // Pointer to last element in color vertex list -static uvList *model_uv = NULL; // Pointer to texcoord list -static uvList *last_uv = NULL; // Pointer to last element in texcoord list -static uint64_t vertex_count = 0; // Vertex counter for vertex list -static SceGxmPrimitiveType prim; // Current in use primitive for rendering -static SceGxmPrimitiveTypeExtra prim_extra = SCE_GXM_PRIMITIVE_NONE; // Current in use non native primitive for rendering -static uint8_t np = 0xFF; // Number of expected vertices per element for current in use primitive - -vector4f current_color = { 1.0f, 1.0f, 1.0f, 1.0f }; // Current in use color - -static void purge_vertex_list() { - vertexList *old; - rgbaList *old2; - uvList *old3; - - // Purging color and vertex lists - while (model_vertices != NULL) { - old = model_vertices; - old2 = model_color; - model_vertices = model_vertices->next; - model_color = model_color->next; - free(old); - free(old2); - } - - // Purging texcoord list - while (model_uv != NULL) { - old3 = model_uv; - model_uv = model_uv->next; - free(old3); - } -} - -/* - * ------------------------------ - * - IMPLEMENTATION STARTS HERE - - * ------------------------------ - */ - -void glVertex3f(GLfloat x, GLfloat y, GLfloat z) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (phase != MODEL_CREATION) { - _vitagl_error = GL_INVALID_OPERATION; - return; - } -#endif - - // Adding a new element to color and vertex lists - if (model_vertices == NULL) { - model_vertices = last_vert = (vertexList *)malloc(sizeof(vertexList)); - model_color = last_clr = (rgbaList *)malloc(sizeof(rgbaList)); - } else { - last_vert->next = (vertexList *)malloc(sizeof(vertexList)); - last_clr->next = (rgbaList *)malloc(sizeof(rgbaList)); - last_vert = last_vert->next; - last_clr = last_clr->next; - } - - // Properly populating the new element - last_vert->v.x = x; - last_vert->v.y = y; - last_vert->v.z = z; - memcpy(&last_clr->v, ¤t_color.r, sizeof(vector4f)); - last_clr->next = last_vert->next = NULL; - - // Increasing vertex counter - vertex_count++; -} - -void glVertex3fv(const GLfloat *v) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (phase != MODEL_CREATION) { - _vitagl_error = GL_INVALID_OPERATION; - return; - } -#endif - - // Adding a new element to color and vertex lists - if (model_vertices == NULL) { - model_vertices = last_vert = (vertexList *)malloc(sizeof(vertexList)); - model_color = last_clr = (rgbaList *)malloc(sizeof(rgbaList)); - } else { - last_vert->next = (vertexList *)malloc(sizeof(vertexList)); - last_clr->next = (rgbaList *)malloc(sizeof(rgbaList)); - last_vert = last_vert->next; - last_clr = last_clr->next; - } - - // Properly populating the new element - memcpy(&last_vert->v, v, sizeof(vector3f)); - memcpy(&last_clr->v, ¤t_color.r, sizeof(vector4f)); - last_clr->next = last_vert->next = NULL; - - // Increasing vertex counter - vertex_count++; -} - -void glVertex2f(GLfloat x, GLfloat y) { - glVertex3f(x, y, 0.0f); -} - -void glColor3f(GLfloat red, GLfloat green, GLfloat blue) { - // Setting current color value - current_color.r = red; - current_color.g = green; - current_color.b = blue; - current_color.a = 1.0f; -} - -void glColor3fv(const GLfloat *v) { - // Setting current color value - memcpy(¤t_color.r, v, sizeof(vector3f)); - current_color.a = 1.0f; -} - -void glColor3ub(GLubyte red, GLubyte green, GLubyte blue) { - // Setting current color value - current_color.r = (1.0f * red) / 255.0f; - current_color.g = (1.0f * green) / 255.0f; - current_color.b = (1.0f * blue) / 255.0f; - current_color.a = 1.0f; -} - -void glColor3ubv(const GLubyte *c) { - // Setting current color value - current_color.r = (1.0f * c[0]) / 255.0f; - current_color.g = (1.0f * c[1]) / 255.0f; - current_color.b = (1.0f * c[2]) / 255.0f; - current_color.a = 1.0f; -} - -void glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) { - // Setting current color value - current_color.r = red; - current_color.g = green; - current_color.b = blue; - current_color.a = alpha; -} - -void glColor4fv(const GLfloat *v) { - // Setting current color value - memcpy(¤t_color.r, v, sizeof(vector4f)); -} - -void glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) { - current_color.r = (1.0f * red) / 255.0f; - current_color.g = (1.0f * green) / 255.0f; - current_color.b = (1.0f * blue) / 255.0f; - current_color.a = (1.0f * alpha) / 255.0f; -} - -void glColor4ubv(const GLubyte *c) { - // Setting current color value - current_color.r = (1.0f * c[0]) / 255.0f; - current_color.g = (1.0f * c[1]) / 255.0f; - current_color.b = (1.0f * c[2]) / 255.0f; - current_color.a = (1.0f * c[3]) / 255.0f; -} - -void glTexCoord2fv(GLfloat *f) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (phase != MODEL_CREATION) { - _vitagl_error = GL_INVALID_OPERATION; - return; - } -#endif - - // Adding a new element to texcoord list - if (model_uv == NULL) { - model_uv = last_uv = (uvList *)malloc(sizeof(uvList)); - } else { - last_uv->next = (uvList *)malloc(sizeof(uvList)); - last_uv = last_uv->next; - } - - // Properly populating the new element - last_uv->v.x = f[0]; - last_uv->v.y = f[1]; - last_uv->next = NULL; -} - -void glTexCoord2f(GLfloat s, GLfloat t) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (phase != MODEL_CREATION) { - _vitagl_error = GL_INVALID_OPERATION; - return; - } -#endif - - // Adding a new element to texcoord list - if (model_uv == NULL) { - model_uv = last_uv = (uvList *)malloc(sizeof(uvList)); - } else { - last_uv->next = (uvList *)malloc(sizeof(uvList)); - last_uv = last_uv->next; - } - - // Properly populating the new element - last_uv->v.x = s; - last_uv->v.y = t; - last_uv->next = NULL; -} - -void glTexCoord2i(GLint s, GLint t) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (phase != MODEL_CREATION) { - _vitagl_error = GL_INVALID_OPERATION; - return; - } -#endif - - // Adding a new element to texcoord list - if (model_uv == NULL) { - model_uv = last_uv = (uvList *)malloc(sizeof(uvList)); - } else { - last_uv->next = (uvList *)malloc(sizeof(uvList)); - last_uv = last_uv->next; - } - - // Properly populating the new element - last_uv->v.x = s; - last_uv->v.y = t; - last_uv->next = NULL; -} - -void glArrayElement(GLint i) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (i < 0) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - - // Aliasing client texture unit and client texture id for better code readability - texture_unit *tex_unit = &texture_units[client_texture_unit]; - int texture2d_idx = tex_unit->tex_id; - - // Checking if current texture unit has GL_VERTEX_ARRAY enabled - if (tex_unit->vertex_array_state) { - // Calculating offset of requested element - uint8_t *ptr; - if (tex_unit->vertex_array.stride == 0) - ptr = ((uint8_t *)tex_unit->vertex_array.pointer) + (i * (tex_unit->vertex_array.num * tex_unit->vertex_array.size)); - else - ptr = ((uint8_t *)tex_unit->vertex_array.pointer) + (i * tex_unit->vertex_array.stride); - - // Adding a new element to vertex and color lists - if (model_vertices == NULL) { - model_vertices = last_vert = (vertexList *)malloc(sizeof(vertexList)); - model_color = last_clr = (rgbaList *)malloc(sizeof(rgbaList)); - } else { - last_vert->next = (vertexList *)malloc(sizeof(vertexList)); - last_clr->next = (rgbaList *)malloc(sizeof(rgbaList)); - last_vert = last_vert->next; - last_clr = last_clr->next; - } - last_vert->next = NULL; - last_clr->next = NULL; - - // Populating new vertex element - memcpy(&last_vert->v, ptr, tex_unit->vertex_array.size * tex_unit->vertex_array.num); - - // Checking if current texture unit has GL_COLOR_ARRAY enabled - if (tex_unit->color_array_state) { - // Calculating offset of requested element - uint8_t *ptr_clr; - if (tex_unit->color_array.stride == 0) - ptr_clr = ((uint8_t *)tex_unit->color_array.pointer) + (i * (tex_unit->color_array.num * tex_unit->color_array.size)); - else - ptr_clr = ((uint8_t *)tex_unit->color_array.pointer) + (i * tex_unit->color_array.stride); - - // Populating new color element - last_clr->v.a = 1.0f; - memcpy(&last_clr->v, ptr_clr, tex_unit->color_array.size * tex_unit->color_array.num); - - } else { - // Populating new color element with current color - memcpy(&last_clr->v, ¤t_color.r, sizeof(vector4f)); - } - - // Checking if current texture unit has GL_TEXTURE_COORD_ARRAY enabled - if (tex_unit->texture_array_state) { - // Calculating offset of requested element - uint8_t *ptr_tex; - if (tex_unit->texture_array.stride == 0) - ptr_tex = ((uint8_t *)tex_unit->texture_array.pointer) + (i * (tex_unit->texture_array.num * tex_unit->texture_array.size)); - else - ptr_tex = ((uint8_t *)tex_unit->texture_array.pointer) + (i * tex_unit->texture_array.stride); - - // Adding a new element to texcoord list - if (model_uv == NULL) { - model_uv = last_uv = (uvList *)malloc(sizeof(uvList)); - } else { - last_uv->next = (uvList *)malloc(sizeof(uvList)); - last_uv = last_uv->next; - } - - // Populating new texcoord element - memcpy(&last_uv->v, ptr_tex, tex_unit->vertex_array.size * 2); - last_uv->next = NULL; - } - } -} - -void glBegin(GLenum mode) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (phase == MODEL_CREATION) { - _vitagl_error = GL_INVALID_OPERATION; - return; - } -#endif - - // Changing current openGL machine state - phase = MODEL_CREATION; - - // Translating primitive to sceGxm one - prim_extra = SCE_GXM_PRIMITIVE_NONE; - switch (mode) { - case GL_POINTS: - prim = SCE_GXM_PRIMITIVE_POINTS; - np = 1; - break; - case GL_LINES: - prim = SCE_GXM_PRIMITIVE_LINES; - np = 2; - break; - case GL_TRIANGLES: - prim = SCE_GXM_PRIMITIVE_TRIANGLES; - np = 3; - break; - case GL_TRIANGLE_STRIP: - prim = SCE_GXM_PRIMITIVE_TRIANGLE_STRIP; - np = 1; - break; - case GL_TRIANGLE_FAN: - prim = SCE_GXM_PRIMITIVE_TRIANGLE_FAN; - np = 1; - break; - case GL_QUADS: - prim = SCE_GXM_PRIMITIVE_TRIANGLES; - prim_extra = SCE_GXM_PRIMITIVE_QUADS; - np = 4; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - - // Resetting vertex count - vertex_count = 0; -} - -void glEnd(void) { -#ifndef SKIP_ERROR_HANDLING - // Integrity checks - if (vertex_count == 0 || ((vertex_count % np) != 0)) - return; - - // Error handling - if (phase != MODEL_CREATION) { - _vitagl_error = GL_INVALID_OPERATION; - return; - } -#endif - - // Changing current openGL machine state - phase = NONE; - - // Checking if we can totally skip drawing cause of culling mode - if (no_polygons_mode && ((prim == SCE_GXM_PRIMITIVE_TRIANGLES) || (prim >= SCE_GXM_PRIMITIVE_TRIANGLE_STRIP))) { - purge_vertex_list(); - vertex_count = 0; - return; - } - - // Aliasing server texture unit and texture id for better code readability - texture_unit *tex_unit = &texture_units[server_texture_unit]; - int texture2d_idx = tex_unit->tex_id; - - // Calculating mvp matrix - if (mvp_modified) { - matrix4x4_multiply(mvp_matrix, projection_matrix, modelview_matrix); - mvp_modified = GL_FALSE; - } - - // Checking if we have to write a texture - if ((server_texture_unit >= 0) && (tex_unit->enabled) && (model_uv != NULL) && (tex_unit->textures[texture2d_idx].valid)) { - // Setting proper vertex and fragment programs - sceGxmSetVertexProgram(gxm_context, texture2d_vertex_program_patched); - sceGxmSetFragmentProgram(gxm_context, texture2d_fragment_program_patched); - - // Setting fragment uniforms for alpha test and texture environment - void *alpha_buffer; - sceGxmReserveFragmentDefaultUniformBuffer(gxm_context, &alpha_buffer); - sceGxmSetUniformDataF(alpha_buffer, texture2d_alpha_cut, 0, 1, &alpha_ref); - float alpha_operation = (float)alpha_op; - sceGxmSetUniformDataF(alpha_buffer, texture2d_alpha_op, 0, 1, &alpha_operation); - sceGxmSetUniformDataF(alpha_buffer, texture2d_tint_color, 0, 4, ¤t_color.r); - float tex_env = (float)tex_unit->env_mode; - sceGxmSetUniformDataF(alpha_buffer, texture2d_tex_env, 0, 1, &tex_env); - float fogmode = (float)internal_fog_mode; - sceGxmSetUniformDataF(alpha_buffer, texture2d_fog_mode, 0, 1, &fogmode); - sceGxmSetUniformDataF(alpha_buffer, texture2d_fog_color, 0, 4, &fog_color.r); - sceGxmSetUniformDataF(alpha_buffer, texture2d_tex_env_color, 0, 4, &texenv_color.r); - - } else { - // Setting proper vertex and fragment programs - sceGxmSetVertexProgram(gxm_context, rgba_vertex_program_patched); - sceGxmSetFragmentProgram(gxm_context, rgba_fragment_program_patched); - } - - // Reserving default uniform buffer for wvp - int i, j; - void *vertex_wvp_buffer; - sceGxmReserveVertexDefaultUniformBuffer(gxm_context, &vertex_wvp_buffer); - - // Checking if we have to write a texture - if (model_uv != NULL) { - // Setting wvp matrix - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_wvp, 0, 16, (const float *)mvp_matrix); - - // Setting fogging uniforms - float fogmode = (float)internal_fog_mode; - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_fog_mode2, 0, 1, (const float *)&fogmode); - float clipplane0 = (float)clip_plane0; - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_clip_plane0, 0, 1, &clipplane0); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_clip_plane0_eq, 0, 4, &clip_plane0_eq.x); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_mv, 0, 16, (const float *)modelview_matrix); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_fog_near, 0, 1, (const float *)&fog_near); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_fog_far, 0, 1, (const float *)&fog_far); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_fog_density, 0, 1, (const float *)&fog_density); - - // Setting in use texture - sceGxmSetFragmentTexture(gxm_context, 0, &tex_unit->textures[texture2d_idx].gxm_tex); - - // Properly generating vertices, uv map and indices buffers - vector3f *vertices; - vector2f *uv_map; - uint16_t *indices; - int n = 0, quad_n = 0; - vertexList *object = model_vertices; - uvList *object_uv = model_uv; - uint64_t idx_count = vertex_count; - switch (prim_extra) { - case SCE_GXM_PRIMITIVE_NONE: - vertices = (vector3f *)gpu_pool_memalign(vertex_count * sizeof(vector3f), sizeof(vector3f)); - uv_map = (vector2f *)gpu_pool_memalign(vertex_count * sizeof(vector2f), sizeof(vector2f)); - memset(vertices, 0, (vertex_count * sizeof(vector3f))); - indices = (uint16_t *)gpu_pool_memalign(idx_count * sizeof(uint16_t), sizeof(uint16_t)); - for (i = 0; i < vertex_count; i++) { - memcpy(&vertices[n], &object->v, sizeof(vector3f)); - memcpy(&uv_map[n], &object_uv->v, sizeof(vector2f)); - indices[n] = n; - object = object->next; - object_uv = object_uv->next; - n++; - } - break; - case SCE_GXM_PRIMITIVE_QUADS: - quad_n = vertex_count >> 2; - idx_count = quad_n * 6; - vertices = (vector3f *)gpu_pool_memalign(vertex_count * sizeof(vector3f), sizeof(vector3f)); - uv_map = (vector2f *)gpu_pool_memalign(vertex_count * sizeof(vector2f), sizeof(vector2f)); - memset(vertices, 0, (vertex_count * sizeof(vector3f))); - indices = (uint16_t *)gpu_pool_memalign(idx_count * sizeof(uint16_t), sizeof(uint16_t)); - for (i = 0; i < quad_n; i++) { - indices[i * 6] = i * 4; - indices[i * 6 + 1] = i * 4 + 1; - indices[i * 6 + 2] = i * 4 + 3; - indices[i * 6 + 3] = i * 4 + 1; - indices[i * 6 + 4] = i * 4 + 2; - indices[i * 6 + 5] = i * 4 + 3; - } - for (j = 0; j < vertex_count; j++) { - memcpy(&vertices[j], &object->v, sizeof(vector3f)); - memcpy(&uv_map[j], &object_uv->v, sizeof(vector2f)); - object = object->next; - object_uv = object_uv->next; - } - break; - } - - // Performing the requested draw call - sceGxmSetVertexStream(gxm_context, 0, vertices); - sceGxmSetVertexStream(gxm_context, 1, uv_map); - sceGxmDraw(gxm_context, prim, SCE_GXM_INDEX_FORMAT_U16, indices, idx_count); - - } else { - // Setting wvp matrix - sceGxmSetUniformDataF(vertex_wvp_buffer, rgba_wvp, 0, 16, (const float *)mvp_matrix); - - // Properly generating vertices, colors and indices buffers - vector3f *vertices; - vector4f *colors; - uint16_t *indices; - int n = 0, quad_n = 0; - vertexList *object = model_vertices; - rgbaList *object_clr = model_color; - uint64_t idx_count = vertex_count; - switch (prim_extra) { - case SCE_GXM_PRIMITIVE_NONE: - vertices = (vector3f *)gpu_pool_memalign(vertex_count * sizeof(vector3f), sizeof(vector3f)); - colors = (vector4f *)gpu_pool_memalign(vertex_count * sizeof(vector4f), sizeof(vector4f)); - memset(vertices, 0, (vertex_count * sizeof(vector3f))); - indices = (uint16_t *)gpu_pool_memalign(idx_count * sizeof(uint16_t), sizeof(uint16_t)); - for (i = 0; i < vertex_count; i++) { - memcpy(&vertices[n], &object->v, sizeof(vector3f)); - memcpy(&colors[n], &object_clr->v, sizeof(vector4f)); - indices[n] = n; - object = object->next; - object_clr = object_clr->next; - n++; - } - break; - case SCE_GXM_PRIMITIVE_QUADS: - quad_n = vertex_count >> 2; - idx_count = quad_n * 6; - vertices = (vector3f *)gpu_pool_memalign(vertex_count * sizeof(vector3f), sizeof(vector3f)); - colors = (vector4f *)gpu_pool_memalign(vertex_count * sizeof(vector4f), sizeof(vector4f)); - memset(vertices, 0, (vertex_count * sizeof(vector3f))); - indices = (uint16_t *)gpu_pool_memalign(idx_count * sizeof(uint16_t), sizeof(uint16_t)); - int i, j; - for (i = 0; i < quad_n; i++) { - indices[i * 6] = i * 4; - indices[i * 6 + 1] = i * 4 + 1; - indices[i * 6 + 2] = i * 4 + 3; - indices[i * 6 + 3] = i * 4 + 1; - indices[i * 6 + 4] = i * 4 + 2; - indices[i * 6 + 5] = i * 4 + 3; - } - for (j = 0; j < vertex_count; j++) { - memcpy(&vertices[j], &object->v, sizeof(vector3f)); - memcpy(&colors[j], &object_clr->v, sizeof(vector4f)); - object = object->next; - object_clr = object_clr->next; - } - break; - } - - // Performing the requested draw call - sceGxmSetVertexStream(gxm_context, 0, vertices); - sceGxmSetVertexStream(gxm_context, 1, colors); - sceGxmDraw(gxm_context, prim, SCE_GXM_INDEX_FORMAT_U16, indices, idx_count); - } - - // Purging vertex, colors and texcoord lists - purge_vertex_list(); - vertex_count = 0; -} diff --git a/deps/vitaGL/source/matrices.c b/deps/vitaGL/source/matrices.c deleted file mode 100644 index 618e48d8dc..0000000000 --- a/deps/vitaGL/source/matrices.c +++ /dev/null @@ -1,213 +0,0 @@ -/* - * matrices.c: - * Implementation for matrices related functions - */ - -#include "shared.h" - -matrix4x4 *matrix = NULL; // Current in-use matrix mode -static matrix4x4 modelview_matrix_stack[MODELVIEW_STACK_DEPTH]; // Modelview matrices stack -static uint8_t modelview_stack_counter = 0; // Modelview matrices stack counter -static matrix4x4 projection_matrix_stack[GENERIC_STACK_DEPTH]; // Projection matrices stack -static uint8_t projection_stack_counter = 0; // Projection matrices stack counter -GLboolean mvp_modified = GL_TRUE; // Check if ModelViewProjection matrix needs to be recreated - -/* - * ------------------------------ - * - IMPLEMENTATION STARTS HERE - - * ------------------------------ - */ - -void glMatrixMode(GLenum mode) { - // Changing current in use matrix - switch (mode) { - case GL_MODELVIEW: // Modelview matrix - matrix = &modelview_matrix; - break; - case GL_PROJECTION: // Projection matrix - matrix = &projection_matrix; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} - -void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (phase == MODEL_CREATION) { - _vitagl_error = GL_INVALID_OPERATION; - return; - } else if ((left == right) || (bottom == top) || (nearVal == farVal)) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - - // Initializing ortho matrix with requested parameters - matrix4x4_init_orthographic(*matrix, left, right, bottom, top, nearVal, farVal); - mvp_modified = GL_TRUE; -} - -void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (phase == MODEL_CREATION) { - _vitagl_error = GL_INVALID_OPERATION; - return; - } else if ((left == right) || (bottom == top) || (nearVal < 0) || (farVal < 0)) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - - // Initializing frustum matrix with requested parameters - matrix4x4_init_frustum(*matrix, left, right, bottom, top, nearVal, farVal); - mvp_modified = GL_TRUE; -} - -void glLoadIdentity(void) { - // Set current in use matrix to identity one - matrix4x4_identity(*matrix); - mvp_modified = GL_TRUE; -} - -void glMultMatrixf(const GLfloat *m) { - matrix4x4 res; - -#ifdef TRANSPOSE_MATRICES - // Properly ordering matrix to perform multiplication - matrix4x4 tmp; - int i, j; - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) { - tmp[i][j] = m[j * 4 + i]; - - } - } - - // Multiplicating passed matrix with in use one - matrix4x4_multiply(res, *matrix, tmp); -#else - // Multiplicating passed matrix with in use one - matrix4x4_multiply(res, *matrix, m); -#endif - // Copying result to in use matrix - matrix4x4_copy(*matrix, res); - mvp_modified = GL_TRUE; -} - -void glLoadMatrixf(const GLfloat *m) { -#ifdef TRANSPOSE_MATRICES - // Properly ordering matrix - matrix4x4 tmp; - int i, j; - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) { - (*matrix)[i][j] = m[j * 4 + i]; - } - } -#else - memcpy(*matrix, m, sizeof(matrix4x4)); -#endif - mvp_modified = GL_TRUE; -} - -void glTranslatef(GLfloat x, GLfloat y, GLfloat z) { - // Translating in use matrix - matrix4x4_translate(*matrix, x, y, z); - mvp_modified = GL_TRUE; -} - -void glScalef(GLfloat x, GLfloat y, GLfloat z) { - // Scaling in use matrix - matrix4x4_scale(*matrix, x, y, z); - mvp_modified = GL_TRUE; -} - -void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (phase == MODEL_CREATION) { - _vitagl_error = GL_INVALID_OPERATION; - return; - } -#endif - - // Performing rotation on in use matrix depending on user call - float rad = DEG_TO_RAD(angle); - if (x == 1.0f) { - matrix4x4_rotate_x(*matrix, rad); - } - if (y == 1.0f) { - matrix4x4_rotate_y(*matrix, rad); - } - if (z == 1.0f) { - matrix4x4_rotate_z(*matrix, rad); - } - mvp_modified = GL_TRUE; -} - -void glPushMatrix(void) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (phase == MODEL_CREATION) { - _vitagl_error = GL_INVALID_OPERATION; - return; - } -#endif - - if (matrix == &modelview_matrix) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (modelview_stack_counter >= MODELVIEW_STACK_DEPTH) { - _vitagl_error = GL_STACK_OVERFLOW; - } else -#endif - // Copying current matrix into the matrix stack and increasing stack counter - matrix4x4_copy(modelview_matrix_stack[modelview_stack_counter++], *matrix); - - } else if (matrix == &projection_matrix) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (projection_stack_counter >= GENERIC_STACK_DEPTH) { - _vitagl_error = GL_STACK_OVERFLOW; - } else -#endif - // Copying current matrix into the matrix stack and increasing stack counter - matrix4x4_copy(projection_matrix_stack[projection_stack_counter++], *matrix); - } -} - -void glPopMatrix(void) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (phase == MODEL_CREATION) { - _vitagl_error = GL_INVALID_OPERATION; - return; - } -#endif - - if (matrix == &modelview_matrix) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (modelview_stack_counter == 0) - _vitagl_error = GL_STACK_UNDERFLOW; - else -#endif - // Copying last matrix on stack into current matrix and decreasing stack counter - matrix4x4_copy(*matrix, modelview_matrix_stack[--modelview_stack_counter]); - - } else if (matrix == &projection_matrix) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (projection_stack_counter == 0) - _vitagl_error = GL_STACK_UNDERFLOW; - else -#endif - // Copying last matrix on stack into current matrix and decreasing stack counter - matrix4x4_copy(*matrix, projection_matrix_stack[--projection_stack_counter]); - } - mvp_modified = GL_TRUE; -} diff --git a/deps/vitaGL/source/misc.c b/deps/vitaGL/source/misc.c deleted file mode 100644 index aa1c89dd93..0000000000 --- a/deps/vitaGL/source/misc.c +++ /dev/null @@ -1,536 +0,0 @@ -/* - * misc.c: - * Implementation for miscellaneous functions - */ - -#include "shared.h" - -static void update_fogging_state() { - if (fogging) { - switch (fog_mode) { - case GL_LINEAR: - internal_fog_mode = LINEAR; - break; - case GL_EXP: - internal_fog_mode = EXP; - break; - default: - internal_fog_mode = EXP2; - break; - } - } else - internal_fog_mode = DISABLED; -} - -static void update_polygon_offset() { - switch (polygon_mode_front) { - case SCE_GXM_POLYGON_MODE_TRIANGLE_LINE: - if (pol_offset_line) - sceGxmSetFrontDepthBias(gxm_context, (int)pol_factor, (int)pol_units); - else - sceGxmSetFrontDepthBias(gxm_context, 0, 0); - break; - case SCE_GXM_POLYGON_MODE_TRIANGLE_POINT: - if (pol_offset_point) - sceGxmSetFrontDepthBias(gxm_context, (int)pol_factor, (int)pol_units); - else - sceGxmSetFrontDepthBias(gxm_context, 0, 0); - break; - case SCE_GXM_POLYGON_MODE_TRIANGLE_FILL: - if (pol_offset_fill) - sceGxmSetFrontDepthBias(gxm_context, (int)pol_factor, (int)pol_units); - else - sceGxmSetFrontDepthBias(gxm_context, 0, 0); - break; - } - switch (polygon_mode_back) { - case SCE_GXM_POLYGON_MODE_TRIANGLE_LINE: - if (pol_offset_line) - sceGxmSetBackDepthBias(gxm_context, (int)pol_factor, (int)pol_units); - else - sceGxmSetBackDepthBias(gxm_context, 0, 0); - break; - case SCE_GXM_POLYGON_MODE_TRIANGLE_POINT: - if (pol_offset_point) - sceGxmSetBackDepthBias(gxm_context, (int)pol_factor, (int)pol_units); - else - sceGxmSetBackDepthBias(gxm_context, 0, 0); - break; - case SCE_GXM_POLYGON_MODE_TRIANGLE_FILL: - if (pol_offset_fill) - sceGxmSetBackDepthBias(gxm_context, (int)pol_factor, (int)pol_units); - else - sceGxmSetBackDepthBias(gxm_context, 0, 0); - break; - } -} - -static void change_cull_mode() { - // Setting proper cull mode in sceGxm depending to current openGL machine state - if (cull_face_state) { - if ((gl_front_face == GL_CW) && (gl_cull_mode == GL_BACK)) - sceGxmSetCullMode(gxm_context, SCE_GXM_CULL_CCW); - else if ((gl_front_face == GL_CCW) && (gl_cull_mode == GL_BACK)) - sceGxmSetCullMode(gxm_context, SCE_GXM_CULL_CW); - else if ((gl_front_face == GL_CCW) && (gl_cull_mode == GL_FRONT)) - sceGxmSetCullMode(gxm_context, SCE_GXM_CULL_CCW); - else if ((gl_front_face == GL_CW) && (gl_cull_mode == GL_FRONT)) - sceGxmSetCullMode(gxm_context, SCE_GXM_CULL_CW); - else if (gl_cull_mode == GL_FRONT_AND_BACK) - no_polygons_mode = GL_TRUE; - } else - sceGxmSetCullMode(gxm_context, SCE_GXM_CULL_NONE); -} - -/* - * ------------------------------ - * - IMPLEMENTATION STARTS HERE - - * ------------------------------ - */ - -void glPolygonMode(GLenum face, GLenum mode) { - SceGxmPolygonMode new_mode; - switch (mode) { - case GL_POINT: - new_mode = SCE_GXM_POLYGON_MODE_TRIANGLE_POINT; - break; - case GL_LINE: - new_mode = SCE_GXM_POLYGON_MODE_TRIANGLE_LINE; - break; - case GL_FILL: - new_mode = SCE_GXM_POLYGON_MODE_TRIANGLE_FILL; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - switch (face) { - case GL_FRONT: - polygon_mode_front = new_mode; - gl_polygon_mode_front = mode; - sceGxmSetFrontPolygonMode(gxm_context, new_mode); - break; - case GL_BACK: - polygon_mode_back = new_mode; - gl_polygon_mode_back = mode; - sceGxmSetBackPolygonMode(gxm_context, new_mode); - break; - case GL_FRONT_AND_BACK: - polygon_mode_front = polygon_mode_back = new_mode; - gl_polygon_mode_front = gl_polygon_mode_back = mode; - sceGxmSetFrontPolygonMode(gxm_context, new_mode); - sceGxmSetBackPolygonMode(gxm_context, new_mode); - break; - default: - _vitagl_error = GL_INVALID_ENUM; - return; - } - update_polygon_offset(); -} - -void glPolygonOffset(GLfloat factor, GLfloat units) { - pol_factor = factor; - pol_units = units; - update_polygon_offset(); -} - -void glCullFace(GLenum mode) { - gl_cull_mode = mode; - if (cull_face_state) - change_cull_mode(); -} - -void glFrontFace(GLenum mode) { - gl_front_face = mode; - if (cull_face_state) - change_cull_mode(); -} - -void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) { -#ifndef SKIP_ERROR_HANDLING - if ((width < 0) || (height < 0)) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - x_scale = width >> 1; - x_port = x + x_scale; - y_scale = -(height >> 1); - y_port = DISPLAY_HEIGHT - y + y_scale; - sceGxmSetViewport(gxm_context, x_port, x_scale, y_port, y_scale, z_port, z_scale); - gl_viewport.x = x; - gl_viewport.y = y; - gl_viewport.w = width; - gl_viewport.h = height; - viewport_mode = 1; -} - -void glDepthRange(GLdouble nearVal, GLdouble farVal) { - z_port = (farVal + nearVal) / 2.0f; - z_scale = (farVal - nearVal) / 2.0f; - sceGxmSetViewport(gxm_context, x_port, x_scale, y_port, y_scale, z_port, z_scale); - viewport_mode = 1; -} - -void glDepthRangef(GLfloat nearVal, GLfloat farVal) { - z_port = (farVal + nearVal) / 2.0f; - z_scale = (farVal - nearVal) / 2.0f; - sceGxmSetViewport(gxm_context, x_port, x_scale, y_port, y_scale, z_port, z_scale); - viewport_mode = 1; -} - -void glEnable(GLenum cap) { -#ifndef SKIP_ERROR_HANDLING - if (phase == MODEL_CREATION) { - _vitagl_error = GL_INVALID_OPERATION; - return; - } -#endif - switch (cap) { - case GL_DEPTH_TEST: - depth_test_state = GL_TRUE; - change_depth_func(); - break; - case GL_STENCIL_TEST: - stencil_test_state = GL_TRUE; - change_stencil_settings(); - break; - case GL_BLEND: - if (!blend_state) - change_blend_factor(); - blend_state = GL_TRUE; - break; - case GL_SCISSOR_TEST: - scissor_test_state = GL_TRUE; - update_scissor_test(); - break; - case GL_CULL_FACE: - cull_face_state = GL_TRUE; - change_cull_mode(); - break; - case GL_POLYGON_OFFSET_FILL: - pol_offset_fill = GL_TRUE; - update_polygon_offset(); - break; - case GL_POLYGON_OFFSET_LINE: - pol_offset_line = GL_TRUE; - update_polygon_offset(); - break; - case GL_POLYGON_OFFSET_POINT: - pol_offset_point = GL_TRUE; - update_polygon_offset(); - break; - case GL_TEXTURE_2D: - texture_units[server_texture_unit].enabled = GL_TRUE; - break; - case GL_ALPHA_TEST: - alpha_test_state = GL_TRUE; - update_alpha_test_settings(); - break; - case GL_FOG: - fogging = GL_TRUE; - update_fogging_state(); - break; - case GL_CLIP_PLANE0: - clip_plane0 = GL_TRUE; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} - -void glDisable(GLenum cap) { -#ifndef SKIP_ERROR_HANDLING - if (phase == MODEL_CREATION) { - _vitagl_error = GL_INVALID_OPERATION; - return; - } -#endif - switch (cap) { - case GL_DEPTH_TEST: - depth_test_state = GL_FALSE; - change_depth_func(); - break; - case GL_STENCIL_TEST: - stencil_test_state = GL_FALSE; - change_stencil_settings(); - break; - case GL_BLEND: - if (blend_state) - disable_blend(); - blend_state = GL_FALSE; - break; - case GL_SCISSOR_TEST: - scissor_test_state = GL_FALSE; - update_scissor_test(); - break; - case GL_CULL_FACE: - cull_face_state = GL_FALSE; - change_cull_mode(); - break; - case GL_POLYGON_OFFSET_FILL: - pol_offset_fill = GL_FALSE; - update_polygon_offset(); - break; - case GL_POLYGON_OFFSET_LINE: - pol_offset_line = GL_FALSE; - update_polygon_offset(); - break; - case GL_POLYGON_OFFSET_POINT: - pol_offset_point = GL_FALSE; - update_polygon_offset(); - break; - case GL_TEXTURE_2D: - texture_units[server_texture_unit].enabled = GL_FALSE; - break; - case GL_ALPHA_TEST: - alpha_test_state = GL_FALSE; - update_alpha_test_settings(); - break; - case GL_FOG: - fogging = GL_FALSE; - update_fogging_state(); - break; - case GL_CLIP_PLANE0: - clip_plane0 = GL_FALSE; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} - -void glClear(GLbitfield mask) { - GLenum orig_depth_test = depth_test_state; - if ((mask & GL_COLOR_BUFFER_BIT) == GL_COLOR_BUFFER_BIT) { - invalidate_depth_test(); - change_depth_write(SCE_GXM_DEPTH_WRITE_DISABLED); - sceGxmSetFrontPolygonMode(gxm_context, SCE_GXM_POLYGON_MODE_TRIANGLE_FILL); - sceGxmSetBackPolygonMode(gxm_context, SCE_GXM_POLYGON_MODE_TRIANGLE_FILL); - sceGxmSetVertexProgram(gxm_context, clear_vertex_program_patched); - sceGxmSetFragmentProgram(gxm_context, clear_fragment_program_patched); - void *color_buffer; - sceGxmReserveFragmentDefaultUniformBuffer(gxm_context, &color_buffer); - sceGxmSetUniformDataF(color_buffer, clear_color, 0, 4, &clear_rgba_val.r); - sceGxmSetVertexStream(gxm_context, 0, clear_vertices); - sceGxmDraw(gxm_context, SCE_GXM_PRIMITIVE_TRIANGLE_FAN, SCE_GXM_INDEX_FORMAT_U16, depth_clear_indices, 4); - validate_depth_test(); - change_depth_write((depth_mask_state && orig_depth_test) ? SCE_GXM_DEPTH_WRITE_ENABLED : SCE_GXM_DEPTH_WRITE_DISABLED); - sceGxmSetFrontPolygonMode(gxm_context, polygon_mode_front); - sceGxmSetBackPolygonMode(gxm_context, polygon_mode_back); - } - if ((mask & GL_DEPTH_BUFFER_BIT) == GL_DEPTH_BUFFER_BIT) { - invalidate_depth_test(); - change_depth_write(SCE_GXM_DEPTH_WRITE_ENABLED); - sceGxmSetVertexProgram(gxm_context, clear_vertex_program_patched); - sceGxmSetFragmentProgram(gxm_context, disable_color_buffer_fragment_program_patched); - void *depth_buffer; - sceGxmReserveFragmentDefaultUniformBuffer(gxm_context, &depth_buffer); - float temp = depth_value; - sceGxmSetUniformDataF(depth_buffer, clear_depth, 0, 1, &temp); - sceGxmSetVertexStream(gxm_context, 0, clear_vertices); - sceGxmDraw(gxm_context, SCE_GXM_PRIMITIVE_TRIANGLE_FAN, SCE_GXM_INDEX_FORMAT_U16, depth_clear_indices, 4); - validate_depth_test(); - change_depth_write((depth_mask_state && orig_depth_test) ? SCE_GXM_DEPTH_WRITE_ENABLED : SCE_GXM_DEPTH_WRITE_DISABLED); - } - if ((mask & GL_STENCIL_BUFFER_BIT) == GL_STENCIL_BUFFER_BIT) { - invalidate_depth_test(); - change_depth_write(SCE_GXM_DEPTH_WRITE_DISABLED); - sceGxmSetVertexProgram(gxm_context, clear_vertex_program_patched); - sceGxmSetFragmentProgram(gxm_context, disable_color_buffer_fragment_program_patched); - sceGxmSetFrontStencilFunc(gxm_context, - SCE_GXM_STENCIL_FUNC_NEVER, - SCE_GXM_STENCIL_OP_REPLACE, - SCE_GXM_STENCIL_OP_REPLACE, - SCE_GXM_STENCIL_OP_REPLACE, - 0, stencil_value * 0xFF); - sceGxmSetBackStencilFunc(gxm_context, - SCE_GXM_STENCIL_FUNC_NEVER, - SCE_GXM_STENCIL_OP_REPLACE, - SCE_GXM_STENCIL_OP_REPLACE, - SCE_GXM_STENCIL_OP_REPLACE, - 0, stencil_value * 0xFF); - void *depth_buffer; - sceGxmReserveFragmentDefaultUniformBuffer(gxm_context, &depth_buffer); - float temp = 1.0f; - sceGxmSetUniformDataF(depth_buffer, clear_depth, 0, 1, &temp); - sceGxmSetVertexStream(gxm_context, 0, clear_vertices); - sceGxmDraw(gxm_context, SCE_GXM_PRIMITIVE_TRIANGLE_FAN, SCE_GXM_INDEX_FORMAT_U16, depth_clear_indices, 4); - validate_depth_test(); - change_depth_write((depth_mask_state && orig_depth_test) ? SCE_GXM_DEPTH_WRITE_ENABLED : SCE_GXM_DEPTH_WRITE_DISABLED); - change_stencil_settings(); - } -} - -void glClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) { - clear_rgba_val.r = red; - clear_rgba_val.g = green; - clear_rgba_val.b = blue; - clear_rgba_val.a = alpha; -} - -void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *data) { - SceDisplayFrameBuf pParam; - pParam.size = sizeof(SceDisplayFrameBuf); - sceDisplayGetFrameBuf(&pParam, SCE_DISPLAY_SETBUF_NEXTFRAME); - y = DISPLAY_HEIGHT - (height + y); - int i, j; - uint8_t *out8 = (uint8_t *)data; - uint8_t *in8 = (uint8_t *)pParam.base; - uint32_t *out32 = (uint32_t *)data; - uint32_t *in32 = (uint32_t *)pParam.base; - switch (format) { - case GL_RGBA: - switch (type) { - case GL_UNSIGNED_BYTE: - in32 += (x + y * pParam.pitch); - for (i = 0; i < height; i++) { - for (j = 0; j < width; j++) { - out32[(height - (i + 1)) * width + j] = in32[j]; - } - in32 += pParam.pitch; - } - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - break; - case GL_RGB: - switch (type) { - case GL_UNSIGNED_BYTE: - in8 += (x * 4 + y * pParam.pitch * 4); - for (i = 0; i < height; i++) { - for (j = 0; j < width; j++) { - out8[((height - (i + 1)) * width + j) * 3] = in8[j * 4]; - out8[((height - (i + 1)) * width + j) * 3 + 1] = in8[j * 4 + 1]; - out8[((height - (i + 1)) * width + j) * 3 + 2] = in8[j * 4 + 2]; - } - in8 += pParam.pitch * 4; - } - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} - -void glLineWidth(GLfloat width) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (width <= 0) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - - // Changing line and point width as requested - sceGxmSetFrontPointLineWidth(gxm_context, width); - sceGxmSetBackPointLineWidth(gxm_context, width); -} - -void glPointSize(GLfloat size) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (size <= 0) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - - // Changing line and point width as requested - sceGxmSetFrontPointLineWidth(gxm_context, size); - sceGxmSetBackPointLineWidth(gxm_context, size); -} - -void glFogf(GLenum pname, GLfloat param) { - switch (pname) { - case GL_FOG_MODE: - fog_mode = param; - update_fogging_state(); - break; - case GL_FOG_DENSITY: - fog_density = param; - break; - case GL_FOG_START: - fog_near = param; - break; - case GL_FOG_END: - fog_far = param; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} - -void glFogfv(GLenum pname, const GLfloat *params) { - switch (pname) { - case GL_FOG_MODE: - fog_mode = params[0]; - update_fogging_state(); - break; - case GL_FOG_DENSITY: - fog_density = params[0]; - break; - case GL_FOG_START: - fog_near = params[0]; - break; - case GL_FOG_END: - fog_far = params[0]; - break; - case GL_FOG_COLOR: - memcpy(&fog_color.r, params, sizeof(vector4f)); - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} - -void glFogi(GLenum pname, const GLint param) { - switch (pname) { - case GL_FOG_MODE: - fog_mode = param; - update_fogging_state(); - break; - case GL_FOG_DENSITY: - fog_density = param; - break; - case GL_FOG_START: - fog_near = param; - break; - case GL_FOG_END: - fog_far = param; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} - -void glClipPlane(GLenum plane, const GLdouble *equation) { - switch (plane) { - case GL_CLIP_PLANE0: - clip_plane0_eq.x = equation[0]; - clip_plane0_eq.y = equation[1]; - clip_plane0_eq.z = equation[2]; - clip_plane0_eq.w = equation[3]; - matrix4x4 inverted, inverted_transposed; - matrix4x4_invert(inverted, modelview_matrix); - matrix4x4_transpose(inverted_transposed, inverted); - vector4f temp; - vector4f_matrix4x4_mult(&temp, inverted_transposed, &clip_plane0_eq); - memcpy(&clip_plane0_eq.x, &temp.x, sizeof(vector4f)); - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} diff --git a/deps/vitaGL/source/shaders.h b/deps/vitaGL/source/shaders.h deleted file mode 100644 index 980b5bef56..0000000000 --- a/deps/vitaGL/source/shaders.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - *shaders.h: - *Header file for default shaders related stuffs - */ - -#ifndef _SHADERS_H_ -#define _SHADERS_H_ - -// Disable color buffer shader -SceGxmShaderPatcherId disable_color_buffer_fragment_id; -const SceGxmProgramParameter *disable_color_buffer_position; -SceGxmFragmentProgram *disable_color_buffer_fragment_program_patched; -const SceGxmProgramParameter *clear_depth; - -// Clear shader -SceGxmShaderPatcherId clear_vertex_id; -SceGxmShaderPatcherId clear_fragment_id; -const SceGxmProgramParameter *clear_position; -const SceGxmProgramParameter *clear_color; -SceGxmVertexProgram *clear_vertex_program_patched; -SceGxmFragmentProgram *clear_fragment_program_patched; - -// Color (RGBA/RGB) shader -SceGxmShaderPatcherId rgba_vertex_id; -SceGxmShaderPatcherId rgb_vertex_id; -SceGxmShaderPatcherId rgba_fragment_id; -const SceGxmProgramParameter *rgba_position; -const SceGxmProgramParameter *rgba_color; -const SceGxmProgramParameter *rgba_wvp; -const SceGxmProgramParameter *rgb_position; -const SceGxmProgramParameter *rgb_color; -const SceGxmProgramParameter *rgb_wvp; -SceGxmVertexProgram *rgba_vertex_program_patched; -SceGxmVertexProgram *rgba_u8n_vertex_program_patched; -SceGxmVertexProgram *rgb_vertex_program_patched; -SceGxmVertexProgram *rgb_u8n_vertex_program_patched; -SceGxmFragmentProgram *rgba_fragment_program_patched; -const SceGxmProgram *rgba_fragment_program; - -// Texture2D shader -SceGxmShaderPatcherId texture2d_vertex_id; -SceGxmShaderPatcherId texture2d_fragment_id; -const SceGxmProgramParameter *texture2d_position; -const SceGxmProgramParameter *texture2d_texcoord; -const SceGxmProgramParameter *texture2d_wvp; -const SceGxmProgramParameter *texture2d_alpha_cut; -const SceGxmProgramParameter *texture2d_alpha_op; -const SceGxmProgramParameter *texture2d_tint_color; -const SceGxmProgramParameter *texture2d_tex_env; -const SceGxmProgramParameter *texture2d_clip_plane0; -const SceGxmProgramParameter *texture2d_clip_plane0_eq; -const SceGxmProgramParameter *texture2d_mv; -const SceGxmProgramParameter *texture2d_fog_mode; -const SceGxmProgramParameter *texture2d_fog_mode2; -const SceGxmProgramParameter *texture2d_fog_near; -const SceGxmProgramParameter *texture2d_fog_far; -const SceGxmProgramParameter *texture2d_fog_density; -const SceGxmProgramParameter *texture2d_fog_color; -const SceGxmProgramParameter *texture2d_tex_env_color; -SceGxmVertexProgram *texture2d_vertex_program_patched; -SceGxmFragmentProgram *texture2d_fragment_program_patched; -const SceGxmProgram *texture2d_fragment_program; - -// Texture2D+RGBA shader -SceGxmShaderPatcherId texture2d_rgba_vertex_id; -SceGxmShaderPatcherId texture2d_rgba_fragment_id; -const SceGxmProgramParameter *texture2d_rgba_position; -const SceGxmProgramParameter *texture2d_rgba_texcoord; -const SceGxmProgramParameter *texture2d_rgba_wvp; -const SceGxmProgramParameter *texture2d_rgba_alpha_cut; -const SceGxmProgramParameter *texture2d_rgba_alpha_op; -const SceGxmProgramParameter *texture2d_rgba_color; -const SceGxmProgramParameter *texture2d_rgba_tex_env; -const SceGxmProgramParameter *texture2d_rgba_clip_plane0; -const SceGxmProgramParameter *texture2d_rgba_clip_plane0_eq; -const SceGxmProgramParameter *texture2d_rgba_mv; -const SceGxmProgramParameter *texture2d_rgba_fog_mode; -const SceGxmProgramParameter *texture2d_rgba_fog_mode2; -const SceGxmProgramParameter *texture2d_rgba_fog_near; -const SceGxmProgramParameter *texture2d_rgba_fog_far; -const SceGxmProgramParameter *texture2d_rgba_fog_density; -const SceGxmProgramParameter *texture2d_rgba_fog_color; -const SceGxmProgramParameter *texture2d_rgba_tex_env_color; -SceGxmVertexProgram *texture2d_rgba_vertex_program_patched; -SceGxmVertexProgram *texture2d_rgba_u8n_vertex_program_patched; -SceGxmFragmentProgram *texture2d_rgba_fragment_program_patched; -const SceGxmProgram *texture2d_rgba_fragment_program; - -#endif diff --git a/deps/vitaGL/source/shaders/clear_f.h b/deps/vitaGL/source/shaders/clear_f.h deleted file mode 100644 index 6cdf4477f3..0000000000 --- a/deps/vitaGL/source/shaders/clear_f.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __clear_f__ -#define __clear_f__ - -static unsigned int size_clear_f = 240; -static unsigned char clear_f[] __attribute__((aligned(16))) = { - 0x47, 0x58, 0x50, 0x00, 0x01, 0x04, 0x00, 0x00, 0xee, 0x00, 0x00, 0x00, 0xd2, 0x36, 0xf6, 0xf2, - 0x44, 0xaa, 0x22, 0x14, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x78, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x80, 0x19, 0xa0, - 0x7e, 0x0d, 0x84, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa, - 0x00, 0x00, 0x00, 0xc5, 0x22, 0x04, 0x80, 0x38, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x75, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, -}; - -#endif diff --git a/deps/vitaGL/source/shaders/clear_v.h b/deps/vitaGL/source/shaders/clear_v.h deleted file mode 100644 index a89b2489ce..0000000000 --- a/deps/vitaGL/source/shaders/clear_v.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __clear_v__ -#define __clear_v__ - -static unsigned int size_clear_v = 264; -static unsigned char clear_v[] __attribute__((aligned(16))) = { - 0x47, 0x58, 0x50, 0x00, 0x01, 0x04, 0x00, 0x00, 0x05, 0x01, 0x00, 0x00, 0x5b, 0x80, 0x2c, 0x29, - 0x17, 0xc6, 0xc1, 0x92, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xc4, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x07, 0x44, 0xfa, 0x00, 0x00, 0x00, 0x00, 0x40, 0x09, 0x00, 0xf8, 0x01, 0x00, 0x24, 0x9f, - 0x88, 0x1f, 0xc5, 0x08, 0x00, 0x0f, 0x00, 0x03, 0x21, 0x05, 0x80, 0x38, 0x00, 0x0f, 0x04, 0x03, - 0x59, 0x05, 0x80, 0x38, 0x00, 0x00, 0x20, 0xa0, 0x00, 0x50, 0x27, 0xfb, 0x10, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x00, -}; - -#endif diff --git a/deps/vitaGL/source/shaders/disable_color_buffer_f.h b/deps/vitaGL/source/shaders/disable_color_buffer_f.h deleted file mode 100644 index c6c4f81174..0000000000 --- a/deps/vitaGL/source/shaders/disable_color_buffer_f.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __disable_color_buffer_f__ -#define __disable_color_buffer_f__ - -static unsigned int size_disable_color_buffer_f = 272; -static unsigned char disable_color_buffer_f[] __attribute__((aligned(16))) = { - 0x47, 0x58, 0x50, 0x00, 0x01, 0x04, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0xf4, 0x51, 0x72, 0xac, - 0x53, 0xb5, 0x21, 0x1b, 0x15, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x44, 0xfa, 0x00, 0x00, 0x00, 0xe0, - 0x08, 0x00, 0x81, 0x50, 0x02, 0x01, 0x00, 0xf0, 0x00, 0x00, 0x30, 0xfb, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x01, 0x04, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xe0, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x13, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5f, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x00, -}; - -#endif diff --git a/deps/vitaGL/source/shaders/rgb_v.h b/deps/vitaGL/source/shaders/rgb_v.h deleted file mode 100644 index 6943aa36fc..0000000000 --- a/deps/vitaGL/source/shaders/rgb_v.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __rgb_v__ -#define __rgb_v__ - -static unsigned int size_rgb_v = 332; -static unsigned char rgb_v[] __attribute__((aligned(16))) = { - 0x47, 0x58, 0x50, 0x00, 0x01, 0x04, 0x00, 0x00, 0x49, 0x01, 0x00, 0x00, 0xbc, 0xb8, 0x59, 0x66, - 0x33, 0x69, 0xbf, 0xbb, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x07, 0x44, 0xfa, 0x00, 0x00, 0x00, 0x00, 0x40, 0x09, 0x00, 0xf8, 0x02, 0x80, 0x81, 0xaf, - 0x9c, 0x0d, 0x80, 0x40, 0x00, 0xa2, 0x3d, 0xc0, 0x81, 0x38, 0x90, 0x18, 0x81, 0x00, 0x04, 0x9f, - 0x84, 0x1f, 0xc5, 0x08, 0x00, 0x0f, 0x08, 0x03, 0x21, 0x05, 0x80, 0x38, 0x00, 0x0f, 0x0c, 0x03, - 0x59, 0x05, 0x80, 0x38, 0x00, 0x00, 0x20, 0xa0, 0x00, 0x50, 0x27, 0xfb, 0x0e, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x10, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x61, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x61, 0x43, - 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x77, 0x76, 0x70, 0x00, 0x00, 0x00, 0x00, -}; - -#endif diff --git a/deps/vitaGL/source/shaders/rgba_f.h b/deps/vitaGL/source/shaders/rgba_f.h deleted file mode 100644 index 71dfb5c3b6..0000000000 --- a/deps/vitaGL/source/shaders/rgba_f.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __rgba_f__ -#define __rgba_f__ - -static unsigned int size_rgba_f = 200; -static unsigned char rgba_f[] __attribute__((aligned(16))) = { - 0x47, 0x58, 0x50, 0x00, 0x01, 0x04, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, 0xb4, 0x45, 0x0f, 0x73, - 0x8c, 0x01, 0x37, 0xf7, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x04, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, 0xa0, 0xc0, 0x2e, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa, -}; - -#endif diff --git a/deps/vitaGL/source/shaders/rgba_v.h b/deps/vitaGL/source/shaders/rgba_v.h deleted file mode 100644 index e75acdee18..0000000000 --- a/deps/vitaGL/source/shaders/rgba_v.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __rgba_v__ -#define __rgba_v__ - -static unsigned int size_rgba_v = 308; -static unsigned char rgba_v[] __attribute__((aligned(16))) = { - 0x47, 0x58, 0x50, 0x00, 0x01, 0x04, 0x00, 0x00, 0x31, 0x01, 0x00, 0x00, 0x05, 0x21, 0xf7, 0xc8, - 0xe0, 0xa4, 0xdd, 0x80, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xc4, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x07, 0x44, 0xfa, 0x80, 0x00, 0x08, 0x83, 0x21, 0x1d, 0x80, 0x38, 0x02, 0x80, 0x81, 0xaf, - 0x9c, 0x0d, 0x80, 0x40, 0x00, 0xa2, 0x3d, 0xc0, 0x81, 0x30, 0x90, 0x18, 0x00, 0x00, 0x20, 0xa0, - 0x00, 0x50, 0x27, 0xfb, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x30, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x01, 0xe4, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61, 0x50, 0x6f, 0x73, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x61, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x77, 0x76, 0x70, - 0x00, 0x00, 0x00, 0x00, -}; - -#endif diff --git a/deps/vitaGL/source/shaders/texture2d_f.h b/deps/vitaGL/source/shaders/texture2d_f.h deleted file mode 100644 index 5f32817991..0000000000 --- a/deps/vitaGL/source/shaders/texture2d_f.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef __texture2d_f__ -#define __texture2d_f__ - -static unsigned int size_texture2d_f = 1032; -static unsigned char texture2d_f[] __attribute__((aligned(16))) = { - 0x47, 0x58, 0x50, 0x00, 0x01, 0x04, 0x00, 0x00, 0x08, 0x04, 0x00, 0x00, 0xae, 0x88, 0x5a, 0x84, - 0x11, 0x87, 0x08, 0x77, 0x09, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x1c, 0x03, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x1c, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x41, 0x00, 0x00, 0x00, - 0xac, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0xcc, 0x02, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xb0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0x02, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x04, 0x02, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x0e, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x10, 0x44, 0xa3, - 0xa6, 0x41, 0xa4, 0x08, 0x88, 0x10, 0xc4, 0xa1, 0xaa, 0x00, 0xc0, 0x08, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x01, 0x04, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x44, 0xfa, 0x93, 0x83, 0x07, 0xf0, 0x81, 0x06, 0xa8, 0x48, 0x03, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xa0, 0x08, 0x30, 0x81, 0x50, 0x1b, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0xf8, 0x94, 0x83, 0x07, 0xf0, 0x81, 0x01, 0x88, 0x48, 0x01, 0x00, 0x04, 0xb0, - 0x84, 0x41, 0xa4, 0x09, 0x42, 0x00, 0x44, 0xb0, 0x88, 0x41, 0xc0, 0x09, 0x17, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0xf9, 0x95, 0x83, 0x07, 0xf0, 0x81, 0x01, 0xa8, 0x48, 0x0f, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0xf9, 0x96, 0x83, 0x07, 0xf0, 0x81, 0x01, 0xa8, 0x48, 0x09, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x40, 0x09, 0x00, 0xf8, 0x04, 0x81, 0x99, 0xff, - 0xbc, 0x0d, 0xc0, 0x40, 0x00, 0x01, 0x5d, 0x8f, 0x84, 0x8b, 0xa1, 0x18, 0x41, 0x5f, 0x44, 0x1f, - 0x84, 0x1b, 0xa5, 0x08, 0x40, 0x6f, 0x04, 0x10, 0x84, 0x09, 0xa5, 0x08, 0x40, 0x6f, 0x4d, 0x10, - 0x80, 0x00, 0x81, 0x08, 0x41, 0x80, 0x4d, 0x80, 0x00, 0x81, 0xe1, 0x18, 0x0b, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0xf8, 0x41, 0x03, 0x00, 0xf0, 0x84, 0x91, 0xa0, 0x00, 0xc2, 0x11, 0x40, 0xf0, - 0x84, 0x00, 0x80, 0x00, 0x42, 0x80, 0x64, 0xb0, 0x00, 0x11, 0x84, 0x08, 0x07, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x40, 0x09, 0x00, 0xf8, 0x04, 0x81, 0x81, 0xff, - 0x9c, 0x0d, 0xc0, 0x40, 0x41, 0x00, 0x11, 0x8f, 0xc0, 0x8b, 0xb1, 0x18, 0x7c, 0x00, 0x10, 0x80, - 0x84, 0x81, 0xa0, 0x00, 0x7c, 0x10, 0x50, 0x80, 0x84, 0x40, 0x80, 0x00, 0x80, 0x00, 0x04, 0xc2, - 0x08, 0x05, 0x80, 0x38, 0x18, 0x83, 0x07, 0xf0, 0x81, 0x06, 0x88, 0x48, 0x00, 0x00, 0x0c, 0xa0, - 0x85, 0x01, 0x8b, 0x4d, 0x15, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xfd, 0x14, 0x83, 0x07, 0xf0, - 0x81, 0x01, 0x88, 0x48, 0x80, 0x80, 0x03, 0x30, 0x15, 0xc9, 0x88, 0x49, 0x12, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0xf9, 0x15, 0x83, 0x07, 0xf0, 0x81, 0x01, 0x88, 0x48, 0x80, 0x80, 0x03, 0x30, - 0x95, 0xca, 0x88, 0x49, 0x0f, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x16, 0x83, 0x07, 0xf0, - 0x81, 0x01, 0x88, 0x48, 0x80, 0x80, 0x03, 0x30, 0x95, 0xc2, 0x88, 0x49, 0x0c, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0xf9, 0x17, 0x83, 0x07, 0xf0, 0x81, 0x01, 0x88, 0x48, 0x80, 0x80, 0x03, 0x30, - 0x95, 0xc1, 0x88, 0x49, 0x09, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x13, 0x83, 0x07, 0xf0, - 0x81, 0x01, 0x88, 0x48, 0x80, 0x80, 0x03, 0x30, 0x15, 0xc5, 0x88, 0x49, 0x06, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0xf9, 0x19, 0x83, 0x07, 0xf0, 0x81, 0x01, 0x88, 0x48, 0x00, 0x00, 0x0c, 0xa0, - 0x85, 0x01, 0x8b, 0x48, 0x00, 0x81, 0x03, 0x50, 0x05, 0x89, 0x8f, 0x4d, 0x40, 0x00, 0x00, 0x01, - 0x0a, 0x05, 0x80, 0x38, 0x00, 0x80, 0x03, 0xb0, 0x85, 0x86, 0x88, 0x4a, 0x12, 0x09, 0x00, 0xf0, - 0x06, 0x04, 0x30, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0x04, 0xf8, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x07, 0x44, 0xfa, 0x17, 0x84, 0x07, 0xf0, 0x81, 0x06, 0xa8, 0x48, 0x06, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x40, 0x09, 0x00, 0xf8, 0x0c, 0x85, 0x81, 0xff, - 0x9c, 0x0d, 0xc0, 0x40, 0x02, 0x00, 0x11, 0x8f, 0xc0, 0x8b, 0xb1, 0x18, 0x3c, 0x20, 0x00, 0x00, - 0x84, 0x91, 0x80, 0x00, 0x7c, 0x20, 0x40, 0x00, 0x84, 0x40, 0x80, 0x00, 0x02, 0x80, 0x19, 0x00, - 0x7e, 0x0d, 0x80, 0x40, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xe0, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x13, 0x00, 0x00, 0x00, - 0x12, 0x00, 0x08, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, 0x41, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x41, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x41, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x0e, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x02, 0x04, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x43, 0x75, 0x74, 0x00, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x4f, 0x70, 0x00, 0x74, 0x69, 0x6e, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x74, - 0x65, 0x78, 0x45, 0x6e, 0x76, 0x00, 0x66, 0x6f, 0x67, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x00, 0x66, - 0x6f, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x74, 0x65, 0x78, 0x45, 0x6e, 0x76, 0x43, 0x6f, - 0x6c, 0x6f, 0x72, 0x00, 0x74, 0x65, 0x78, 0x00, -}; - -#endif diff --git a/deps/vitaGL/source/shaders/texture2d_rgba_f.h b/deps/vitaGL/source/shaders/texture2d_rgba_f.h deleted file mode 100644 index 8f6835a5a3..0000000000 --- a/deps/vitaGL/source/shaders/texture2d_rgba_f.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef __texture2d_rgba_f__ -#define __texture2d_rgba_f__ - -static unsigned int size_texture2d_rgba_f = 1040; -static unsigned char texture2d_rgba_f[] __attribute__((aligned(16))) = { - 0x47, 0x58, 0x50, 0x00, 0x01, 0x04, 0x00, 0x00, 0x0e, 0x04, 0x00, 0x00, 0x3d, 0x43, 0x2b, 0xd5, - 0x8b, 0x8f, 0xb3, 0x36, 0x09, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3c, 0x03, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x48, 0x00, 0x00, 0x00, - 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xec, 0x02, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe8, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xd0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x02, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0xc0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x04, 0x02, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0xa9, 0xd0, 0x0c, - 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x0e, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x44, 0xfa, 0x0d, 0x81, 0x07, 0xf0, - 0x81, 0x06, 0xa8, 0x48, 0x03, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x00, 0x02, 0x00, 0xa0, - 0x0a, 0x30, 0x81, 0x50, 0x22, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf8, 0x0e, 0x81, 0x07, 0xf0, - 0x81, 0x01, 0x88, 0x48, 0x80, 0x00, 0x44, 0xa0, 0x84, 0x41, 0xa4, 0x09, 0xc1, 0x00, 0x04, 0xa0, - 0x88, 0x41, 0xc0, 0x09, 0x1b, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x0f, 0x81, 0x07, 0xf0, - 0x81, 0x01, 0xa8, 0x48, 0x13, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x10, 0x81, 0x07, 0xf0, - 0x81, 0x01, 0xa8, 0x48, 0x09, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x09, 0x00, 0xf8, 0x02, 0x80, 0x99, 0xaf, 0xbc, 0x0d, 0xc0, 0x40, 0x02, 0x01, 0x5d, 0x8f, - 0x84, 0x8b, 0xa1, 0x18, 0x41, 0x5f, 0x44, 0x1f, 0x84, 0x1b, 0xa5, 0x08, 0x40, 0x6f, 0x04, 0x10, - 0x86, 0x09, 0xa5, 0x08, 0x40, 0x6f, 0x4d, 0x10, 0x82, 0x00, 0x81, 0x08, 0x43, 0x80, 0x4d, 0x80, - 0x02, 0x81, 0xe1, 0x18, 0x12, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x09, 0x00, 0xf8, 0x02, 0x80, 0x99, 0xaf, 0xbc, 0x0d, 0xc0, 0x40, 0x06, 0x82, 0xa1, 0xaf, - 0x9c, 0x0d, 0xc0, 0x40, 0x04, 0x01, 0x91, 0xdf, 0x80, 0x8b, 0xb1, 0x18, 0x3d, 0x21, 0x11, 0x00, - 0xc2, 0x89, 0xb1, 0x18, 0xbd, 0xa0, 0x48, 0x00, 0xc2, 0x80, 0xb1, 0x18, 0x43, 0x80, 0x4d, 0x80, - 0x02, 0x81, 0xe1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x09, 0x00, 0xf8, 0x06, 0x82, 0x81, 0xaf, 0x9c, 0x0d, 0xc0, 0x40, 0x00, 0x01, 0x1d, 0x8f, - 0xc4, 0x8b, 0xa1, 0x18, 0xc0, 0xc0, 0x13, 0xa0, 0x82, 0x81, 0xa0, 0x00, 0xc1, 0xc0, 0x5b, 0xa0, - 0x82, 0x00, 0x80, 0x00, 0x04, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf8, 0x01, 0x4e, 0x01, 0x01, - 0x02, 0x00, 0x10, 0xfa, 0x00, 0x00, 0x00, 0x20, 0x0a, 0x30, 0x81, 0x50, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x10, 0xfa, 0x92, 0x80, 0x07, 0xf0, 0x81, 0x06, 0x88, 0x48, 0x00, 0x00, 0x0c, 0xa0, - 0x85, 0x01, 0x8b, 0x4d, 0x15, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xfd, 0x8e, 0x80, 0x07, 0xf0, - 0x81, 0x01, 0x88, 0x48, 0x80, 0x80, 0x03, 0xb0, 0x15, 0xc9, 0x88, 0x49, 0x12, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0xf9, 0x8f, 0x80, 0x07, 0xf0, 0x81, 0x01, 0x88, 0x48, 0x80, 0x80, 0x03, 0xb0, - 0x95, 0xca, 0x88, 0x49, 0x0f, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x90, 0x80, 0x07, 0xf0, - 0x81, 0x01, 0x88, 0x48, 0x80, 0x80, 0x03, 0xb0, 0x95, 0xc2, 0x88, 0x49, 0x0c, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0xf9, 0x91, 0x80, 0x07, 0xf0, 0x81, 0x01, 0x88, 0x48, 0x80, 0x80, 0x03, 0xb0, - 0x95, 0xc1, 0x88, 0x49, 0x09, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x8d, 0x80, 0x07, 0xf0, - 0x81, 0x01, 0x88, 0x48, 0x80, 0x80, 0x03, 0xb0, 0x15, 0xc5, 0x88, 0x49, 0x06, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0xf9, 0x93, 0x80, 0x07, 0xf0, 0x81, 0x01, 0x88, 0x48, 0x00, 0x00, 0x0c, 0xa0, - 0x85, 0x01, 0x8b, 0x48, 0x00, 0x81, 0x03, 0x50, 0x05, 0x89, 0x8f, 0x4d, 0x40, 0x00, 0x08, 0x81, - 0x0a, 0x05, 0x80, 0x38, 0x00, 0x81, 0x03, 0xb0, 0x85, 0x86, 0x88, 0x4a, 0x0c, 0x06, 0x00, 0xf0, - 0x06, 0x04, 0x30, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0x04, 0xf8, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x07, 0x44, 0xfa, 0x91, 0x81, 0x07, 0xf0, 0x81, 0x06, 0xa8, 0x48, 0x06, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x40, 0x09, 0x00, 0xf8, 0x06, 0x82, 0x81, 0xff, - 0x9c, 0x0d, 0xc0, 0x40, 0x04, 0x00, 0x11, 0x8f, 0xc0, 0x8b, 0xb1, 0x18, 0x3c, 0x40, 0x00, 0x80, - 0x86, 0x91, 0x80, 0x00, 0x7c, 0x40, 0x40, 0x80, 0x86, 0x40, 0x80, 0x00, 0x02, 0x80, 0x19, 0xa0, - 0x7e, 0x0d, 0x80, 0x40, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xe0, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x13, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x08, 0x00, 0x70, 0x00, 0x00, 0x00, 0x01, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x41, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x41, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x41, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x02, 0x04, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x43, 0x75, 0x74, 0x00, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x4f, 0x70, 0x00, 0x74, 0x65, 0x78, 0x45, 0x6e, 0x76, 0x00, 0x66, 0x6f, 0x67, 0x5f, - 0x6d, 0x6f, 0x64, 0x65, 0x00, 0x66, 0x6f, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x74, 0x65, - 0x78, 0x45, 0x6e, 0x76, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x74, 0x65, 0x78, 0x00, 0x00, 0x00, -}; - -#endif diff --git a/deps/vitaGL/source/shaders/texture2d_rgba_v.h b/deps/vitaGL/source/shaders/texture2d_rgba_v.h deleted file mode 100644 index fd7aac10db..0000000000 --- a/deps/vitaGL/source/shaders/texture2d_rgba_v.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef __texture2d_rgba_v__ -#define __texture2d_rgba_v__ - -static unsigned int size_texture2d_rgba_v = 900; -static unsigned char texture2d_rgba_v[] __attribute__((aligned(16))) = { - 0x47, 0x58, 0x50, 0x00, 0x01, 0x04, 0x00, 0x00, 0x83, 0x03, 0x00, 0x00, 0x8f, 0x3b, 0x70, 0x51, - 0x7e, 0x76, 0xab, 0xcf, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x44, 0x02, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x27, 0x00, 0x00, 0x00, - 0xac, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xd8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x01, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0xc8, 0x01, 0x00, 0x00, 0x37, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1a, 0x00, 0x0d, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x68, 0x41, 0x0a, 0x05, 0x82, 0x38, - 0x14, 0x15, 0x04, 0xa5, 0xa6, 0x10, 0xa4, 0x08, 0x02, 0x0a, 0x20, 0x82, 0x02, 0x00, 0x80, 0x30, - 0x11, 0x85, 0x68, 0xa6, 0x86, 0x10, 0xc0, 0x08, 0x10, 0x06, 0x04, 0xa5, 0xa6, 0x00, 0xa4, 0x08, - 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0x04, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x07, 0x44, 0xfa, 0x01, 0x0e, 0x01, 0x34, 0x0a, 0x00, 0x10, 0xfa, 0x80, 0x00, 0x08, 0x83, - 0x21, 0x25, 0x80, 0x38, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x10, 0xfa, 0x2b, 0x91, 0x07, 0xf0, - 0x81, 0x06, 0xc8, 0x48, 0x40, 0x05, 0xf0, 0xc1, 0x00, 0x05, 0x80, 0x38, 0x41, 0x92, 0x80, 0x41, - 0x81, 0x80, 0xd3, 0x19, 0x06, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x09, 0x00, 0xf8, 0x02, 0x80, 0x81, 0xaf, 0x9c, 0x0d, 0x80, 0x40, 0x08, 0xa2, 0xbd, 0xc0, - 0x82, 0x38, 0x90, 0x18, 0x26, 0x92, 0x99, 0xff, 0xbc, 0x0d, 0x80, 0x40, 0x02, 0xa2, 0x91, 0x81, - 0x81, 0x80, 0xd1, 0x18, 0x00, 0x00, 0x00, 0x00, 0x40, 0x09, 0x00, 0xf8, 0x02, 0x80, 0x81, 0xaf, - 0x9c, 0x0d, 0x80, 0x40, 0x00, 0xa2, 0x3d, 0xc0, 0x81, 0x30, 0x90, 0x18, 0xac, 0x90, 0x07, 0xf0, - 0x81, 0x0a, 0x88, 0x48, 0x80, 0x06, 0x10, 0xc1, 0x01, 0x05, 0x80, 0x39, 0x14, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x40, 0x09, 0x00, 0xf8, 0x02, 0x80, 0x81, 0x5f, - 0x9c, 0x0d, 0x80, 0x40, 0x3c, 0xa2, 0x11, 0x00, 0x82, 0x80, 0x81, 0x18, 0x01, 0x00, 0x00, 0x80, - 0x02, 0x02, 0x80, 0x30, 0x02, 0x00, 0x00, 0x80, 0x02, 0x00, 0x80, 0x30, 0xad, 0x90, 0x07, 0xf0, - 0x81, 0x01, 0x88, 0x48, 0x59, 0x04, 0x14, 0xf0, 0xa6, 0x00, 0x80, 0x01, 0x0a, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0xf9, 0xab, 0x90, 0x07, 0xf0, 0x81, 0x01, 0x88, 0x48, 0x06, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0xf9, 0x00, 0x04, 0x04, 0xe0, 0x86, 0x10, 0xa4, 0x08, 0x00, 0x00, 0x04, 0xa0, - 0x86, 0x00, 0xa4, 0x08, 0x17, 0x00, 0x04, 0xb0, 0x86, 0x10, 0xa4, 0x08, 0x01, 0x00, 0x00, 0x80, - 0x02, 0x06, 0x80, 0x30, 0x03, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf8, 0x00, 0x05, 0x04, 0xe0, - 0x86, 0x10, 0xa4, 0x08, 0x01, 0x00, 0x00, 0x80, 0x02, 0x06, 0x80, 0x30, 0x17, 0x50, 0x04, 0xb0, - 0x86, 0x00, 0xa4, 0x08, 0x00, 0x60, 0x04, 0x91, 0x85, 0x00, 0xa5, 0x08, 0x00, 0x00, 0x20, 0xa0, - 0x00, 0x50, 0x27, 0xfb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x05, 0x00, 0x00, 0x00, - 0x26, 0x35, 0x05, 0xc0, 0x06, 0x00, 0x00, 0x00, 0x3b, 0xaa, 0xb8, 0x3f, 0x0e, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x2a, 0x00, 0x13, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x07, 0x00, 0xb0, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa9, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, - 0x01, 0xe4, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, - 0x41, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, - 0x41, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, - 0x01, 0xe4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x01, 0xe4, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, - 0x01, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, - 0x01, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, - 0x01, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x00, 0x63, 0x6f, - 0x6c, 0x6f, 0x72, 0x00, 0x77, 0x76, 0x70, 0x00, 0x66, 0x6f, 0x67, 0x5f, 0x6d, 0x6f, 0x64, 0x65, - 0x00, 0x63, 0x6c, 0x69, 0x70, 0x5f, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x30, 0x00, 0x63, 0x6c, 0x69, - 0x70, 0x5f, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x30, 0x5f, 0x65, 0x71, 0x00, 0x6d, 0x6f, 0x64, 0x65, - 0x6c, 0x76, 0x69, 0x65, 0x77, 0x00, 0x66, 0x6f, 0x67, 0x5f, 0x6e, 0x65, 0x61, 0x72, 0x00, 0x66, - 0x6f, 0x67, 0x5f, 0x66, 0x61, 0x72, 0x00, 0x66, 0x6f, 0x67, 0x5f, 0x64, 0x65, 0x6e, 0x73, 0x69, - 0x74, 0x79, 0x00, 0x00, -}; - -#endif diff --git a/deps/vitaGL/source/shaders/texture2d_v.h b/deps/vitaGL/source/shaders/texture2d_v.h deleted file mode 100644 index 7a99365bf0..0000000000 --- a/deps/vitaGL/source/shaders/texture2d_v.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef __texture2d_v__ -#define __texture2d_v__ - -static unsigned int size_texture2d_v = 864; -static unsigned char texture2d_v[] __attribute__((aligned(16))) = { - 0x47, 0x58, 0x50, 0x00, 0x01, 0x04, 0x00, 0x00, 0x5d, 0x03, 0x00, 0x00, 0x7d, 0xa1, 0xee, 0xec, - 0x39, 0xcd, 0x14, 0x0a, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x34, 0x02, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x25, 0x00, 0x00, 0x00, - 0xac, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0xe4, 0x01, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0xa0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xc8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0xb8, 0x01, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x12, 0x00, 0x09, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x68, 0x41, 0x0a, 0x05, 0x82, 0x38, - 0x14, 0x15, 0x04, 0xa5, 0xa6, 0x10, 0xa4, 0x08, 0x02, 0x0a, 0x20, 0x82, 0x02, 0x00, 0x80, 0x30, - 0x11, 0x85, 0x68, 0xa6, 0x86, 0x10, 0xc0, 0x08, 0x10, 0x06, 0x04, 0xa5, 0xa6, 0x00, 0xa4, 0x08, - 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0x04, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x07, 0x44, 0xfa, 0x80, 0x00, 0x0c, 0x83, 0x21, 0x05, 0x80, 0x38, 0x2b, 0x91, 0x07, 0xf0, - 0x81, 0x06, 0xc8, 0x48, 0x40, 0x05, 0xf0, 0xc1, 0x00, 0x05, 0x80, 0x38, 0x41, 0x92, 0x00, 0x41, - 0x81, 0x80, 0xd3, 0x19, 0x06, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x09, 0x00, 0xf8, 0x02, 0x80, 0x81, 0xaf, 0x9c, 0x0d, 0x80, 0x40, 0x08, 0xa2, 0x3d, 0xc0, - 0x81, 0x38, 0x90, 0x18, 0x26, 0x92, 0x99, 0xff, 0xbc, 0x0d, 0x80, 0x40, 0x00, 0xa2, 0x11, 0x41, - 0x81, 0x80, 0xd1, 0x18, 0x00, 0x00, 0x00, 0x00, 0x40, 0x09, 0x00, 0xf8, 0x02, 0x80, 0x81, 0xaf, - 0x9c, 0x0d, 0x80, 0x40, 0x00, 0xa2, 0x3d, 0xc0, 0x81, 0x30, 0x90, 0x18, 0xac, 0x90, 0x07, 0xf0, - 0x81, 0x0a, 0x88, 0x48, 0x80, 0x06, 0x08, 0xc1, 0x01, 0x05, 0x80, 0x39, 0x14, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x40, 0x09, 0x00, 0xf8, 0x02, 0x80, 0x81, 0x5f, - 0x9c, 0x0d, 0x80, 0x40, 0x3c, 0xa2, 0x11, 0x00, 0x82, 0x80, 0x81, 0x18, 0x01, 0x00, 0x00, 0x80, - 0x02, 0x02, 0x80, 0x30, 0x02, 0x00, 0x00, 0x80, 0x02, 0x00, 0x80, 0x30, 0xad, 0x90, 0x07, 0xf0, - 0x81, 0x01, 0x88, 0x48, 0x59, 0x04, 0x14, 0xf0, 0xa6, 0x00, 0x80, 0x01, 0x0a, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0xf9, 0xab, 0x90, 0x07, 0xf0, 0x81, 0x01, 0x88, 0x48, 0x06, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0xf9, 0x00, 0x04, 0x04, 0xe0, 0x86, 0x10, 0xa4, 0x08, 0x00, 0x00, 0x04, 0xa0, - 0x86, 0x00, 0xa4, 0x08, 0x17, 0x00, 0x04, 0xb0, 0x86, 0x10, 0xa4, 0x08, 0x01, 0x00, 0x00, 0x80, - 0x02, 0x06, 0x80, 0x30, 0x03, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf8, 0x00, 0x05, 0x04, 0xe0, - 0x86, 0x10, 0xa4, 0x08, 0x01, 0x00, 0x00, 0x80, 0x02, 0x06, 0x80, 0x30, 0x17, 0x50, 0x04, 0xb0, - 0x86, 0x00, 0xa4, 0x08, 0x00, 0x60, 0x84, 0x90, 0x85, 0x00, 0xa5, 0x08, 0x00, 0x00, 0x20, 0xa0, - 0x00, 0x50, 0x27, 0xfb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x05, 0x00, 0x00, 0x00, - 0x26, 0x35, 0x05, 0xc0, 0x06, 0x00, 0x00, 0x00, 0x3b, 0xaa, 0xb8, 0x3f, 0x0e, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x2a, 0x00, 0x13, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x07, 0x00, 0xa0, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, - 0x01, 0xe4, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, - 0x41, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, - 0x41, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, - 0x01, 0xe4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, - 0x01, 0xe4, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, - 0x01, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, - 0x01, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, - 0x01, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x00, 0x77, 0x76, - 0x70, 0x00, 0x66, 0x6f, 0x67, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x00, 0x63, 0x6c, 0x69, 0x70, 0x5f, - 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x30, 0x00, 0x63, 0x6c, 0x69, 0x70, 0x5f, 0x70, 0x6c, 0x61, 0x6e, - 0x65, 0x30, 0x5f, 0x65, 0x71, 0x00, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x76, 0x69, 0x65, 0x77, 0x00, - 0x66, 0x6f, 0x67, 0x5f, 0x6e, 0x65, 0x61, 0x72, 0x00, 0x66, 0x6f, 0x67, 0x5f, 0x66, 0x61, 0x72, - 0x00, 0x66, 0x6f, 0x67, 0x5f, 0x64, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x79, 0x00, 0x00, 0x00, 0x00, -}; - -#endif diff --git a/deps/vitaGL/source/shared.h b/deps/vitaGL/source/shared.h deleted file mode 100644 index 4f9453b70c..0000000000 --- a/deps/vitaGL/source/shared.h +++ /dev/null @@ -1,165 +0,0 @@ -/* - * shared.h: - * All functions/definitions that shouldn't be exposed to - * end users but are used in multiple source files must be here - */ - -#ifndef _SHARED_H_ -#define _SHARED_H_ - -// Internal constants -#define TEXTURES_NUM 4096 // Available textures per texture unit -#define MODELVIEW_STACK_DEPTH 32 // Depth of modelview matrix stack -#define GENERIC_STACK_DEPTH 2 // Depth of generic matrix stack -#define DISPLAY_WIDTH_DEF 960 // Default display width in pixels -#define DISPLAY_HEIGHT_DEF 544 // Default display height in pixels -#define DISPLAY_BUFFER_COUNT 2 // Display buffers to use -#define GXM_TEX_MAX_SIZE 4096 // Maximum width/height in pixels per texture -#define BUFFERS_ADDR 0xA000 // Starting address for buffers indexing -#define BUFFERS_NUM 128 // Maximum number of allocatable buffers - -// Internal constants set in bootup phase -extern int DISPLAY_WIDTH; // Display width in pixels -extern int DISPLAY_HEIGHT; // Display height in pixels -extern int DISPLAY_STRIDE; // Display stride in pixels -extern float DISPLAY_WIDTH_FLOAT; // Display width in pixels (float) -extern float DISPLAY_HEIGHT_FLOAT; // Display height in pixels (float) - -#include -#include -#include - -#include "vitaGL.h" - -#include "utils/gpu_utils.h" -#include "utils/math_utils.h" -#include "utils/mem_utils.h" - -#include "state.h" -#include "texture_callbacks.h" - -// Texture environment mode -typedef enum texEnvMode { - MODULATE = 0, - DECAL = 1, - BLEND = 2, - ADD = 3, - REPLACE = 4 -} texEnvMode; - -// 3D vertex for position + 4D vertex for RGBA color struct -typedef struct rgba_vertex { - vector3f position; - vector4f color; -} rgba_vertex; - -// 3D vertex for position + 3D vertex for RGB color struct -typedef struct rgb_vertex { - vector3f position; - vector3f color; -} rgb_vertex; - -// 3D vertex for position + 2D vertex for UV map struct -typedef struct texture2d_vertex { - vector3f position; - vector2f texcoord; -} texture2d_vertex; - -// Non native primitives implemented -typedef enum SceGxmPrimitiveTypeExtra { - SCE_GXM_PRIMITIVE_NONE = 0, - SCE_GXM_PRIMITIVE_QUADS = 1 -} SceGxmPrimitiveTypeExtra; - -#include "shaders.h" - -// Internal stuffs -extern void *frag_uniforms; -extern void *vert_uniforms; -extern SceGxmMultisampleMode msaa_mode; - -// Debugging tool -#ifdef ENABLE_LOG -void LOG(const char *format, ...); -#endif - -// Depending on SDK, that could be or not defined -#ifndef max -#define max(a, b) ((a) > (b) ? (a) : (b)) -#endif - -// sceGxm viewport setup (NOTE: origin is on center screen) -extern float x_port; -extern float y_port; -extern float z_port; -extern float x_scale; -extern float y_scale; -extern float z_scale; - -extern SceGxmContext *gxm_context; // sceGxm context instance -extern GLenum _vitagl_error; // Error returned by glGetError -extern SceGxmShaderPatcher *gxm_shader_patcher; // sceGxmShaderPatcher shader patcher instance - -matrix4x4 mvp_matrix; // ModelViewProjection Matrix -matrix4x4 projection_matrix; // Projection Matrix -matrix4x4 modelview_matrix; // ModelView Matrix -extern GLboolean mvp_modified; // Check if ModelViewProjection matrix needs to be recreated - -extern GLuint cur_program; // Current in use custom program (0 = No custom program) -extern uint8_t viewport_mode; // Current setting for viewport mode -extern GLboolean vblank; // Current setting for VSync - -extern GLenum orig_depth_test; // Original depth test state (used for depth test invalidation) - -// Scissor test shaders -extern SceGxmFragmentProgram *scissor_test_fragment_program; // Scissor test fragment program -extern vector2f *scissor_test_vertices; // Scissor test region vertices -extern SceUID scissor_test_vertices_uid; // Scissor test vertices memblock id - -extern uint16_t *depth_clear_indices; // Memblock starting address for clear screen indices - -// Clear screen shaders -extern SceGxmVertexProgram *clear_vertex_program_patched; // Patched vertex program for clearing screen -extern vector2f *clear_vertices; // Memblock starting address for clear screen vertices - -/* gxm.c */ -void initGxm(void); // Inits sceGxm -void initGxmContext(void); // Inits sceGxm context -void termGxmContext(void); // Terms sceGxm context -void createDisplayRenderTarget(void); // Creates render target for the display -void destroyDisplayRenderTarget(void); // Destroys render target for the display -void initDisplayColorSurfaces(void); // Creates color surfaces for the display -void termDisplayColorSurfaces(void); // Destroys color surfaces for the display -void initDepthStencilBuffer(uint32_t w, uint32_t h, SceGxmDepthStencilSurface *surface, void **depth_buffer, void **stencil_buffer, vglMemType *depth_type, vglMemType *stencil_type); // Creates depth and stencil surfaces -void initDepthStencilSurfaces(void); // Creates depth and stencil surfaces for the display -void termDepthStencilSurfaces(void); // Destroys depth and stencil surfaces for the display -void startShaderPatcher(void); // Creates a shader patcher instance -void stopShaderPatcher(void); // Destroys a shader patcher instance -void waitRenderingDone(void); // Waits for rendering to be finished - -/* tests.c */ -void change_depth_write(SceGxmDepthWriteMode mode); // Changes current in use depth write mode -void change_depth_func(void); // Changes current in use depth test function -void invalidate_depth_test(void); // Invalidates depth test state -void validate_depth_test(void); // Resets original depth test state after invalidation -void change_stencil_settings(void); // Changes current in use stencil test parameters -GLboolean change_stencil_config(SceGxmStencilOp *cfg, GLenum new); // Changes current in use stencil test operation value -GLboolean change_stencil_func_config(SceGxmStencilFunc *cfg, GLenum new); // Changes current in use stencil test function value -void update_alpha_test_settings(void); // Changes current in use alpha test operation value -void update_scissor_test(void); // Changes current in use scissor test region -void resetScissorTestRegion(void); // Resets scissor test region to default values - -/* blending.c */ -void change_blend_factor(void); // Changes current blending settings for all used shaders -void disable_blend(void); // Disables blending for all used shaders - -/* custom_shaders.c */ -void resetCustomShaders(void); // Resets custom shaders -void changeCustomShadersBlend(SceGxmBlendInfo *blend_info); // Change SceGxmBlendInfo value to all custom shaders -void reloadCustomShader(void); // Reloads in use custom shader inside sceGxm -void _vglDrawObjects_CustomShadersIMPL(GLenum mode, GLsizei count, GLboolean implicit_wvp); // vglDrawObjects implementation for rendering with custom shaders - -/* misc functions */ -void vector2f_convert_to_local_space(vector2f *out, int x, int y, int width, int height); // Converts screen coords to local space - -#endif diff --git a/deps/vitaGL/source/state.c b/deps/vitaGL/source/state.c deleted file mode 100644 index eab845053b..0000000000 --- a/deps/vitaGL/source/state.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * state.c: - * Initial config of the openGL machine state - */ - -#include "shared.h" - -// Blending -GLboolean blend_state = GL_FALSE; // Current state for GL_BLEND -SceGxmBlendFactor blend_sfactor_rgb = SCE_GXM_BLEND_FACTOR_ONE; // Current in use RGB source blend factor -SceGxmBlendFactor blend_dfactor_rgb = SCE_GXM_BLEND_FACTOR_ZERO; // Current in use RGB dest blend factor -SceGxmBlendFactor blend_sfactor_a = SCE_GXM_BLEND_FACTOR_ONE; // Current in use A source blend factor -SceGxmBlendFactor blend_dfactor_a = SCE_GXM_BLEND_FACTOR_ZERO; // Current in use A dest blend factor - -// Polygon Mode -GLfloat pol_factor = 0.0f; // Current factor for glPolygonOffset -GLfloat pol_units = 0.0f; // Current units for glPolygonOffset - -// Texture Units -int8_t client_texture_unit = 0; // Current in use client side texture unit - -// Miscellaneous -glPhase phase = NONE; // Current drawing phase for legacy openGL -vector4f clear_rgba_val; // Current clear color for glClear - -// Fogging -GLboolean fogging = GL_FALSE; // Current fogging processor state -GLint fog_mode = GL_EXP; // Current fogging mode (openGL) -fogType internal_fog_mode = DISABLED; // Current fogging mode (sceGxm) -GLfloat fog_density = 1.0f; // Current fogging density -GLfloat fog_near = 0.0f; // Current fogging near distance -GLfloat fog_far = 1.0f; // Current fogging far distance -vector4f fog_color = { 0.0f, 0.0f, 0.0f, 0.0f }; // Current fogging color - -// Clipping Planes -GLint clip_plane0 = GL_FALSE; // Current status of clip plane 0 -vector4f clip_plane0_eq = { 0.0f, 0.0f, 0.0f, 0.0f }; // Current equation of clip plane 0 - -// Cullling -GLboolean cull_face_state = GL_FALSE; // Current state for GL_CULL_FACE -GLenum gl_cull_mode = GL_BACK; // Current in use openGL cull mode -GLenum gl_front_face = GL_CCW; // Current in use openGL setting for front facing primitives -GLboolean no_polygons_mode = GL_FALSE; // GL_TRUE when cull mode is set to GL_FRONT_AND_BACK - -// Polygon Offset -GLboolean pol_offset_fill = GL_FALSE; // Current state for GL_POLYGON_OFFSET_FILL -GLboolean pol_offset_line = GL_FALSE; // Current state for GL_POLYGON_OFFSET_LINE -GLboolean pol_offset_point = GL_FALSE; // Current state for GL_POLYGON_OFFSET_POINT -SceGxmPolygonMode polygon_mode_front = SCE_GXM_POLYGON_MODE_TRIANGLE_FILL; // Current in use polygon mode for front -SceGxmPolygonMode polygon_mode_back = SCE_GXM_POLYGON_MODE_TRIANGLE_FILL; // Current in use polygon mode for back -GLenum gl_polygon_mode_front = GL_FILL; // Current in use polygon mode for front -GLenum gl_polygon_mode_back = GL_FILL; // Current in use polygon mode for back -viewport gl_viewport; // Current viewport state diff --git a/deps/vitaGL/source/state.h b/deps/vitaGL/source/state.h deleted file mode 100644 index 0d8cb5048b..0000000000 --- a/deps/vitaGL/source/state.h +++ /dev/null @@ -1,191 +0,0 @@ -/* - * state.h: - * Header file managing state of openGL machine - */ - -#ifndef _STATE_H_ -#define _STATE_H_ - -// Drawing phases constants for legacy openGL -typedef enum glPhase { - NONE = 0, - MODEL_CREATION = 1 -} glPhase; - -// Vertex array attributes struct -typedef struct vertexArray { - GLint size; - GLint num; - GLsizei stride; - const GLvoid *pointer; -} vertexArray; - -// Scissor test region struct -typedef struct scissor_region { - int x; - int y; - int w; - int h; -} scissor_region; - -// Viewport struct -typedef struct viewport { - int x; - int y; - int w; - int h; -} viewport; - -// Alpha operations for alpha testing -typedef enum alphaOp { - GREATER_EQUAL = 0, - GREATER = 1, - NOT_EQUAL = 2, - EQUAL = 3, - LESS_EQUAL = 4, - LESS = 5, - NEVER = 6, - ALWAYS = 7 -} alphaOp; - -// Fog modes -typedef enum fogType { - LINEAR = 0, - EXP = 1, - EXP2 = 2, - DISABLED = 3 -} fogType; - -// Texture unit struct -typedef struct texture_unit { - GLboolean enabled; - GLboolean vertex_array_state; - GLboolean color_array_state; - GLboolean texture_array_state; - matrix4x4 stack[GENERIC_STACK_DEPTH]; - texture textures[TEXTURES_NUM]; - vertexArray vertex_array; - vertexArray color_array; - vertexArray texture_array; - GLenum color_object_type; - void *vertex_object; - void *color_object; - void *texture_object; - void *index_object; - int env_mode; - int tex_id; - SceGxmTextureFilter min_filter; - SceGxmTextureFilter mag_filter; - SceGxmTextureAddrMode u_mode; - SceGxmTextureAddrMode v_mode; -} texture_unit; - -// Framebuffer struct -typedef struct framebuffer { - uint8_t active; - SceGxmRenderTarget *target; - SceGxmColorSurface colorbuffer; - SceGxmDepthStencilSurface depthbuffer; - void *depth_buffer_addr; - vglMemType depth_buffer_mem_type; - void *stencil_buffer_addr; - vglMemType stencil_buffer_mem_type; -} framebuffer; - -// Blending -extern GLboolean blend_state; // Current state for GL_BLEND -extern SceGxmBlendFactor blend_sfactor_rgb; // Current in use RGB source blend factor -extern SceGxmBlendFactor blend_dfactor_rgb; // Current in use RGB dest blend factor -extern SceGxmBlendFactor blend_sfactor_a; // Current in use A source blend factor -extern SceGxmBlendFactor blend_dfactor_a; // Current in use A dest blend factor - -// Depth Test -extern GLboolean depth_test_state; // Current state for GL_DEPTH_TEST -extern SceGxmDepthFunc gxm_depth; // Current in-use depth test func -extern GLenum orig_depth_test; // Original depth test state (used for depth test invalidation) -extern GLdouble depth_value; // Current depth test clear value -extern GLboolean depth_mask_state; // Current state for glDepthMask - -// Scissor Test -extern scissor_region region; // Current scissor test region setup -extern GLboolean scissor_test_state; // Current state for GL_SCISSOR_TEST - -// Stencil Test -extern uint8_t stencil_mask_front; // Current in use mask for stencil test on front -extern uint8_t stencil_mask_back; // Current in use mask for stencil test on back -extern uint8_t stencil_mask_front_write; // Current in use mask for write stencil test on front -extern uint8_t stencil_mask_back_write; // Current in use mask for write stencil test on back -extern uint8_t stencil_ref_front; // Current in use reference for stencil test on front -extern uint8_t stencil_ref_back; // Current in use reference for stencil test on back -extern SceGxmStencilOp stencil_fail_front; // Current in use stencil operation when stencil test fails for front -extern SceGxmStencilOp depth_fail_front; // Current in use stencil operation when depth test fails for front -extern SceGxmStencilOp depth_pass_front; // Current in use stencil operation when depth test passes for front -extern SceGxmStencilOp stencil_fail_back; // Current in use stencil operation when stencil test fails for back -extern SceGxmStencilOp depth_fail_back; // Current in use stencil operation when depth test fails for back -extern SceGxmStencilOp depth_pass_back; // Current in use stencil operation when depth test passes for back -extern SceGxmStencilFunc stencil_func_front; // Current in use stencil function on front -extern SceGxmStencilFunc stencil_func_back; // Current in use stencil function on back -extern GLboolean stencil_test_state; // Current state for GL_STENCIL_TEST -extern GLint stencil_value; // Current stencil test clear value - -// Alpha Test -extern GLenum alpha_func; // Current in use alpha test mode -extern GLfloat alpha_ref; // Current in use alpha test reference value -extern int alpha_op; // Current in use alpha test operation -extern GLboolean alpha_test_state; // Current state for GL_ALPHA_TEST - -// Polygon Mode -extern GLfloat pol_factor; // Current factor for glPolygonOffset -extern GLfloat pol_units; // Current units for glPolygonOffset - -// Texture Units -extern texture_unit texture_units[GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS]; // Available texture units -extern int8_t server_texture_unit; // Current in use server side texture unit -extern int8_t client_texture_unit; // Current in use client side texture unit -extern palette *color_table; // Current in-use color table - -// Matrices -extern matrix4x4 *matrix; // Current in-use matrix mode - -// Miscellaneous -extern glPhase phase; // Current drawing phase for legacy openGL -extern vector4f current_color; // Current in use color -extern vector4f clear_rgba_val; // Current clear color for glClear -extern viewport gl_viewport; // Current viewport state - -// Culling -extern GLboolean no_polygons_mode; // GL_TRUE when cull mode is set to GL_FRONT_AND_BACK -extern GLboolean cull_face_state; // Current state for GL_CULL_FACE -extern GLenum gl_cull_mode; // Current in use openGL cull mode -extern GLenum gl_front_face; // Current in use openGL setting for front facing primitives - -// Polygon Offset -extern GLboolean pol_offset_fill; // Current state for GL_POLYGON_OFFSET_FILL -extern GLboolean pol_offset_line; // Current state for GL_POLYGON_OFFSET_LINE -extern GLboolean pol_offset_point; // Current state for GL_POLYGON_OFFSET_POINT -extern SceGxmPolygonMode polygon_mode_front; // Current in use polygon mode for front -extern SceGxmPolygonMode polygon_mode_back; // Current in use polygon mode for back -extern GLenum gl_polygon_mode_front; // Current in use polygon mode for front -extern GLenum gl_polygon_mode_back; // Current in use polygon mode for back - -// Texture Environment -extern vector4f texenv_color; // Current in use texture environment color - -// Fogging -extern GLboolean fogging; // Current fogging processor state -extern GLint fog_mode; // Current fogging mode (openGL) -extern fogType internal_fog_mode; // Current fogging mode (sceGxm) -extern GLfloat fog_density; // Current fogging density -extern GLfloat fog_near; // Current fogging near distance -extern GLfloat fog_far; // Current fogging far distance -extern vector4f fog_color; // Current fogging color - -// Clipping Planes -extern GLint clip_plane0; // Current status of clip plane 0 -extern vector4f clip_plane0_eq; // Current equation of clip plane 0 - -// Framebuffers -extern framebuffer *active_read_fb; // Current readback framebuffer in use -extern framebuffer *active_write_fb; // Current write framebuffer in use - -#endif diff --git a/deps/vitaGL/source/tests.c b/deps/vitaGL/source/tests.c deleted file mode 100644 index d1afbef677..0000000000 --- a/deps/vitaGL/source/tests.c +++ /dev/null @@ -1,463 +0,0 @@ -/* - * tests.c: - * Implementation for all drawing tests functions - */ - -#include "shared.h" - -// Depth Test -GLboolean depth_test_state = GL_FALSE; // Current state for GL_DEPTH_TEST -SceGxmDepthFunc gxm_depth = SCE_GXM_DEPTH_FUNC_LESS; // Current in-use depth test func -GLenum orig_depth_test; // Original depth test state (used for depth test invalidation) -GLdouble depth_value = 1.0f; // Current depth test clear value -GLboolean depth_mask_state = GL_TRUE; // Current state for glDepthMask - -// Scissor Test -scissor_region region; // Current scissor test region setup -GLboolean scissor_test_state = GL_FALSE; // Current state for GL_SCISSOR_TEST -SceGxmFragmentProgram *scissor_test_fragment_program; // Scissor test fragment program -vector2f *scissor_test_vertices = NULL; // Scissor test region vertices -SceUID scissor_test_vertices_uid; // Scissor test vertices memblock id - -// Stencil Test -uint8_t stencil_mask_front = 0xFF; // Current in use mask for stencil test on front -uint8_t stencil_mask_back = 0xFF; // Current in use mask for stencil test on back -uint8_t stencil_mask_front_write = 0xFF; // Current in use mask for write stencil test on front -uint8_t stencil_mask_back_write = 0xFF; // Current in use mask for write stencil test on back -uint8_t stencil_ref_front = 0; // Current in use reference for stencil test on front -uint8_t stencil_ref_back = 0; // Current in use reference for stencil test on back -SceGxmStencilOp stencil_fail_front = SCE_GXM_STENCIL_OP_KEEP; // Current in use stencil operation when stencil test fails for front -SceGxmStencilOp depth_fail_front = SCE_GXM_STENCIL_OP_KEEP; // Current in use stencil operation when depth test fails for front -SceGxmStencilOp depth_pass_front = SCE_GXM_STENCIL_OP_KEEP; // Current in use stencil operation when depth test passes for front -SceGxmStencilOp stencil_fail_back = SCE_GXM_STENCIL_OP_KEEP; // Current in use stencil operation when stencil test fails for back -SceGxmStencilOp depth_fail_back = SCE_GXM_STENCIL_OP_KEEP; // Current in use stencil operation when depth test fails for back -SceGxmStencilOp depth_pass_back = SCE_GXM_STENCIL_OP_KEEP; // Current in use stencil operation when depth test passes for back -SceGxmStencilFunc stencil_func_front = SCE_GXM_STENCIL_FUNC_ALWAYS; // Current in use stencil function on front -SceGxmStencilFunc stencil_func_back = SCE_GXM_STENCIL_FUNC_ALWAYS; // Current in use stencil function on back -GLboolean stencil_test_state = GL_FALSE; // Current state for GL_STENCIL_TEST -GLint stencil_value = 0; // Current stencil test clear value - -// Alpha Test -GLenum alpha_func = GL_ALWAYS; // Current in-use alpha test mode -GLfloat alpha_ref = 0.0f; // Current in use alpha test reference value -int alpha_op = ALWAYS; // Current in use alpha test operation -GLboolean alpha_test_state = GL_FALSE; // Current state for GL_ALPHA_TEST - -void change_depth_write(SceGxmDepthWriteMode mode) { - // Change depth write mode for both front and back primitives - sceGxmSetFrontDepthWriteEnable(gxm_context, mode); - sceGxmSetBackDepthWriteEnable(gxm_context, mode); -} - -void change_depth_func() { - // Setting depth function for both front and back primitives - sceGxmSetFrontDepthFunc(gxm_context, depth_test_state ? gxm_depth : SCE_GXM_DEPTH_FUNC_ALWAYS); - sceGxmSetBackDepthFunc(gxm_context, depth_test_state ? gxm_depth : SCE_GXM_DEPTH_FUNC_ALWAYS); - - // Calling an update for the depth write mode - change_depth_write((depth_mask_state && depth_test_state) ? SCE_GXM_DEPTH_WRITE_ENABLED : SCE_GXM_DEPTH_WRITE_DISABLED); -} - -void invalidate_depth_test() { - // Invalidating current depth test state - orig_depth_test = depth_test_state; - depth_test_state = GL_FALSE; - - // Invoking a depth function update - change_depth_func(); -} - -void validate_depth_test() { - // Resetting original depth test state - depth_test_state = orig_depth_test; - - // Invoking a depth function update - change_depth_func(); -} - -void change_stencil_settings() { - if (stencil_test_state) { - // Setting stencil function for both front and back primitives - sceGxmSetFrontStencilFunc(gxm_context, - stencil_func_front, - stencil_fail_front, - depth_fail_front, - depth_pass_front, - stencil_mask_front, stencil_mask_front_write); - sceGxmSetBackStencilFunc(gxm_context, - stencil_func_back, - stencil_fail_back, - depth_fail_back, - depth_pass_back, - stencil_mask_back, stencil_mask_back_write); - - // Setting stencil ref for both front and back primitives - sceGxmSetFrontStencilRef(gxm_context, stencil_ref_front); - sceGxmSetBackStencilRef(gxm_context, stencil_ref_back); - - } else { - sceGxmSetFrontStencilFunc(gxm_context, - SCE_GXM_STENCIL_FUNC_ALWAYS, - SCE_GXM_STENCIL_OP_KEEP, - SCE_GXM_STENCIL_OP_KEEP, - SCE_GXM_STENCIL_OP_KEEP, - 0, 0); - sceGxmSetBackStencilFunc(gxm_context, - SCE_GXM_STENCIL_FUNC_ALWAYS, - SCE_GXM_STENCIL_OP_KEEP, - SCE_GXM_STENCIL_OP_KEEP, - SCE_GXM_STENCIL_OP_KEEP, - 0, 0); - } -} - -GLboolean change_stencil_config(SceGxmStencilOp *cfg, GLenum new) { - // Translating openGL stencil operation value to sceGxm one - GLboolean ret = GL_TRUE; - switch (new) { - case GL_KEEP: - *cfg = SCE_GXM_STENCIL_OP_KEEP; - break; - case GL_ZERO: - *cfg = SCE_GXM_STENCIL_OP_ZERO; - break; - case GL_REPLACE: - *cfg = SCE_GXM_STENCIL_OP_REPLACE; - break; - case GL_INCR: - *cfg = SCE_GXM_STENCIL_OP_INCR; - break; - case GL_INCR_WRAP: - *cfg = SCE_GXM_STENCIL_OP_INCR_WRAP; - break; - case GL_DECR: - *cfg = SCE_GXM_STENCIL_OP_DECR; - break; - case GL_DECR_WRAP: - *cfg = SCE_GXM_STENCIL_OP_DECR_WRAP; - break; - case GL_INVERT: - *cfg = SCE_GXM_STENCIL_OP_INVERT; - break; - default: - ret = GL_FALSE; - break; - } - return ret; -} - -GLboolean change_stencil_func_config(SceGxmStencilFunc *cfg, GLenum new) { - // Translating openGL stencil function to sceGxm one - GLboolean ret = GL_TRUE; - switch (new) { - case GL_NEVER: - *cfg = SCE_GXM_STENCIL_FUNC_NEVER; - break; - case GL_LESS: - *cfg = SCE_GXM_STENCIL_FUNC_LESS; - break; - case GL_LEQUAL: - *cfg = SCE_GXM_STENCIL_FUNC_LESS_EQUAL; - break; - case GL_GREATER: - *cfg = SCE_GXM_STENCIL_FUNC_GREATER; - break; - case GL_GEQUAL: - *cfg = SCE_GXM_STENCIL_FUNC_GREATER_EQUAL; - break; - case GL_EQUAL: - *cfg = SCE_GXM_STENCIL_FUNC_EQUAL; - break; - case GL_NOTEQUAL: - *cfg = SCE_GXM_STENCIL_FUNC_NOT_EQUAL; - break; - case GL_ALWAYS: - *cfg = SCE_GXM_STENCIL_FUNC_ALWAYS; - break; - default: - ret = GL_FALSE; - break; - } - return ret; -} - -void update_alpha_test_settings() { - // Translating openGL alpha test operation to internal one - if (alpha_test_state) { - switch (alpha_func) { - case GL_EQUAL: - alpha_op = EQUAL; - break; - case GL_LEQUAL: - alpha_op = LESS_EQUAL; - break; - case GL_GEQUAL: - alpha_op = GREATER_EQUAL; - break; - case GL_LESS: - alpha_op = LESS; - break; - case GL_GREATER: - alpha_op = GREATER; - break; - case GL_NOTEQUAL: - alpha_op = NOT_EQUAL; - break; - case GL_NEVER: - alpha_op = NEVER; - break; - default: - alpha_op = ALWAYS; - break; - } - } else - alpha_op = ALWAYS; -} - -void update_scissor_test() { - // Calculating scissor test region vertices - if (scissor_test_state) { - vector2f_convert_to_local_space(scissor_test_vertices, region.x, region.y, region.w, region.h); - } - - // Setting current vertex program to clear screen one and fragment program to scissor test one - sceGxmSetVertexProgram(gxm_context, clear_vertex_program_patched); - sceGxmSetFragmentProgram(gxm_context, scissor_test_fragment_program); - - // Cleaning stencil surface mask update bit on the whole screen - sceGxmSetFrontStencilFunc(gxm_context, - SCE_GXM_STENCIL_FUNC_NEVER, - SCE_GXM_STENCIL_OP_KEEP, - SCE_GXM_STENCIL_OP_KEEP, - SCE_GXM_STENCIL_OP_KEEP, - 0, 0); - sceGxmSetBackStencilFunc(gxm_context, - SCE_GXM_STENCIL_FUNC_NEVER, - SCE_GXM_STENCIL_OP_KEEP, - SCE_GXM_STENCIL_OP_KEEP, - SCE_GXM_STENCIL_OP_KEEP, - 0, 0); - sceGxmSetVertexStream(gxm_context, 0, clear_vertices); - sceGxmDraw(gxm_context, SCE_GXM_PRIMITIVE_TRIANGLE_FAN, SCE_GXM_INDEX_FORMAT_U16, depth_clear_indices, 4); - - // Setting stencil surface mask update bit on the scissor test region - sceGxmSetFrontStencilFunc(gxm_context, - SCE_GXM_STENCIL_FUNC_ALWAYS, - SCE_GXM_STENCIL_OP_KEEP, - SCE_GXM_STENCIL_OP_KEEP, - SCE_GXM_STENCIL_OP_KEEP, - 0, 0); - sceGxmSetBackStencilFunc(gxm_context, - SCE_GXM_STENCIL_FUNC_ALWAYS, - SCE_GXM_STENCIL_OP_KEEP, - SCE_GXM_STENCIL_OP_KEEP, - SCE_GXM_STENCIL_OP_KEEP, - 0, 0); - if (scissor_test_state) - sceGxmSetVertexStream(gxm_context, 0, scissor_test_vertices); - else - sceGxmSetVertexStream(gxm_context, 0, clear_vertices); - sceGxmDraw(gxm_context, SCE_GXM_PRIMITIVE_TRIANGLE_FAN, SCE_GXM_INDEX_FORMAT_U16, depth_clear_indices, 4); - - if (scissor_test_state) - sceGxmSetRegionClip(gxm_context, SCE_GXM_REGION_CLIP_OUTSIDE, region.x, region.y, region.x + region.w, region.y + region.h); - else - sceGxmSetRegionClip(gxm_context, SCE_GXM_REGION_CLIP_OUTSIDE, gl_viewport.x, DISPLAY_HEIGHT - gl_viewport.y - gl_viewport.h, gl_viewport.x + gl_viewport.w, gl_viewport.y + gl_viewport.h); -} - -void resetScissorTestRegion(void) { - // Setting scissor test region to default values - region.x = region.y = 0; - region.w = DISPLAY_WIDTH; - region.h = DISPLAY_HEIGHT; -} - -/* - * ------------------------------ - * - IMPLEMENTATION STARTS HERE - - * ------------------------------ - */ - -void glScissor(GLint x, GLint y, GLsizei width, GLsizei height) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if ((width < 0) || (height < 0)) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - - // Converting openGL scissor test region to sceGxm one - region.x = x; - region.y = DISPLAY_HEIGHT - y - height; - region.w = width; - region.h = height; - - // Updating in use scissor test parameters if GL_SCISSOR_TEST is enabled - if (scissor_test_state) - update_scissor_test(); -} - -void glDepthFunc(GLenum func) { - // Properly translating openGL function to sceGxm one - switch (func) { - case GL_NEVER: - gxm_depth = SCE_GXM_DEPTH_FUNC_NEVER; - break; - case GL_LESS: - gxm_depth = SCE_GXM_DEPTH_FUNC_LESS; - break; - case GL_EQUAL: - gxm_depth = SCE_GXM_DEPTH_FUNC_EQUAL; - break; - case GL_LEQUAL: - gxm_depth = SCE_GXM_DEPTH_FUNC_LESS_EQUAL; - break; - case GL_GREATER: - gxm_depth = SCE_GXM_DEPTH_FUNC_GREATER; - break; - case GL_NOTEQUAL: - gxm_depth = SCE_GXM_DEPTH_FUNC_NOT_EQUAL; - break; - case GL_GEQUAL: - gxm_depth = SCE_GXM_DEPTH_FUNC_GREATER_EQUAL; - break; - case GL_ALWAYS: - gxm_depth = SCE_GXM_DEPTH_FUNC_ALWAYS; - break; - } - - // Updating in use depth function - change_depth_func(); -} - -void glClearDepth(GLdouble depth) { - // Set current in use depth test depth value - depth_value = depth; -} - -void glDepthMask(GLboolean flag) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (phase == MODEL_CREATION) { - _vitagl_error = GL_INVALID_OPERATION; - return; - } -#endif - - // Set current in use depth mask and invoking a depth write mode update - depth_mask_state = flag; - change_depth_write((depth_mask_state && depth_test_state) ? SCE_GXM_DEPTH_WRITE_ENABLED : SCE_GXM_DEPTH_WRITE_DISABLED); -} - -void glAlphaFunc(GLenum func, GLfloat ref) { - // Updating in use alpha test parameters - alpha_func = func; - alpha_ref = ref; - update_alpha_test_settings(); -} - -void glStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) { - // Properly updating stencil operation settings - switch (face) { - case GL_FRONT: - if (!change_stencil_config(&stencil_fail_front, sfail)) - _vitagl_error = GL_INVALID_ENUM; - if (!change_stencil_config(&depth_fail_front, dpfail)) - _vitagl_error = GL_INVALID_ENUM; - if (!change_stencil_config(&depth_pass_front, dppass)) - _vitagl_error = GL_INVALID_ENUM; - break; - case GL_BACK: - if (!change_stencil_config(&stencil_fail_back, sfail)) - _vitagl_error = GL_INVALID_ENUM; - if (!change_stencil_config(&depth_fail_back, dpfail)) - _vitagl_error = GL_INVALID_ENUM; - if (!change_stencil_config(&depth_pass_front, dppass)) - _vitagl_error = GL_INVALID_ENUM; - break; - case GL_FRONT_AND_BACK: - if (!change_stencil_config(&stencil_fail_front, sfail)) - _vitagl_error = GL_INVALID_ENUM; - if (!change_stencil_config(&stencil_fail_back, sfail)) - _vitagl_error = GL_INVALID_ENUM; - if (!change_stencil_config(&depth_fail_front, dpfail)) - _vitagl_error = GL_INVALID_ENUM; - if (!change_stencil_config(&depth_fail_back, dpfail)) - _vitagl_error = GL_INVALID_ENUM; - if (!change_stencil_config(&depth_pass_front, dppass)) - _vitagl_error = GL_INVALID_ENUM; - if (!change_stencil_config(&depth_pass_back, dppass)) - _vitagl_error = GL_INVALID_ENUM; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - change_stencil_settings(); -} - -void glStencilOp(GLenum sfail, GLenum dpfail, GLenum dppass) { - glStencilOpSeparate(GL_FRONT_AND_BACK, sfail, dpfail, dppass); -} - -void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) { - // Properly updating stencil test function settings - switch (face) { - case GL_FRONT: - if (!change_stencil_func_config(&stencil_func_front, func)) - _vitagl_error = GL_INVALID_ENUM; - stencil_mask_front = mask; - stencil_ref_front = ref; - break; - case GL_BACK: - if (!change_stencil_func_config(&stencil_func_back, func)) - _vitagl_error = GL_INVALID_ENUM; - stencil_mask_back = mask; - stencil_ref_back = ref; - break; - case GL_FRONT_AND_BACK: - if (!change_stencil_func_config(&stencil_func_front, func)) - _vitagl_error = GL_INVALID_ENUM; - if (!change_stencil_func_config(&stencil_func_back, func)) - _vitagl_error = GL_INVALID_ENUM; - stencil_mask_front = stencil_mask_back = mask; - stencil_ref_front = stencil_ref_back = ref; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - change_stencil_settings(); -} - -void glStencilFunc(GLenum func, GLint ref, GLuint mask) { - glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); -} - -void glStencilMaskSeparate(GLenum face, GLuint mask) { - // Properly updating stencil test mask settings - switch (face) { - case GL_FRONT: - stencil_mask_front_write = mask; - break; - case GL_BACK: - stencil_mask_back_write = mask; - break; - case GL_FRONT_AND_BACK: - stencil_mask_front_write = stencil_mask_back_write = mask; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - return; - } - change_stencil_settings(); -} - -void glStencilMask(GLuint mask) { - glStencilMaskSeparate(GL_FRONT_AND_BACK, mask); -} - -void glClearStencil(GLint s) { - stencil_value = s; -} diff --git a/deps/vitaGL/source/texture_callbacks.c b/deps/vitaGL/source/texture_callbacks.c deleted file mode 100644 index c1bf72fdd4..0000000000 --- a/deps/vitaGL/source/texture_callbacks.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * texture_callbacks.c: - * Implementation for texture data reading/writing callbacks - */ - -#include -#include - -#include "texture_callbacks.h" - -// Read callback for 32bpp unsigned RGBA format -uint32_t readRGBA(void *data) { - uint32_t res; - memcpy(&res, data, 4); - return res; -} - -// Read callback for 16bpp unsigned RGBA5551 format -uint32_t readRGBA5551(void *data) { - uint16_t clr; - uint32_t r, g, b, a; - memcpy(&clr, data, 2); - r = (((clr >> 11) & 0x1F) * 0xFF) / 0x1F; - g = ((((clr << 5) >> 11) & 0x1F) * 0xFF) / 0x1F; - b = ((((clr << 10) >> 11) & 0x1F) * 0xFF) / 0x1F; - a = (((clr << 15) >> 15) & 0x1) == 1 ? 0xFF : 0x00; - return ((a << 24) | (b << 16) | (g << 8) | r); -} - -// Read callback for 24bpp unsigned RGB format -uint32_t readRGB(void *data) { - uint32_t res = 0xFFFFFFFF; - memcpy(&res, data, 3); - return res; -} - -// Read callback for 16bpp unsigned RG format -uint32_t readRG(void *data) { - uint32_t res = 0xFFFFFFFF; - memcpy(&res, data, 2); - return res; -} - -// Read callback for 8bpp unsigned R format -uint32_t readR(void *data) { - uint32_t res = 0xFFFFFFFF; - memcpy(&res, data, 1); - return res; -} - -// Write callback for 32bpp unsigned RGBA format -void writeRGBA(void *data, uint32_t color) { - memcpy(data, &color, 4); -} - -// Write callback for 24bpp unsigned RGB format -void writeRGB(void *data, uint32_t color) { - memcpy(data, &color, 3); -} - -// Write callback for 16bpp unsigned RG format -void writeRG(void *data, uint32_t color) { - memcpy(data, &color, 2); -} - -// Write callback for 16bpp unsigned RA format -void writeRA(void *data, uint32_t color) { - uint8_t *dst = (uint8_t *)data; - uint8_t *src = (uint8_t *)&color; - dst[0] = src[0]; - dst[1] = src[3]; -} - -// Write callback for 8bpp unsigned R format -void writeR(void *data, uint32_t color) { - memcpy(data, &color, 1); -} \ No newline at end of file diff --git a/deps/vitaGL/source/texture_callbacks.h b/deps/vitaGL/source/texture_callbacks.h deleted file mode 100644 index 634efe08cf..0000000000 --- a/deps/vitaGL/source/texture_callbacks.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * texture_callbacks.h: - * Header file for texture data reading/writing callbacks exposed by texture_callbacks.c - */ - -#ifndef _TEXTURE_CALLBACKS_H_ -#define _TEXTURE_CALLBACKS_H_ - -// Read callbacks -uint32_t readR(void *data); -uint32_t readRG(void *data); -uint32_t readRGB(void *data); -uint32_t readRGBA(void *data); -uint32_t readRGBA5551(void *data); - -// Write callbacks -void writeR(void *data, uint32_t color); -void writeRG(void *data, uint32_t color); -void writeRA(void *data, uint32_t color); -void writeRGB(void *data, uint32_t color); -void writeRGBA(void *data, uint32_t color); - -#endif diff --git a/deps/vitaGL/source/textures.c b/deps/vitaGL/source/textures.c deleted file mode 100644 index 4e9ce23f37..0000000000 --- a/deps/vitaGL/source/textures.c +++ /dev/null @@ -1,662 +0,0 @@ -/* - * textures.c: - * Implementation for textures related functions - */ - -#include "shared.h" - -texture_unit texture_units[GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS]; // Available texture units -palette *color_table = NULL; // Current in-use color table -int8_t server_texture_unit = 0; // Current in use server side texture unit - -/* - * ------------------------------ - * - IMPLEMENTATION STARTS HERE - - * ------------------------------ - */ - -void glGenTextures(GLsizei n, GLuint *res) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (n < 0) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - - // Aliasing to make code more readable - texture_unit *tex_unit = &texture_units[server_texture_unit]; - - // Reserving a texture and returning its id if available - int i, j = 0; - for (i = 0; i < TEXTURES_NUM; i++) { - if (!(tex_unit->textures[i].used)) { - res[j++] = i; - tex_unit->textures[i].used = 1; - } - if (j >= n) - break; - } -} - -void glBindTexture(GLenum target, GLuint texture) { - // Aliasing to make code more readable - texture_unit *tex_unit = &texture_units[server_texture_unit]; - - // Setting current in use texture id for the in use server texture unit - switch (target) { - case GL_TEXTURE_2D: - tex_unit->tex_id = texture; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} - -void glDeleteTextures(GLsizei n, const GLuint *gl_textures) { -#ifndef SKIP_ERROR_HANDLING - // Error handling - if (n < 0) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - - // Aliasing to make code more readable - texture_unit *tex_unit = &texture_units[server_texture_unit]; - - // Deallocating given textures and invalidating used texture ids - int j; - for (j = 0; j < n; j++) { - GLuint i = gl_textures[j]; - tex_unit->textures[i].used = 0; - gpu_free_texture(&tex_unit->textures[i]); - } -} - -void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *data) { - // Setting some aliases to make code more readable - texture_unit *tex_unit = &texture_units[server_texture_unit]; - int texture2d_idx = tex_unit->tex_id; - texture *tex = &tex_unit->textures[texture2d_idx]; - - SceGxmTextureFormat tex_format; - uint8_t data_bpp = 0; - - // Support for legacy GL1.0 internalFormat - switch (internalFormat) { - case 1: - internalFormat = GL_RED; - break; - case 2: - internalFormat = GL_RG; - break; - case 3: - internalFormat = GL_RGB; - break; - case 4: - internalFormat = GL_RGBA; - break; - } - - /* - * Callbacks are actually used to just perform down/up-sampling - * between U8 texture formats. Reads are expected to give as result - * a RGBA sample that will be wrote depending on texture format - * by the write callback - */ - void (*write_cb)(void *, uint32_t) = NULL; - uint32_t (*read_cb)(void *) = NULL; - - // Detecting proper read callaback and source bpp - switch (format) { - case GL_RED: - case GL_ALPHA: - switch (type) { - case GL_UNSIGNED_BYTE: - read_cb = readR; - data_bpp = 1; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - break; - case GL_RG: - case GL_LUMINANCE_ALPHA: - switch (type) { - case GL_UNSIGNED_BYTE: - read_cb = readRG; - data_bpp = 2; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - break; - case GL_RGB: - switch (type) { - case GL_UNSIGNED_BYTE: - data_bpp = 3; - read_cb = readRGB; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - break; - case GL_RGBA: - switch (type) { - case GL_UNSIGNED_BYTE: - data_bpp = 4; - read_cb = readRGBA; - break; - case GL_UNSIGNED_SHORT_5_5_5_1: - data_bpp = 2; - read_cb = readRGBA5551; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - break; - } - - switch (target) { - case GL_TEXTURE_2D: - - // Detecting proper write callback and texture format - switch (internalFormat) { - case GL_RGB: - write_cb = writeRGB; - tex_format = SCE_GXM_TEXTURE_FORMAT_U8U8U8_BGR; - break; - case GL_RGBA: - write_cb = writeRGBA; - tex_format = SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ABGR; - break; - case GL_LUMINANCE: - write_cb = writeR; - tex_format = SCE_GXM_TEXTURE_FORMAT_L8; - break; - case GL_LUMINANCE_ALPHA: - write_cb = writeRG; - tex_format = SCE_GXM_TEXTURE_FORMAT_A8L8; - break; - case GL_INTENSITY: - write_cb = writeR; - tex_format = SCE_GXM_TEXTURE_FORMAT_U8_RRRR; - break; - case GL_ALPHA: - write_cb = writeR; - tex_format = SCE_GXM_TEXTURE_FORMAT_A8; - break; - case GL_COLOR_INDEX8_EXT: - write_cb = writeR; // TODO: This is a hack - tex_format = SCE_GXM_TEXTURE_FORMAT_P8_ABGR; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - - // Checking if texture is too big for sceGxm - if (width > GXM_TEX_MAX_SIZE || height > GXM_TEX_MAX_SIZE) { - _vitagl_error = GL_INVALID_VALUE; - return; - } - - // Allocating texture/mipmaps depending on user call - tex->type = internalFormat; - tex->write_cb = write_cb; - if (level == 0) - gpu_alloc_texture(width, height, tex_format, data, tex, data_bpp, read_cb, write_cb); - else - gpu_alloc_mipmaps(level, tex); - - // Setting texture parameters - sceGxmTextureSetUAddrMode(&tex->gxm_tex, tex_unit->u_mode); - sceGxmTextureSetVAddrMode(&tex->gxm_tex, tex_unit->v_mode); - sceGxmTextureSetMinFilter(&tex->gxm_tex, tex_unit->min_filter); - sceGxmTextureSetMagFilter(&tex->gxm_tex, tex_unit->mag_filter); - - // Setting palette if the format requests one - if (tex->valid && tex->palette_UID) - sceGxmTextureSetPalette(&tex->gxm_tex, color_table->data); - - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} - -void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) { - // Setting some aliases to make code more readable - texture_unit *tex_unit = &texture_units[server_texture_unit]; - int texture2d_idx = tex_unit->tex_id; - texture *target_texture = &tex_unit->textures[texture2d_idx]; - - // Calculating implicit texture stride and start address of requested texture modification - SceGxmTextureFormat tex_format = sceGxmTextureGetFormat(&target_texture->gxm_tex); - uint8_t bpp = tex_format_to_bytespp(tex_format); - uint32_t stride = ALIGN(sceGxmTextureGetWidth(&target_texture->gxm_tex), 8) * bpp; - uint8_t *ptr = (uint8_t *)sceGxmTextureGetData(&target_texture->gxm_tex) + xoffset * bpp + yoffset * stride; - uint8_t *ptr_line = ptr; - uint8_t data_bpp = 0; - int i, j; - - /* - * Callbacks are actually used to just perform down/up-sampling - * between U8 texture formats. Reads are expected to give as result - * a RGBA sample that will be wrote depending on texture format - * by the write callback - */ - void (*write_cb)(void *, uint32_t) = NULL; - uint32_t (*read_cb)(void *) = NULL; - - // Detecting proper read callback and source bpp - switch (format) { - case GL_RED: - case GL_ALPHA: - switch (type) { - case GL_UNSIGNED_BYTE: - read_cb = readR; - data_bpp = 1; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - break; - case GL_RG: - switch (type) { - case GL_UNSIGNED_BYTE: - read_cb = readRG; - data_bpp = 2; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - break; - case GL_RGB: - switch (type) { - case GL_UNSIGNED_BYTE: - data_bpp = 3; - read_cb = readRGB; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - break; - case GL_RGBA: - switch (type) { - case GL_UNSIGNED_BYTE: - data_bpp = 4; - read_cb = readRGBA; - break; - case GL_UNSIGNED_SHORT_5_5_5_1: - data_bpp = 2; - read_cb = readRGBA5551; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - break; - } - - switch (target) { - case GL_TEXTURE_2D: - - // Detecting proper write callback - switch (target_texture->type) { - case GL_RGB: - write_cb = writeRGB; - break; - case GL_RGBA: - write_cb = writeRGBA; - break; - case GL_LUMINANCE: - write_cb = writeR; - break; - case GL_LUMINANCE_ALPHA: - write_cb = writeRA; - break; - case GL_INTENSITY: - write_cb = writeR; - break; - case GL_ALPHA: - write_cb = writeR; - break; - } - - // Executing texture modification via callbacks - uint8_t *data = (uint8_t *)pixels; - for (i = 0; i < height; i++) { - for (j = 0; j < width; j++) { - uint32_t clr = read_cb((uint8_t *)data); - write_cb(ptr, clr); - data += data_bpp; - ptr += bpp; - } - ptr = ptr_line + stride; - ptr_line = ptr; - } - - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} - -void glColorTable(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *data) { - // Checking if a color table is already enabled, if so, deallocating it - if (color_table != NULL) { - gpu_free_palette(color_table); - color_table = NULL; - } - - // Calculating color table bpp - uint8_t bpp = 0; - switch (target) { - case GL_COLOR_TABLE: - switch (format) { - case GL_RGBA: - bpp = 4; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - - // Allocating and initializing color table - color_table = gpu_alloc_palette(data, width, bpp); -} - -void glTexParameteri(GLenum target, GLenum pname, GLint param) { - // Setting some aliases to make code more readable - texture_unit *tex_unit = &texture_units[server_texture_unit]; - int texture2d_idx = tex_unit->tex_id; - texture *tex = &tex_unit->textures[texture2d_idx]; - - switch (target) { - case GL_TEXTURE_2D: - switch (pname) { - case GL_TEXTURE_MIN_FILTER: // Min filter - switch (param) { - case GL_NEAREST: // Point - tex_unit->min_filter = SCE_GXM_TEXTURE_FILTER_POINT; - break; - case GL_LINEAR: // Linear - tex_unit->min_filter = SCE_GXM_TEXTURE_FILTER_LINEAR; - break; - case GL_NEAREST_MIPMAP_NEAREST: // TODO: Implement this - break; - case GL_LINEAR_MIPMAP_NEAREST: // TODO: Implement this - break; - case GL_NEAREST_MIPMAP_LINEAR: // TODO: Implement this - break; - case GL_LINEAR_MIPMAP_LINEAR: // TODO: Implement this - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - sceGxmTextureSetMinFilter(&tex->gxm_tex, tex_unit->min_filter); - break; - case GL_TEXTURE_MAG_FILTER: // Mag Filter - switch (param) { - case GL_NEAREST: // Point - tex_unit->mag_filter = SCE_GXM_TEXTURE_FILTER_POINT; - break; - case GL_LINEAR: // Linear - tex_unit->mag_filter = SCE_GXM_TEXTURE_FILTER_LINEAR; - break; - case GL_NEAREST_MIPMAP_NEAREST: // TODO: Implement this - break; - case GL_LINEAR_MIPMAP_NEAREST: // TODO: Implement this - break; - case GL_NEAREST_MIPMAP_LINEAR: // TODO: Implement this - break; - case GL_LINEAR_MIPMAP_LINEAR: // TODO: Implement this - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - sceGxmTextureSetMagFilter(&tex->gxm_tex, tex_unit->mag_filter); - break; - case GL_TEXTURE_WRAP_S: // U Mode - switch (param) { - case GL_CLAMP_TO_EDGE: // Clamp - tex_unit->u_mode = SCE_GXM_TEXTURE_ADDR_CLAMP; - break; - case GL_REPEAT: // Repeat - tex_unit->u_mode = SCE_GXM_TEXTURE_ADDR_REPEAT; - break; - case GL_MIRRORED_REPEAT: // Mirror - tex_unit->u_mode = SCE_GXM_TEXTURE_ADDR_MIRROR; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - sceGxmTextureSetUAddrMode(&tex->gxm_tex, tex_unit->u_mode); - break; - case GL_TEXTURE_WRAP_T: // V Mode - switch (param) { - case GL_CLAMP_TO_EDGE: // Clamp - tex_unit->v_mode = SCE_GXM_TEXTURE_ADDR_CLAMP; - break; - case GL_REPEAT: // Repeat - tex_unit->v_mode = SCE_GXM_TEXTURE_ADDR_REPEAT; - break; - case GL_MIRRORED_REPEAT: // Mirror - tex_unit->v_mode = SCE_GXM_TEXTURE_ADDR_MIRROR; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - sceGxmTextureSetVAddrMode(&tex->gxm_tex, tex_unit->v_mode); - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} - -void glTexParameterf(GLenum target, GLenum pname, GLfloat param) { - // Setting some aliases to make code more readable - texture_unit *tex_unit = &texture_units[server_texture_unit]; - int texture2d_idx = tex_unit->tex_id; - texture *tex = &tex_unit->textures[texture2d_idx]; - - switch (target) { - case GL_TEXTURE_2D: - switch (pname) { - case GL_TEXTURE_MIN_FILTER: // Min Filter - if (param == GL_NEAREST) - tex_unit->min_filter = SCE_GXM_TEXTURE_FILTER_POINT; // Point - if (param == GL_LINEAR) - tex_unit->min_filter = SCE_GXM_TEXTURE_FILTER_LINEAR; // Linear - sceGxmTextureSetMinFilter(&tex->gxm_tex, tex_unit->min_filter); - break; - case GL_TEXTURE_MAG_FILTER: // Mag filter - if (param == GL_NEAREST) - tex_unit->mag_filter = SCE_GXM_TEXTURE_FILTER_POINT; // Point - else if (param == GL_LINEAR) - tex_unit->mag_filter = SCE_GXM_TEXTURE_FILTER_LINEAR; // Linear - sceGxmTextureSetMagFilter(&tex->gxm_tex, tex_unit->mag_filter); - break; - case GL_TEXTURE_WRAP_S: // U Mode - if (param == GL_CLAMP_TO_EDGE) - tex_unit->u_mode = SCE_GXM_TEXTURE_ADDR_CLAMP; // Clamp - else if (param == GL_REPEAT) - tex_unit->u_mode = SCE_GXM_TEXTURE_ADDR_REPEAT; // Repeat - else if (param == GL_MIRRORED_REPEAT) - tex_unit->u_mode = SCE_GXM_TEXTURE_ADDR_MIRROR; // Mirror - sceGxmTextureSetUAddrMode(&tex->gxm_tex, tex_unit->u_mode); - break; - case GL_TEXTURE_WRAP_T: // V Mode - if (param == GL_CLAMP_TO_EDGE) - tex_unit->v_mode = SCE_GXM_TEXTURE_ADDR_CLAMP; // Clamp - else if (param == GL_REPEAT) - tex_unit->v_mode = SCE_GXM_TEXTURE_ADDR_REPEAT; // Repeat - else if (param == GL_MIRRORED_REPEAT) - tex_unit->v_mode = SCE_GXM_TEXTURE_ADDR_MIRROR; // Mirror - sceGxmTextureSetVAddrMode(&tex->gxm_tex, tex_unit->v_mode); - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} - -void glActiveTexture(GLenum texture) { - // Changing current in use server texture unit -#ifndef SKIP_ERROR_HANDLING - if ((texture < GL_TEXTURE0) && (texture > GL_TEXTURE31)) - _vitagl_error = GL_INVALID_ENUM; - else -#endif - server_texture_unit = texture - GL_TEXTURE0; -} - -void glGenerateMipmap(GLenum target) { - // Setting some aliases to make code more readable - texture_unit *tex_unit = &texture_units[server_texture_unit]; - int texture2d_idx = tex_unit->tex_id; - texture *tex = &tex_unit->textures[texture2d_idx]; - -#ifndef SKIP_ERROR_HANDLING - // Checking if current texture is valid - if (!tex->valid) - return; -#endif - - switch (target) { - case GL_TEXTURE_2D: - - // Generating mipmaps to the max possible level - gpu_alloc_mipmaps(-1, tex); - - // Setting texture parameters - sceGxmTextureSetUAddrMode(&tex->gxm_tex, tex_unit->u_mode); - sceGxmTextureSetVAddrMode(&tex->gxm_tex, tex_unit->v_mode); - sceGxmTextureSetMinFilter(&tex->gxm_tex, tex_unit->min_filter); - sceGxmTextureSetMagFilter(&tex->gxm_tex, tex_unit->mag_filter); - sceGxmTextureSetMipFilter(&tex->gxm_tex, SCE_GXM_TEXTURE_MIP_FILTER_ENABLED); - - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} - -void glTexEnvf(GLenum target, GLenum pname, GLfloat param) { - // Aliasing texture unit for cleaner code - texture_unit *tex_unit = &texture_units[server_texture_unit]; - - // Properly changing texture environment settings as per request - switch (target) { - case GL_TEXTURE_ENV: - switch (pname) { - case GL_TEXTURE_ENV_MODE: - if (param == GL_MODULATE) - tex_unit->env_mode = MODULATE; - else if (param == GL_DECAL) - tex_unit->env_mode = DECAL; - else if (param == GL_REPLACE) - tex_unit->env_mode = REPLACE; - else if (param == GL_BLEND) - tex_unit->env_mode = BLEND; - else if (param == GL_ADD) - tex_unit->env_mode = ADD; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - break; - default: - _vitagl_error = GL_INVALID_ENUM; - } -} - -void glTexEnvi(GLenum target, GLenum pname, GLint param) { - // Aliasing texture unit for cleaner code - texture_unit *tex_unit = &texture_units[server_texture_unit]; - - // Properly changing texture environment settings as per request - switch (target) { - case GL_TEXTURE_ENV: - switch (pname) { - case GL_TEXTURE_ENV_MODE: - switch (param) { - case GL_MODULATE: - tex_unit->env_mode = MODULATE; - break; - case GL_DECAL: - tex_unit->env_mode = DECAL; - break; - case GL_REPLACE: - tex_unit->env_mode = REPLACE; - break; - case GL_BLEND: - tex_unit->env_mode = BLEND; - break; - case GL_ADD: - tex_unit->env_mode = ADD; - break; - } - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} - -void *vglGetTexDataPointer(GLenum target) { - // Aliasing texture unit for cleaner code - texture_unit *tex_unit = &texture_units[server_texture_unit]; - int texture2d_idx = tex_unit->tex_id; - texture *tex = &tex_unit->textures[texture2d_idx]; - - switch (target) { - case GL_TEXTURE_2D: - return tex->data; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - - return NULL; -} diff --git a/deps/vitaGL/source/utils/gpu_utils.c b/deps/vitaGL/source/utils/gpu_utils.c deleted file mode 100644 index 383a3c68f2..0000000000 --- a/deps/vitaGL/source/utils/gpu_utils.c +++ /dev/null @@ -1,330 +0,0 @@ -/* - * gpu_utils.c: - * Utilities for GPU usage - */ - -#include "../shared.h" - -// VRAM usage setting -uint8_t use_vram = 0; - -// vitaGL memory pool setup -static void *pool_addr = NULL; -static unsigned int pool_index = 0; -static unsigned int pool_size = 0; - -void *gpu_alloc_mapped(size_t size, vglMemType *type) { - // Allocating requested memblock - void *res = vitagl_mempool_alloc(size, *type); - - // Requested memory type finished, using other one - if (res == NULL) { - *type = use_vram ? VGL_MEM_RAM : VGL_MEM_VRAM; - res = vitagl_mempool_alloc(size, *type); - } - - // Even the other one failed, using our last resort - if (res == NULL) { - *type = VGL_MEM_SLOW; - res = vitagl_mempool_alloc(size, *type); - } - - if (res == NULL) { - *type = VGL_MEM_EXTERNAL; - res = malloc(size); - } - - return res; -} - -void *gpu_vertex_usse_alloc_mapped(size_t size, unsigned int *usse_offset) { - // Allocating memblock - void *addr = vitagl_mempool_alloc(size, VGL_MEM_RAM); - - // Mapping memblock into sceGxm as vertex USSE memory - sceGxmMapVertexUsseMemory(addr, size, usse_offset); - - // Returning memblock starting address - return addr; -} - -void gpu_vertex_usse_free_mapped(void *addr) { - // Unmapping memblock from sceGxm as vertex USSE memory - sceGxmUnmapVertexUsseMemory(addr); - - // Deallocating memblock - vitagl_mempool_free(addr, VGL_MEM_RAM); -} - -void *gpu_fragment_usse_alloc_mapped(size_t size, unsigned int *usse_offset) { - // Allocating memblock - void *addr = vitagl_mempool_alloc(size, VGL_MEM_RAM); - - // Mapping memblock into sceGxm as fragment USSE memory - sceGxmMapFragmentUsseMemory(addr, size, usse_offset); - - // Returning memblock starting address - return addr; -} - -void gpu_fragment_usse_free_mapped(void *addr) { - // Unmapping memblock from sceGxm as fragment USSE memory - sceGxmUnmapFragmentUsseMemory(addr); - - // Deallocating memblock - vitagl_mempool_free(addr, VGL_MEM_RAM); -} - -void *gpu_pool_malloc(unsigned int size) { - // Reserving vitaGL mempool space - if ((pool_index + size) < pool_size) { - void *addr = (void *)((unsigned int)pool_addr + pool_index); - pool_index += size; - return addr; - } - - return NULL; -} - -void *gpu_pool_memalign(unsigned int size, unsigned int alignment) { - // Aligning requested memory size - unsigned int new_index = ALIGN(pool_index, alignment); - - // Reserving vitaGL mempool space - if ((new_index + size) < pool_size) { - void *addr = (void *)((unsigned int)pool_addr + new_index); - pool_index = new_index + size; - return addr; - } - return NULL; -} - -unsigned int gpu_pool_free_space() { - // Returning vitaGL available mempool space - return pool_size - pool_index; -} - -void gpu_pool_reset() { - // Resetting vitaGL available mempool space - pool_index = 0; -} - -void gpu_pool_init(uint32_t temp_pool_size) { - // Allocating vitaGL mempool - pool_size = temp_pool_size; - vglMemType type = VGL_MEM_RAM; - pool_addr = gpu_alloc_mapped(temp_pool_size, &type); -} - -int tex_format_to_bytespp(SceGxmTextureFormat format) { - // Calculating bpp for the requested texture format - switch (format & 0x9f000000U) { - case SCE_GXM_TEXTURE_BASE_FORMAT_U8: - case SCE_GXM_TEXTURE_BASE_FORMAT_S8: - case SCE_GXM_TEXTURE_BASE_FORMAT_P8: - return 1; - case SCE_GXM_TEXTURE_BASE_FORMAT_U4U4U4U4: - case SCE_GXM_TEXTURE_BASE_FORMAT_U8U3U3U2: - case SCE_GXM_TEXTURE_BASE_FORMAT_U1U5U5U5: - case SCE_GXM_TEXTURE_BASE_FORMAT_U5U6U5: - case SCE_GXM_TEXTURE_BASE_FORMAT_S5S5U6: - case SCE_GXM_TEXTURE_BASE_FORMAT_U8U8: - case SCE_GXM_TEXTURE_BASE_FORMAT_S8S8: - return 2; - case SCE_GXM_TEXTURE_BASE_FORMAT_U8U8U8: - case SCE_GXM_TEXTURE_BASE_FORMAT_S8S8S8: - return 3; - case SCE_GXM_TEXTURE_BASE_FORMAT_U8U8U8U8: - case SCE_GXM_TEXTURE_BASE_FORMAT_S8S8S8S8: - case SCE_GXM_TEXTURE_BASE_FORMAT_F32: - case SCE_GXM_TEXTURE_BASE_FORMAT_U32: - case SCE_GXM_TEXTURE_BASE_FORMAT_S32: - default: - return 4; - } -} - -palette *gpu_alloc_palette(const void *data, uint32_t w, uint32_t bpe) { - // Allocating a palette object - palette *res = (palette *)malloc(sizeof(palette)); - res->type = use_vram ? VGL_MEM_VRAM : VGL_MEM_RAM; - - // Allocating palette data buffer - void *texture_palette = gpu_alloc_mapped(256 * sizeof(uint32_t), &res->type); - - // Initializing palette - if (data == NULL) - memset(texture_palette, 0, 256 * sizeof(uint32_t)); - else if (bpe == 4) - memcpy(texture_palette, data, w * sizeof(uint32_t)); - res->data = texture_palette; - - // Returning palette - return res; -} - -void gpu_free_texture(texture *tex) { - // Deallocating texture - if (tex->data != NULL) - vitagl_mempool_free(tex->data, tex->mtype); - - // Invalidating texture object - tex->valid = 0; -} - -void gpu_alloc_texture(uint32_t w, uint32_t h, SceGxmTextureFormat format, const void *data, texture *tex, uint8_t src_bpp, uint32_t (*read_cb)(void *), void (*write_cb)(void *, uint32_t)) { - // If there's already a texture in passed texture object we first dealloc it - if (tex->valid) - gpu_free_texture(tex); - - // Getting texture format bpp - uint8_t bpp = tex_format_to_bytespp(format); - - // Allocating texture data buffer - tex->mtype = use_vram ? VGL_MEM_VRAM : VGL_MEM_RAM; - const int tex_size = ALIGN(w, 8) * h * bpp; - void *texture_data = gpu_alloc_mapped(tex_size, &tex->mtype); - - if (texture_data != NULL) { - // Initializing texture data buffer - if (data != NULL) { - int i, j; - uint8_t *src = (uint8_t *)data; - uint8_t *dst; - for (i = 0; i < h; i++) { - dst = ((uint8_t *)texture_data) + (ALIGN(w, 8) * bpp) * i; - for (j = 0; j < w; j++) { - uint32_t clr = read_cb(src); - write_cb(dst, clr); - src += src_bpp; - dst += bpp; - } - } - } else - memset(texture_data, 0, tex_size); - - // Initializing texture and validating it - sceGxmTextureInitLinear(&tex->gxm_tex, texture_data, format, w, h, 0); - if ((format & 0x9f000000U) == SCE_GXM_TEXTURE_BASE_FORMAT_P8) - tex->palette_UID = 1; - else - tex->palette_UID = 0; - tex->valid = 1; - tex->data = texture_data; - } -} - -void gpu_alloc_mipmaps(int level, texture *tex) { - // Getting current mipmap count in passed texture - uint32_t count = sceGxmTextureGetMipmapCount(&tex->gxm_tex); - - // Getting textures info and calculating bpp - uint32_t w, h, stride; - uint32_t orig_w = sceGxmTextureGetWidth(&tex->gxm_tex); - uint32_t orig_h = sceGxmTextureGetHeight(&tex->gxm_tex); - SceGxmTextureFormat format = sceGxmTextureGetFormat(&tex->gxm_tex); - uint32_t bpp = tex_format_to_bytespp(format); - - // Checking if we need at least one more new mipmap level - if ((level > count) || (level < 0)) { // Note: level < 0 means we will use max possible mipmaps level - - uint32_t jumps[10]; - for (w = 1; w < orig_w; w <<= 1) { - } - for (h = 1; h < orig_h; h <<= 1) { - } - - // Calculating new texture data buffer size - uint32_t size = 0; - int j; - if (level > 0) { - for (j = 0; j < level; j++) { - jumps[j] = max(w, 8) * h * bpp; - size += jumps[j]; - w /= 2; - h /= 2; - } - } else { - level = 0; - while ((w > 1) && (h > 1)) { - jumps[level] = max(w, 8) * h * bpp; - size += jumps[level]; - w /= 2; - h /= 2; - level++; - } - } - - // Calculating needed sceGxmTransfer format for the downscale process - SceGxmTransferFormat fmt; - switch (tex->type) { - case GL_RGBA: - fmt = SCE_GXM_TRANSFER_FORMAT_U8U8U8U8_ABGR; - break; - case GL_RGB: - fmt = SCE_GXM_TRANSFER_FORMAT_U8U8U8_BGR; - default: - break; - } - - // Moving texture data to heap and deallocating texture memblock - GLboolean has_temp_buffer = GL_TRUE; - stride = ALIGN(orig_w, 8); - void *temp = (void *)malloc(stride * orig_h * bpp); - if (temp == NULL) { // If we finished newlib heap, we delay texture free - has_temp_buffer = GL_FALSE; - temp = sceGxmTextureGetData(&tex->gxm_tex); - } else { - memcpy(temp, sceGxmTextureGetData(&tex->gxm_tex), stride * orig_h * bpp); - gpu_free_texture(tex); - } - - // Allocating the new texture data buffer - tex->mtype = use_vram ? VGL_MEM_VRAM : VGL_MEM_RAM; - void *texture_data = gpu_alloc_mapped(size, &tex->mtype); - - // Moving back old texture data from heap to texture memblock - memcpy(texture_data, temp, stride * orig_h * bpp); - if (has_temp_buffer) - free(temp); - else - gpu_free_texture(tex); - tex->valid = 1; - - // Performing a chain downscale process to generate requested mipmaps - uint8_t *curPtr = (uint8_t *)texture_data; - uint32_t curWidth = orig_w; - uint32_t curHeight = orig_h; - if (curWidth % 2) - curWidth--; - if (curHeight % 2) - curHeight--; - for (j = 0; j < level - 1; j++) { - uint32_t curSrcStride = ALIGN(curWidth, 8); - uint32_t curDstStride = ALIGN(curWidth >> 1, 8); - uint8_t *dstPtr = curPtr + jumps[j]; - sceGxmTransferDownscale( - fmt, curPtr, 0, 0, - curWidth, curHeight, - curSrcStride * bpp, - fmt, dstPtr, 0, 0, - curDstStride * bpp, - NULL, SCE_GXM_TRANSFER_FRAGMENT_SYNC, NULL); - curPtr = dstPtr; - curWidth /= 2; - curHeight /= 2; - } - - // Initializing texture in sceGxm - sceGxmTextureInitLinear(&tex->gxm_tex, texture_data, format, orig_w, orig_h, level); - tex->data = texture_data; - } -} - -void gpu_free_palette(palette *pal) { - // Deallocating palette memblock and object - if (pal == NULL) - return; - vitagl_mempool_free(pal->data, pal->type); - free(pal); -} \ No newline at end of file diff --git a/deps/vitaGL/source/utils/gpu_utils.h b/deps/vitaGL/source/utils/gpu_utils.h deleted file mode 100644 index d17524e002..0000000000 --- a/deps/vitaGL/source/utils/gpu_utils.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * gpu_utils.h: - * Header file for the GPU utilities exposed by gpu_utils.c - */ - -#ifndef _GPU_UTILS_H_ -#define _GPU_UTILS_H_ - -#include "mem_utils.h" - -// Align a value to the requested alignment -#define ALIGN(x, a) (((x) + ((a)-1)) & ~((a)-1)) - -// Texture object struct -typedef struct texture { - SceGxmTexture gxm_tex; - void *data; - vglMemType mtype; - SceUID palette_UID; - SceUID depth_UID; - uint8_t used; - uint8_t valid; - uint32_t type; - void (*write_cb)(void *, uint32_t); -} texture; - -// Palette object struct -typedef struct palette { - void *data; - vglMemType type; -} palette; - -// Alloc a generic memblock into sceGxm mapped memory -void *gpu_alloc_mapped(size_t size, vglMemType *type); - -// Alloc into sceGxm mapped memory a vertex USSE memblock -void *gpu_vertex_usse_alloc_mapped(size_t size, unsigned int *usse_offset); - -// Dealloc from sceGxm mapped memory a vertex USSE memblock -void gpu_vertex_usse_free_mapped(void *addr); - -// Alloc into sceGxm mapped memory a fragment USSE memblock -void *gpu_fragment_usse_alloc_mapped(size_t size, unsigned int *usse_offset); - -// Dealloc from sceGxm mapped memory a fragment USSE memblock -void gpu_fragment_usse_free_mapped(void *addr); - -// Reserve a memory space from vitaGL mempool -void *gpu_pool_malloc(unsigned int size); - -// Reserve an aligned memory space from vitaGL mempool -void *gpu_pool_memalign(unsigned int size, unsigned int alignment); - -// Returns available free space on vitaGL mempool -unsigned int gpu_pool_free_space(); - -// Resets vitaGL mempool -void gpu_pool_reset(); - -// Alloc vitaGL mempool -void gpu_pool_init(uint32_t temp_pool_size); - -// Calculate bpp for a requested texture format -int tex_format_to_bytespp(SceGxmTextureFormat format); - -// Alloc a texture -void gpu_alloc_texture(uint32_t w, uint32_t h, SceGxmTextureFormat format, const void *data, texture *tex, uint8_t src_bpp, uint32_t (*read_cb)(void *), void (*write_cb)(void *, uint32_t)); - -// Dealloc a texture -void gpu_free_texture(texture *tex); - -// Alloc a palette -palette *gpu_alloc_palette(const void *data, uint32_t w, uint32_t bpe); - -// Dealloc a palette -void gpu_free_palette(palette *pal); - -// Generate mipmaps for a given texture -void gpu_alloc_mipmaps(int level, texture *tex); - -#endif diff --git a/deps/vitaGL/source/utils/math_utils.c b/deps/vitaGL/source/utils/math_utils.c deleted file mode 100644 index 6592f01c68..0000000000 --- a/deps/vitaGL/source/utils/math_utils.c +++ /dev/null @@ -1,222 +0,0 @@ -/* - * math_utils.c: - * Utilities for math operations - */ - -#include "../shared.h" -#include -#include - -// NOTE: matrices are row-major. - -void matrix4x4_identity(matrix4x4 m) { - m[0][1] = m[0][2] = m[0][3] = 0.0f; - m[1][0] = m[1][2] = m[1][3] = 0.0f; - m[2][0] = m[2][1] = m[2][3] = 0.0f; - m[3][0] = m[3][1] = m[3][2] = 0.0f; - m[0][0] = m[1][1] = m[2][2] = m[3][3] = 1.0f; -} - -void matrix4x4_copy(matrix4x4 dst, const matrix4x4 src) { - memcpy(dst, src, sizeof(matrix4x4)); -} - -void matrix4x4_multiply(matrix4x4 dst, const matrix4x4 src1, const matrix4x4 src2) { - matmul4_neon((float*)src2, (float*)src1, (float*)dst); -} - -void matrix4x4_init_rotation_x(matrix4x4 m, float rad) { - float cs[2]; - sincosf_c(rad, cs); - - matrix4x4_identity(m); - - m[1][1] = cs[1]; - m[1][2] = -cs[0]; - m[2][1] = cs[0]; - m[2][2] = cs[1]; -} - -void matrix4x4_init_rotation_y(matrix4x4 m, float rad) { - float cs[2]; - sincosf_c(rad, cs); - - matrix4x4_identity(m); - - m[0][0] = cs[1]; - m[0][2] = cs[0]; - m[2][0] = -cs[0]; - m[2][2] = cs[1]; -} - -void matrix4x4_init_rotation_z(matrix4x4 m, float rad) { - float cs[2]; - sincosf_c(rad, cs); - - matrix4x4_identity(m); - - m[0][0] = cs[1]; - m[0][1] = -cs[0]; - m[1][0] = cs[0]; - m[1][1] = cs[1]; -} - -void matrix4x4_rotate_x(matrix4x4 m, float rad) { - matrix4x4 m1, m2; - - matrix4x4_init_rotation_x(m1, rad); - matrix4x4_multiply(m2, m, m1); - matrix4x4_copy(m, m2); -} - -void matrix4x4_rotate_y(matrix4x4 m, float rad) { - matrix4x4 m1, m2; - - matrix4x4_init_rotation_y(m1, rad); - matrix4x4_multiply(m2, m, m1); - matrix4x4_copy(m, m2); -} - -void matrix4x4_rotate_z(matrix4x4 m, float rad) { - matrix4x4 m1, m2; - - matrix4x4_init_rotation_z(m1, rad); - matrix4x4_multiply(m2, m, m1); - matrix4x4_copy(m, m2); -} - -void matrix4x4_init_translation(matrix4x4 m, float x, float y, float z) { - matrix4x4_identity(m); - - m[0][3] = x; - m[1][3] = y; - m[2][3] = z; -} - -void matrix4x4_translate(matrix4x4 m, float x, float y, float z) { - matrix4x4 m1, m2; - - matrix4x4_init_translation(m1, x, y, z); - matrix4x4_multiply(m2, m, m1); - matrix4x4_copy(m, m2); -} - -void matrix4x4_init_scaling(matrix4x4 m, float scale_x, float scale_y, float scale_z) { - matrix4x4_identity(m); - - m[0][0] = scale_x; - m[1][1] = scale_y; - m[2][2] = scale_z; -} - -void matrix4x4_scale(matrix4x4 m, float scale_x, float scale_y, float scale_z) { - matrix4x4 m1, m2; - - matrix4x4_init_scaling(m1, scale_x, scale_y, scale_z); - matrix4x4_multiply(m2, m, m1); - matrix4x4_copy(m, m2); -} - -void matrix4x4_transpose(matrix4x4 out, const matrix4x4 m) { - int i, j; - - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) - out[i][j] = m[j][i]; - } -} - -void matrix4x4_init_orthographic(matrix4x4 m, float left, float right, float bottom, float top, float near, float far) { - m[0][0] = 2.0f / (right - left); - m[0][1] = 0.0f; - m[0][2] = 0.0f; - m[0][3] = -(right + left) / (right - left); - - m[1][0] = 0.0f; - m[1][1] = 2.0f / (top - bottom); - m[1][2] = 0.0f; - m[1][3] = -(top + bottom) / (top - bottom); - - m[2][0] = 0.0f; - m[2][1] = 0.0f; - m[2][2] = -2.0f / (far - near); - m[2][3] = -(far + near) / (far - near); - - m[3][0] = 0.0f; - m[3][1] = 0.0f; - m[3][2] = 0.0f; - m[3][3] = 1.0f; -} - -void matrix4x4_init_frustum(matrix4x4 m, float left, float right, float bottom, float top, float near, float far) { - m[0][0] = (2.0f * near) / (right - left); - m[0][1] = 0.0f; - m[0][2] = (right + left) / (right - left); - m[0][3] = 0.0f; - - m[1][0] = 0.0f; - m[1][1] = (2.0f * near) / (top - bottom); - m[1][2] = (top + bottom) / (top - bottom); - m[1][3] = 0.0f; - - m[2][0] = 0.0f; - m[2][1] = 0.0f; - m[2][2] = -(far + near) / (far - near); - m[2][3] = (-2.0f * far * near) / (far - near); - - m[3][0] = 0.0f; - m[3][1] = 0.0f; - m[3][2] = -1.0f; - m[3][3] = 0.0f; -} - -void matrix4x4_init_perspective(matrix4x4 m, float fov, float aspect, float near, float far) { - float half_height = near * tanf_neon(DEG_TO_RAD(fov) * 0.5f); - float half_width = half_height * aspect; - - matrix4x4_init_frustum(m, -half_width, half_width, -half_height, half_height, near, far); -} - -int matrix4x4_invert(matrix4x4 out, const matrix4x4 m) { - int i, j; - float det; - matrix4x4 inv; - - inv[0][0] = m[1][1] * m[2][2] * m[3][3] - m[1][1] * m[3][2] * m[2][3] - m[1][2] * m[2][1] * m[3][3] + m[1][2] * m[3][1] * m[2][3] + m[1][3] * m[2][1] * m[3][2] - m[1][3] * m[3][1] * m[2][2]; - inv[0][1] = -m[0][1] * m[2][2] * m[3][3] + m[0][1] * m[3][2] * m[2][3] + m[0][2] * m[2][1] * m[3][3] - m[0][2] * m[3][1] * m[2][3] - m[0][3] * m[2][1] * m[3][2] + m[0][3] * m[3][1] * m[2][2]; - inv[0][2] = m[0][1] * m[1][2] * m[3][3] - m[0][1] * m[3][2] * m[1][3] - m[0][2] * m[1][1] * m[3][3] + m[0][2] * m[3][1] * m[1][3] + m[0][3] * m[1][1] * m[3][2] - m[0][3] * m[3][1] * m[1][2]; - inv[0][3] = -m[0][1] * m[1][2] * m[2][3] + m[0][1] * m[2][2] * m[1][3] + m[0][2] * m[1][1] * m[2][3] - m[0][2] * m[2][1] * m[1][3] - m[0][3] * m[1][1] * m[2][2] + m[0][3] * m[2][1] * m[1][2]; - inv[1][0] = -m[1][0] * m[2][2] * m[3][3] + m[1][0] * m[3][2] * m[2][3] + m[1][2] * m[2][0] * m[3][3] - m[1][2] * m[3][0] * m[2][3] - m[1][3] * m[2][0] * m[3][2] + m[1][3] * m[3][0] * m[2][2]; - inv[1][1] = m[0][0] * m[2][2] * m[3][3] - m[0][0] * m[3][2] * m[2][3] - m[0][2] * m[2][0] * m[3][3] + m[0][2] * m[3][0] * m[2][3] + m[0][3] * m[2][0] * m[3][2] - m[0][3] * m[3][0] * m[2][2]; - inv[1][2] = -m[0][0] * m[1][2] * m[3][3] + m[0][0] * m[3][2] * m[1][3] + m[0][2] * m[1][0] * m[3][3] - m[0][2] * m[3][0] * m[1][3] - m[0][3] * m[1][0] * m[3][2] + m[0][3] * m[3][0] * m[1][2]; - inv[1][3] = m[0][0] * m[1][2] * m[2][3] - m[0][0] * m[2][2] * m[1][3] - m[0][2] * m[1][0] * m[2][3] + m[0][2] * m[2][0] * m[1][3] + m[0][3] * m[1][0] * m[2][2] - m[0][3] * m[2][0] * m[1][2]; - inv[2][0] = m[1][0] * m[2][1] * m[3][3] - m[1][0] * m[3][1] * m[2][3] - m[1][1] * m[2][0] * m[3][3] + m[1][1] * m[3][0] * m[2][3] + m[1][3] * m[2][0] * m[3][1] - m[1][3] * m[3][0] * m[2][1]; - inv[2][1] = -m[0][0] * m[2][1] * m[3][3] + m[0][0] * m[3][1] * m[2][3] + m[0][1] * m[2][0] * m[3][3] - m[0][1] * m[3][0] * m[2][3] - m[0][3] * m[2][0] * m[3][1] + m[0][3] * m[3][0] * m[2][1]; - inv[2][2] = m[0][0] * m[1][1] * m[3][3] - m[0][0] * m[3][1] * m[1][3] - m[0][1] * m[1][0] * m[3][3] + m[0][1] * m[3][0] * m[1][3] + m[0][3] * m[1][0] * m[3][1] - m[0][3] * m[3][0] * m[1][1]; - inv[2][3] = -m[0][0] * m[1][1] * m[2][3] + m[0][0] * m[2][1] * m[1][3] + m[0][1] * m[1][0] * m[2][3] - m[0][1] * m[2][0] * m[1][3] - m[0][3] * m[1][0] * m[2][1] + m[0][3] * m[2][0] * m[1][1]; - inv[3][0] = -m[1][0] * m[2][1] * m[3][2] + m[1][0] * m[3][1] * m[2][2] + m[1][1] * m[2][0] * m[3][2] - m[1][1] * m[3][0] * m[2][2] - m[1][2] * m[2][0] * m[3][1] + m[1][2] * m[3][0] * m[2][1]; - inv[3][1] = m[0][0] * m[2][1] * m[3][2] - m[0][0] * m[3][1] * m[2][2] - m[0][1] * m[2][0] * m[3][2] + m[0][1] * m[3][0] * m[2][2] + m[0][2] * m[2][0] * m[3][1] - m[0][2] * m[3][0] * m[2][1]; - inv[3][2] = -m[0][0] * m[1][1] * m[3][2] + m[0][0] * m[3][1] * m[1][2] + m[0][1] * m[1][0] * m[3][2] - m[0][1] * m[3][0] * m[1][2] - m[0][2] * m[1][0] * m[3][1] + m[0][2] * m[3][0] * m[1][1]; - inv[3][3] = m[0][0] * m[1][1] * m[2][2] - m[0][0] * m[2][1] * m[1][2] - m[0][1] * m[1][0] * m[2][2] + m[0][1] * m[2][0] * m[1][2] + m[0][2] * m[1][0] * m[2][1] - m[0][2] * m[2][0] * m[1][1]; - - det = m[0][0] * inv[0][0] + m[1][0] * inv[0][1] + m[2][0] * inv[0][2] + m[3][0] * inv[0][3]; - - if (det == 0) - return 0; - - det = 1.0 / det; - - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) - out[i][j] = inv[i][j] * det; - } - - return 1; -} - -void vector4f_matrix4x4_mult(vector4f *u, const matrix4x4 m, const vector4f *v) { - u->x = m[0][0] * v->x + m[0][1] * v->y + m[0][2] * v->z + m[0][3] * v->w; - u->y = m[1][0] * v->x + m[1][1] * v->y + m[1][2] * v->z + m[1][3] * v->w; - u->z = m[2][0] * v->x + m[2][1] * v->y + m[2][2] * v->z + m[2][3] * v->w; - u->w = m[3][0] * v->x + m[3][1] * v->y + m[3][2] * v->z + m[3][3] * v->w; -} diff --git a/deps/vitaGL/source/utils/math_utils.h b/deps/vitaGL/source/utils/math_utils.h deleted file mode 100644 index edf4694146..0000000000 --- a/deps/vitaGL/source/utils/math_utils.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * math_utils.h: - * Header file for the math utilities exposed by math_utils.c - */ - -#ifndef _MATH_UTILS_H_ -#define _MATH_UTILS_H_ - -#include - -#ifndef DEG_TO_RAD -#define DEG_TO_RAD(x) ((x)*M_PI / 180.0) -#endif - -// clang-format off -// vector of 2 floats struct -typedef struct { - float x, y; -} vector2f; - -// vector of 3 floats struct -typedef struct { - union { float x; float r; }; - union { float y; float g; }; - union { float z; float b; }; -} vector3f; - -// vector of 4 floats struct -typedef struct { - union { float x; float r; }; - union { float y; float g; }; - union { float z; float b; }; - union { float w; float a; }; -} vector4f; -// clang-format on - -// 4x4 matrix -typedef float matrix4x4[4][4]; - -// Creates an identity matrix -void matrix4x4_identity(matrix4x4 m); - -// Copy a matrix to another one -void matrix4x4_copy(matrix4x4 dst, const matrix4x4 src); - -// Perform a matrix per matrix moltiplication -void matrix4x4_multiply(matrix4x4 dst, const matrix4x4 src1, const matrix4x4 src2); - -// Rotate a matrix on x,y,z axis -void matrix4x4_rotate_x(matrix4x4 m, float rad); -void matrix4x4_rotate_y(matrix4x4 m, float rad); -void matrix4x4_rotate_z(matrix4x4 m, float rad); - -// Translate a matrix -void matrix4x4_translate(matrix4x4 m, float x, float y, float z); - -// Scale a matrix -void matrix4x4_scale(matrix4x4 m, float scale_x, float scale_y, float scale_z); - -// Transpose a matrix -void matrix4x4_transpose(matrix4x4 out, const matrix4x4 m); - -// Init a matrix with different settings (ortho, frustum, perspective) -void matrix4x4_init_orthographic(matrix4x4 m, float left, float right, float bottom, float top, float near, float far); -void matrix4x4_init_frustum(matrix4x4 m, float left, float right, float bottom, float top, float near, float far); -void matrix4x4_init_perspective(matrix4x4 m, float fov, float aspect, float near, float far); - -// Invert a matrix -int matrix4x4_invert(matrix4x4 out, const matrix4x4 m); - -// Perform a matrix per vector moltiplication -void vector4f_matrix4x4_mult(vector4f *u, const matrix4x4 m, const vector4f *v); - -#endif diff --git a/deps/vitaGL/source/utils/mem_utils.c b/deps/vitaGL/source/utils/mem_utils.c deleted file mode 100644 index 7d362263c4..0000000000 --- a/deps/vitaGL/source/utils/mem_utils.c +++ /dev/null @@ -1,297 +0,0 @@ -/* - * mem_utils.c: - * Utilities for memory management - */ - -#include "../shared.h" - -#define MEM_ALIGNMENT 8 // seems to be enough, set to 16 if something explodes - -typedef struct tm_block_s { - struct tm_block_s *next; // next block in list (either free or allocated) - int32_t type; // one of vglMemType (VGL_MEM_ALL when unused) - uintptr_t base; // block start address - uint32_t offset; // offset for USSE stuff (unused) - uint32_t size; // block size -} tm_block_t; - -static void *mempool_addr[3] = { NULL, NULL, NULL }; // addresses of heap memblocks (VRAM, RAM, PHYCONT RAM) -static SceUID mempool_id[3] = { 0, 0, 0 }; // UIDs of heap memblocks (VRAM, RAM, PHYCONT RAM) -static size_t mempool_size[3] = { 0, 0, 0 }; // sizes of heap memlbocks (VRAM, RAM, PHYCONT RAM) - -static int tm_initialized; - -static tm_block_t *tm_alloclist; // list of allocated blocks -static tm_block_t *tm_freelist; // list of free blocks - -static uint32_t tm_free[VGL_MEM_TYPE_COUNT]; // see enum vglMemType - -// heap funcs // - -// get new block header -static inline tm_block_t *heap_blk_new(void) { - return calloc(1, sizeof(tm_block_t)); -} - -// release block header -static inline void heap_blk_release(tm_block_t *block) { - free(block); -} - -// determine if two blocks can be merged into one -// blocks of different types can't be merged, -// blocks of same type can only be merged if they're next to each other -// in memory and have matching offsets -static inline int heap_blk_mergeable(tm_block_t *a, tm_block_t *b) { - return a->type == b->type - && a->base + a->size == b->base - && a->offset + a->size == b->offset; -} - -// inserts a block into the free list and merges with neighboring -// free blocks if possible -static void heap_blk_insert_free(tm_block_t *block) { - tm_block_t *curblk = tm_freelist; - tm_block_t *prevblk = NULL; - while (curblk && curblk->base < block->base) { - prevblk = curblk; - curblk = curblk->next; - } - - if (prevblk) - prevblk->next = block; - else - tm_freelist = block; - - block->next = curblk; - tm_free[block->type] += block->size; - tm_free[0] += block->size; - - if (curblk && heap_blk_mergeable(block, curblk)) { - block->size += curblk->size; - block->next = curblk->next; - heap_blk_release(curblk); - } - - if (prevblk && heap_blk_mergeable(prevblk, block)) { - prevblk->size += block->size; - prevblk->next = block->next; - heap_blk_release(block); - } -} - -// allocates a block from the heap -// (removes it from free list and adds to alloc list) -static tm_block_t *heap_blk_alloc(int32_t type, uint32_t size, uint32_t alignment) { - tm_block_t *curblk = tm_freelist; - tm_block_t *prevblk = NULL; - - while (curblk) { - const uint32_t skip = ALIGN(curblk->base, alignment) - curblk->base; - - if (curblk->type == type && skip + size <= curblk->size) { - tm_block_t *skipblk = NULL; - tm_block_t *unusedblk = NULL; - - if (skip != 0) { - skipblk = heap_blk_new(); - if (!skipblk) - return NULL; - } - - if (skip + size != curblk->size) { - unusedblk = heap_blk_new(); - if (!unusedblk) { - if (skipblk) - heap_blk_release(skipblk); - return NULL; - } - } - - if (skip != 0) { - if (prevblk) - prevblk->next = skipblk; - else - tm_freelist = skipblk; - - skipblk->next = curblk; - skipblk->type = curblk->type; - skipblk->base = curblk->base; - skipblk->offset = curblk->offset; - skipblk->size = skip; - - curblk->base += skip; - curblk->offset += skip; - curblk->size -= skip; - - prevblk = skipblk; - } - - if (size != curblk->size) { - unusedblk->next = curblk->next; - curblk->next = unusedblk; - unusedblk->type = curblk->type; - unusedblk->base = curblk->base + size; - unusedblk->offset = curblk->offset + size; - unusedblk->size = curblk->size - size; - curblk->size = size; - } - - if (prevblk) - prevblk->next = curblk->next; - else - tm_freelist = curblk->next; - - curblk->next = tm_alloclist; - tm_alloclist = curblk; - tm_free[type] -= size; - tm_free[0] -= size; - return curblk; - } - - prevblk = curblk; - curblk = curblk->next; - } - - return NULL; -} - -// frees a previously allocated heap block -// (removes from alloc list and inserts into free list) -static void heap_blk_free(uintptr_t base) { - tm_block_t *curblk = tm_alloclist; - tm_block_t *prevblk = NULL; - - while (curblk && curblk->base != base) { - prevblk = curblk; - curblk = curblk->next; - } - - if (!curblk) - return; - - if (prevblk) - prevblk->next = curblk->next; - else - tm_alloclist = curblk->next; - - curblk->next = NULL; - - heap_blk_insert_free(curblk); -} - -// initializes heap variables and blockpool -static void heap_init(void) { - tm_alloclist = NULL; - tm_freelist = NULL; - - for (int i = 0; i < VGL_MEM_TYPE_COUNT; ++i) - tm_free[i] = 0; - - tm_initialized = 1; -} - -// resets heap state and frees allocated block headers -static void heap_destroy(void) { - tm_block_t *n; - - tm_block_t *p = tm_alloclist; - while (p) { - n = p->next; - heap_blk_release(p); - p = n; - } - - p = tm_freelist; - while (p) { - n = p->next; - heap_blk_release(p); - p = n; - } - - tm_initialized = 0; -} - -// adds a memblock to the heap -static void heap_extend(int32_t type, void *base, uint32_t size) { - tm_block_t *block = heap_blk_new(); - block->next = NULL; - block->type = type; - block->base = (uintptr_t)base; - block->offset = 0; - block->size = size; - heap_blk_insert_free(block); -} - -// allocates memory from the heap (basically malloc()) -static void *heap_alloc(int32_t type, uint32_t size, uint32_t alignment) { - tm_block_t *block = heap_blk_alloc(type, size, alignment); - - if (!block) - return NULL; - - return (void *)block->base; -} - -// frees previously allocated heap memory (basically free()) -static void heap_free(void *addr) { - heap_blk_free((uintptr_t)addr); -} - -void vitagl_mem_term(void) { - heap_destroy(); - if (mempool_addr[0] != NULL) { - sceKernelFreeMemBlock(mempool_id[0]); - sceKernelFreeMemBlock(mempool_id[1]); - mempool_addr[0] = NULL; - mempool_addr[1] = NULL; - mempool_id[0] = 0; - mempool_id[1] = 0; - } -} - -int vitagl_mem_init(size_t size_ram, size_t size_cdram, size_t size_phycont) { - if (mempool_addr[0] != NULL) - vitagl_mem_term(); - - mempool_size[0] = ALIGN(size_cdram, 256 * 1024); - mempool_size[1] = ALIGN(size_ram, 4 * 1024); - mempool_size[2] = ALIGN(size_phycont, 256 * 1024); - mempool_id[0] = sceKernelAllocMemBlock("cdram_mempool", SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, mempool_size[0], NULL); - mempool_id[1] = sceKernelAllocMemBlock("ram_mempool", SCE_KERNEL_MEMBLOCK_TYPE_USER_RW, mempool_size[1], NULL); - mempool_id[2] = sceKernelAllocMemBlock("phycont_mempool", SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_RW, mempool_size[2], NULL); - - for (int i = 0; i < VGL_MEM_TYPE_COUNT - 2; i++) { - sceKernelGetMemBlockBase(mempool_id[i], &mempool_addr[i]); - sceGxmMapMemory(mempool_addr[i], mempool_size[i], SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE); - } - - // Initialize heap - heap_init(); - - // Add memblocks to heap - heap_extend(VGL_MEM_VRAM, mempool_addr[0], mempool_size[0]); - heap_extend(VGL_MEM_RAM, mempool_addr[1], mempool_size[1]); - heap_extend(VGL_MEM_SLOW, mempool_addr[2], mempool_size[2]); - - return 1; -} - -void vitagl_mempool_free(void *ptr, vglMemType type) { - if (type == VGL_MEM_EXTERNAL) - free(ptr); - else - heap_free(ptr); // type is already stored in heap for alloc'd blocks -} - -void *vitagl_mempool_alloc(size_t size, vglMemType type) { - void *res = NULL; - if (size <= tm_free[type]) - res = heap_alloc(type, size, MEM_ALIGNMENT); - return res; -} - -// Returns currently free space on mempool -size_t vitagl_mempool_get_free_space(vglMemType type) { - return tm_free[type]; -} diff --git a/deps/vitaGL/source/utils/mem_utils.h b/deps/vitaGL/source/utils/mem_utils.h deleted file mode 100644 index bf2c9be5ac..0000000000 --- a/deps/vitaGL/source/utils/mem_utils.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * mem_utils.h: - * Header file for the memory management utilities exposed by mem_utils.c - */ - -#ifndef _MEM_UTILS_H_ -#define _MEM_UTILS_H_ - -int vitagl_mem_init(size_t size_ram, size_t size_cdram, size_t size_phycont); // Initialize mempools -void vitagl_mem_term(void); // Terminate both CDRAM and RAM mempools -size_t vitagl_mempool_get_free_space(vglMemType type); // Return free space in bytes for a mempool -void *vitagl_mempool_alloc(size_t size, vglMemType type); // Allocate a memory block on a mempool -void vitagl_mempool_free(void *ptr, vglMemType type); // Free a memory block on a mempool - -#endif \ No newline at end of file diff --git a/deps/vitaGL/source/vitaGL.c b/deps/vitaGL/source/vitaGL.c deleted file mode 100644 index 95fc121fed..0000000000 --- a/deps/vitaGL/source/vitaGL.c +++ /dev/null @@ -1,2110 +0,0 @@ -/* - * - */ -#include "vitaGL.h" -#include "shared.h" -#include "texture_callbacks.h" - -// Shaders -#include "shaders/clear_f.h" -#include "shaders/clear_v.h" -#include "shaders/disable_color_buffer_f.h" -#include "shaders/rgb_v.h" -#include "shaders/rgba_f.h" -#include "shaders/rgba_v.h" -#include "shaders/texture2d_f.h" -#include "shaders/texture2d_rgba_f.h" -#include "shaders/texture2d_rgba_v.h" -#include "shaders/texture2d_v.h" - -typedef struct gpubuffer { - void *ptr; -} gpubuffer; - -// sceGxm viewport setup (NOTE: origin is on center screen) -float x_port = 480.0f; -float y_port = -272.0f; -float z_port = 0.5f; -float x_scale = 480.0f; -float y_scale = 272.0f; -float z_scale = 0.5f; - -uint8_t viewport_mode = 0; // Current setting for viewport mode -GLboolean vblank = GL_TRUE; // Current setting for VSync - -extern int _newlib_heap_memblock; // Newlib Heap memblock -extern unsigned _newlib_heap_size; // Newlib Heap size - -static const SceGxmProgram *const gxm_program_disable_color_buffer_f = (SceGxmProgram *)&disable_color_buffer_f; -static const SceGxmProgram *const gxm_program_clear_v = (SceGxmProgram *)&clear_v; -static const SceGxmProgram *const gxm_program_clear_f = (SceGxmProgram *)&clear_f; -static const SceGxmProgram *const gxm_program_rgba_v = (SceGxmProgram *)&rgba_v; -static const SceGxmProgram *const gxm_program_rgba_f = (SceGxmProgram *)&rgba_f; -static const SceGxmProgram *const gxm_program_rgb_v = (SceGxmProgram *)&rgb_v; -static const SceGxmProgram *const gxm_program_texture2d_v = (SceGxmProgram *)&texture2d_v; -static const SceGxmProgram *const gxm_program_texture2d_f = (SceGxmProgram *)&texture2d_f; -static const SceGxmProgram *const gxm_program_texture2d_rgba_v = (SceGxmProgram *)&texture2d_rgba_v; -static const SceGxmProgram *const gxm_program_texture2d_rgba_f = (SceGxmProgram *)&texture2d_rgba_f; - -// Disable color buffer shader -uint16_t *depth_clear_indices = NULL; // Memblock starting address for clear screen indices - -// Clear shaders -SceGxmVertexProgram *clear_vertex_program_patched; // Patched vertex program for clearing screen -vector2f *clear_vertices = NULL; // Memblock starting address for clear screen vertices -vector3f *depth_vertices = NULL; // Memblock starting address for depth clear screen vertices - -// Internal stuffs -SceGxmMultisampleMode msaa_mode = SCE_GXM_MULTISAMPLE_NONE; - -static SceGxmBlendInfo *cur_blend_info_ptr = NULL; -extern uint8_t use_vram; - -static GLuint buffers[BUFFERS_NUM]; // Buffers array -static gpubuffer gpu_buffers[BUFFERS_NUM]; // Buffers array -static SceGxmColorMask blend_color_mask = SCE_GXM_COLOR_MASK_ALL; // Current in-use color mask (glColorMask) -static SceGxmBlendFunc blend_func_rgb = SCE_GXM_BLEND_FUNC_ADD; // Current in-use RGB blend func -static SceGxmBlendFunc blend_func_a = SCE_GXM_BLEND_FUNC_ADD; // Current in-use A blend func -static int vertex_array_unit = -1; // Current in-use vertex array unit -static int index_array_unit = -1; // Current in-use index array unit - -vector4f texenv_color = { 0.0f, 0.0f, 0.0f, 0.0f }; // Current in use texture environment color - -// Internal functions - -#ifdef ENABLE_LOG -void LOG(const char *format, ...) { - __gnuc_va_list arg; - int done; - va_start(arg, format); - char msg[512]; - done = vsprintf(msg, format, arg); - va_end(arg); - int i; - sprintf(msg, "%s\n", msg); - FILE *log = fopen("ux0:/data/vitaGL.log", "a+"); - if (log != NULL) { - fwrite(msg, 1, strlen(msg), log); - fclose(log); - } -} -#endif - -static void _change_blend_factor(SceGxmBlendInfo *blend_info) { - changeCustomShadersBlend(blend_info); - - sceGxmShaderPatcherCreateFragmentProgram(gxm_shader_patcher, - rgba_fragment_id, - SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4, - msaa_mode, - blend_info, - NULL, - &rgba_fragment_program_patched); - - sceGxmShaderPatcherCreateFragmentProgram(gxm_shader_patcher, - texture2d_fragment_id, - SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4, - msaa_mode, - blend_info, - NULL, - &texture2d_fragment_program_patched); - - sceGxmShaderPatcherCreateFragmentProgram(gxm_shader_patcher, - texture2d_rgba_fragment_id, - SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4, - msaa_mode, - blend_info, - NULL, - &texture2d_rgba_fragment_program_patched); -} - -void change_blend_factor() { - static SceGxmBlendInfo blend_info; - blend_info.colorMask = blend_color_mask; - blend_info.colorFunc = blend_func_rgb; - blend_info.alphaFunc = blend_func_a; - blend_info.colorSrc = blend_sfactor_rgb; - blend_info.colorDst = blend_dfactor_rgb; - blend_info.alphaSrc = blend_sfactor_a; - blend_info.alphaDst = blend_dfactor_a; - - _change_blend_factor(&blend_info); - cur_blend_info_ptr = &blend_info; - if (cur_program != 0) { - reloadCustomShader(); - } -} - -void change_blend_mask() { - static SceGxmBlendInfo blend_info; - blend_info.colorMask = blend_color_mask; - blend_info.colorFunc = SCE_GXM_BLEND_FUNC_ADD; - blend_info.alphaFunc = SCE_GXM_BLEND_FUNC_ADD; - blend_info.colorSrc = SCE_GXM_BLEND_FACTOR_SRC_ALPHA; - blend_info.colorDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; - blend_info.alphaSrc = SCE_GXM_BLEND_FACTOR_ONE; - blend_info.alphaDst = SCE_GXM_BLEND_FACTOR_ZERO; - - _change_blend_factor(&blend_info); - cur_blend_info_ptr = &blend_info; - if (cur_program != 0) { - reloadCustomShader(); - } -} - -void disable_blend() { - if (blend_color_mask == SCE_GXM_COLOR_MASK_ALL) { - _change_blend_factor(NULL); - cur_blend_info_ptr = NULL; - if (cur_program != 0) { - reloadCustomShader(); - } - } else - change_blend_mask(); -} - -void vector2f_convert_to_local_space(vector2f *out, int x, int y, int width, int height) { - out[0].x = (float)(2 * x) / (float)DISPLAY_WIDTH_FLOAT - 1.0f; - out[1].x = (float)(2 * (x + width)) / (float)DISPLAY_WIDTH_FLOAT - 1.0f; - out[2].x = (float)(2 * (x + width)) / (float)DISPLAY_WIDTH_FLOAT - 1.0f; - out[3].x = (float)(2 * x) / (float)DISPLAY_WIDTH_FLOAT - 1.0f; - out[0].y = 1.0f - (float)(2 * y) / (float)DISPLAY_HEIGHT_FLOAT; - out[1].y = 1.0f - (float)(2 * y) / (float)DISPLAY_HEIGHT_FLOAT; - out[2].y = 1.0f - (float)(2 * (y + height)) / (float)DISPLAY_HEIGHT_FLOAT; - out[3].y = 1.0f - (float)(2 * (y + height)) / (float)DISPLAY_HEIGHT_FLOAT; -} - -// vitaGL specific functions - -void vglUseVram(GLboolean usage) { - use_vram = usage; -} - -void vglInitExtended(uint32_t gpu_pool_size, int width, int height, int ram_threshold, SceGxmMultisampleMode msaa) { - // Setting our display size - msaa_mode = msaa; - DISPLAY_WIDTH = width; - DISPLAY_HEIGHT = height; - DISPLAY_WIDTH_FLOAT = width * 1.0f; - DISPLAY_HEIGHT_FLOAT = height * 1.0f; - switch (DISPLAY_WIDTH) { - case 480: - DISPLAY_STRIDE = 512; - break; - case 640: - DISPLAY_STRIDE = 640; - break; - case 720: - DISPLAY_STRIDE = 768; - break; - default: - DISPLAY_STRIDE = 960; - break; - } - - // Initializing sceGxm - initGxm(); - - // Getting max allocatable CDRAM and RAM memory - SceKernelFreeMemorySizeInfo info; - info.size = sizeof(SceKernelFreeMemorySizeInfo); - sceKernelGetFreeMemorySize(&info); - - // Initializing memory heap for CDRAM and RAM memory - vitagl_mem_init(info.size_user - ram_threshold, info.size_cdram - 1 * 1024 * 1024, info.size_phycont - 1 * 1024 * 1024); // leave some just in case - - // Initializing sceGxm context - initGxmContext(); - - // Creating render target for the display - createDisplayRenderTarget(); - - // Creating color surfaces for the display - initDisplayColorSurfaces(); - - // Creating depth and stencil surfaces for the display - initDepthStencilSurfaces(); - - // Starting a sceGxmShaderPatcher instance - startShaderPatcher(); - - // Disable color buffer shader register - sceGxmShaderPatcherRegisterProgram(gxm_shader_patcher, gxm_program_disable_color_buffer_f, - &disable_color_buffer_fragment_id); - - const SceGxmProgram *disable_color_buffer_fragment_program = sceGxmShaderPatcherGetProgramFromId(disable_color_buffer_fragment_id); - - clear_depth = sceGxmProgramFindParameterByName( - disable_color_buffer_fragment_program, "depth_clear"); - - SceGxmBlendInfo disable_color_buffer_blend_info; - memset(&disable_color_buffer_blend_info, 0, sizeof(SceGxmBlendInfo)); - disable_color_buffer_blend_info.colorMask = SCE_GXM_COLOR_MASK_NONE; - disable_color_buffer_blend_info.colorFunc = SCE_GXM_BLEND_FUNC_NONE; - disable_color_buffer_blend_info.alphaFunc = SCE_GXM_BLEND_FUNC_NONE; - disable_color_buffer_blend_info.colorSrc = SCE_GXM_BLEND_FACTOR_ZERO; - disable_color_buffer_blend_info.colorDst = SCE_GXM_BLEND_FACTOR_ZERO; - disable_color_buffer_blend_info.alphaSrc = SCE_GXM_BLEND_FACTOR_ZERO; - disable_color_buffer_blend_info.alphaDst = SCE_GXM_BLEND_FACTOR_ZERO; - - sceGxmShaderPatcherCreateFragmentProgram(gxm_shader_patcher, - disable_color_buffer_fragment_id, - SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4, - msaa, - &disable_color_buffer_blend_info, NULL, - &disable_color_buffer_fragment_program_patched); - - vglMemType type = VGL_MEM_RAM; - clear_vertices = gpu_alloc_mapped(4 * sizeof(vector2f), &type); - depth_clear_indices = gpu_alloc_mapped(4 * sizeof(unsigned short), &type); - - vector2f_convert_to_local_space(clear_vertices, 0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT); - - depth_clear_indices[0] = 0; - depth_clear_indices[1] = 1; - depth_clear_indices[2] = 2; - depth_clear_indices[3] = 3; - - // Clear shader register - sceGxmShaderPatcherRegisterProgram(gxm_shader_patcher, gxm_program_clear_v, - &clear_vertex_id); - sceGxmShaderPatcherRegisterProgram(gxm_shader_patcher, gxm_program_clear_f, - &clear_fragment_id); - - const SceGxmProgram *clear_vertex_program = sceGxmShaderPatcherGetProgramFromId(clear_vertex_id); - const SceGxmProgram *clear_fragment_program = sceGxmShaderPatcherGetProgramFromId(clear_fragment_id); - - clear_position = sceGxmProgramFindParameterByName( - clear_vertex_program, "position"); - - clear_color = sceGxmProgramFindParameterByName( - clear_fragment_program, "u_clear_color"); - - SceGxmVertexAttribute clear_vertex_attribute; - SceGxmVertexStream clear_vertex_stream; - clear_vertex_attribute.streamIndex = 0; - clear_vertex_attribute.offset = 0; - clear_vertex_attribute.format = SCE_GXM_ATTRIBUTE_FORMAT_F32; - clear_vertex_attribute.componentCount = 2; - clear_vertex_attribute.regIndex = sceGxmProgramParameterGetResourceIndex( - clear_position); - clear_vertex_stream.stride = sizeof(vector2f); - clear_vertex_stream.indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT; - - sceGxmShaderPatcherCreateVertexProgram(gxm_shader_patcher, - clear_vertex_id, &clear_vertex_attribute, - 1, &clear_vertex_stream, 1, &clear_vertex_program_patched); - - sceGxmShaderPatcherCreateFragmentProgram(gxm_shader_patcher, - clear_fragment_id, SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4, - msaa, NULL, NULL, - &clear_fragment_program_patched); - - // Color shader register - sceGxmShaderPatcherRegisterProgram(gxm_shader_patcher, gxm_program_rgba_v, - &rgba_vertex_id); - sceGxmShaderPatcherRegisterProgram(gxm_shader_patcher, gxm_program_rgb_v, - &rgb_vertex_id); - sceGxmShaderPatcherRegisterProgram(gxm_shader_patcher, gxm_program_rgba_f, - &rgba_fragment_id); - - const SceGxmProgram *rgba_vertex_program = sceGxmShaderPatcherGetProgramFromId(rgba_vertex_id); - const SceGxmProgram *rgb_vertex_program = sceGxmShaderPatcherGetProgramFromId(rgb_vertex_id); - rgba_fragment_program = sceGxmShaderPatcherGetProgramFromId(rgba_fragment_id); - - rgba_position = sceGxmProgramFindParameterByName( - rgba_vertex_program, "aPosition"); - - rgba_color = sceGxmProgramFindParameterByName( - rgba_vertex_program, "aColor"); - - rgb_position = sceGxmProgramFindParameterByName( - rgba_vertex_program, "aPosition"); - - rgb_color = sceGxmProgramFindParameterByName( - rgba_vertex_program, "aColor"); - - SceGxmVertexAttribute rgba_vertex_attribute[2]; - SceGxmVertexStream rgba_vertex_stream[2]; - rgba_vertex_attribute[0].streamIndex = 0; - rgba_vertex_attribute[0].offset = 0; - rgba_vertex_attribute[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32; - rgba_vertex_attribute[0].componentCount = 3; - rgba_vertex_attribute[0].regIndex = sceGxmProgramParameterGetResourceIndex( - rgba_position); - rgba_vertex_attribute[1].streamIndex = 1; - rgba_vertex_attribute[1].offset = 0; - rgba_vertex_attribute[1].format = SCE_GXM_ATTRIBUTE_FORMAT_F32; - rgba_vertex_attribute[1].componentCount = 4; - rgba_vertex_attribute[1].regIndex = sceGxmProgramParameterGetResourceIndex( - rgba_color); - rgba_vertex_stream[0].stride = sizeof(vector3f); - rgba_vertex_stream[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT; - rgba_vertex_stream[1].stride = sizeof(vector4f); - rgba_vertex_stream[1].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT; - - sceGxmShaderPatcherCreateVertexProgram(gxm_shader_patcher, - rgba_vertex_id, rgba_vertex_attribute, - 2, rgba_vertex_stream, 2, &rgba_vertex_program_patched); - - rgba_vertex_attribute[1].format = SCE_GXM_ATTRIBUTE_FORMAT_U8N; - rgba_vertex_stream[1].stride = sizeof(uint8_t) * 4; - - sceGxmShaderPatcherCreateVertexProgram(gxm_shader_patcher, - rgba_vertex_id, rgba_vertex_attribute, - 2, rgba_vertex_stream, 2, &rgba_u8n_vertex_program_patched); - - SceGxmVertexAttribute rgb_vertex_attribute[2]; - SceGxmVertexStream rgb_vertex_stream[2]; - rgb_vertex_attribute[0].streamIndex = 0; - rgb_vertex_attribute[0].offset = 0; - rgb_vertex_attribute[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32; - rgb_vertex_attribute[0].componentCount = 3; - rgb_vertex_attribute[0].regIndex = sceGxmProgramParameterGetResourceIndex( - rgb_position); - rgb_vertex_attribute[1].streamIndex = 1; - rgb_vertex_attribute[1].offset = 0; - rgb_vertex_attribute[1].format = SCE_GXM_ATTRIBUTE_FORMAT_F32; - rgb_vertex_attribute[1].componentCount = 3; - rgb_vertex_attribute[1].regIndex = sceGxmProgramParameterGetResourceIndex( - rgb_color); - rgb_vertex_stream[0].stride = sizeof(vector3f); - rgb_vertex_stream[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT; - rgb_vertex_stream[1].stride = sizeof(vector3f); - rgb_vertex_stream[1].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT; - - sceGxmShaderPatcherCreateVertexProgram(gxm_shader_patcher, - rgb_vertex_id, rgb_vertex_attribute, - 2, rgb_vertex_stream, 2, &rgb_vertex_program_patched); - - rgb_vertex_attribute[1].format = SCE_GXM_ATTRIBUTE_FORMAT_U8N; - rgb_vertex_stream[1].stride = sizeof(uint8_t) * 3; - - sceGxmShaderPatcherCreateVertexProgram(gxm_shader_patcher, - rgb_vertex_id, rgb_vertex_attribute, - 2, rgb_vertex_stream, 2, &rgb_u8n_vertex_program_patched); - - sceGxmShaderPatcherCreateFragmentProgram(gxm_shader_patcher, - rgba_fragment_id, SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4, - msaa, NULL, NULL, - &rgba_fragment_program_patched); - - rgba_wvp = sceGxmProgramFindParameterByName(rgba_vertex_program, "wvp"); - rgb_wvp = sceGxmProgramFindParameterByName(rgb_vertex_program, "wvp"); - - // Texture2D shader register - sceGxmShaderPatcherRegisterProgram(gxm_shader_patcher, gxm_program_texture2d_v, - &texture2d_vertex_id); - sceGxmShaderPatcherRegisterProgram(gxm_shader_patcher, gxm_program_texture2d_f, - &texture2d_fragment_id); - - const SceGxmProgram *texture2d_vertex_program = sceGxmShaderPatcherGetProgramFromId(texture2d_vertex_id); - texture2d_fragment_program = sceGxmShaderPatcherGetProgramFromId(texture2d_fragment_id); - - texture2d_position = sceGxmProgramFindParameterByName( - texture2d_vertex_program, "position"); - - texture2d_texcoord = sceGxmProgramFindParameterByName( - texture2d_vertex_program, "texcoord"); - - texture2d_alpha_cut = sceGxmProgramFindParameterByName( - texture2d_fragment_program, "alphaCut"); - - texture2d_alpha_op = sceGxmProgramFindParameterByName( - texture2d_fragment_program, "alphaOp"); - - texture2d_tint_color = sceGxmProgramFindParameterByName( - texture2d_fragment_program, "tintColor"); - - texture2d_tex_env = sceGxmProgramFindParameterByName( - texture2d_fragment_program, "texEnv"); - - texture2d_fog_mode = sceGxmProgramFindParameterByName( - texture2d_fragment_program, "fog_mode"); - - texture2d_fog_color = sceGxmProgramFindParameterByName( - texture2d_fragment_program, "fogColor"); - - texture2d_fog_mode2 = sceGxmProgramFindParameterByName( - texture2d_vertex_program, "fog_mode"); - - texture2d_clip_plane0 = sceGxmProgramFindParameterByName( - texture2d_vertex_program, "clip_plane0"); - - texture2d_clip_plane0_eq = sceGxmProgramFindParameterByName( - texture2d_vertex_program, "clip_plane0_eq"); - - texture2d_mv = sceGxmProgramFindParameterByName( - texture2d_vertex_program, "modelview"); - - texture2d_fog_near = sceGxmProgramFindParameterByName( - texture2d_vertex_program, "fog_near"); - - texture2d_fog_far = sceGxmProgramFindParameterByName( - texture2d_vertex_program, "fog_far"); - - texture2d_fog_density = sceGxmProgramFindParameterByName( - texture2d_vertex_program, "fog_density"); - - texture2d_tex_env_color = sceGxmProgramFindParameterByName( - texture2d_fragment_program, "texEnvColor"); - - SceGxmVertexAttribute texture2d_vertex_attribute[2]; - SceGxmVertexStream texture2d_vertex_stream[2]; - texture2d_vertex_attribute[0].streamIndex = 0; - texture2d_vertex_attribute[0].offset = 0; - texture2d_vertex_attribute[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32; - texture2d_vertex_attribute[0].componentCount = 3; - texture2d_vertex_attribute[0].regIndex = sceGxmProgramParameterGetResourceIndex( - texture2d_position); - texture2d_vertex_attribute[1].streamIndex = 1; - texture2d_vertex_attribute[1].offset = 0; - texture2d_vertex_attribute[1].format = SCE_GXM_ATTRIBUTE_FORMAT_F32; - texture2d_vertex_attribute[1].componentCount = 2; - texture2d_vertex_attribute[1].regIndex = sceGxmProgramParameterGetResourceIndex( - texture2d_texcoord); - texture2d_vertex_stream[0].stride = sizeof(vector3f); - texture2d_vertex_stream[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT; - texture2d_vertex_stream[1].stride = sizeof(vector2f); - texture2d_vertex_stream[1].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT; - - sceGxmShaderPatcherCreateVertexProgram(gxm_shader_patcher, - texture2d_vertex_id, texture2d_vertex_attribute, - 2, texture2d_vertex_stream, 2, &texture2d_vertex_program_patched); - - sceGxmShaderPatcherCreateFragmentProgram(gxm_shader_patcher, - texture2d_fragment_id, SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4, - msaa, NULL, NULL, - &texture2d_fragment_program_patched); - - texture2d_wvp = sceGxmProgramFindParameterByName(texture2d_vertex_program, "wvp"); - - // Texture2D+RGBA shader register - sceGxmShaderPatcherRegisterProgram(gxm_shader_patcher, gxm_program_texture2d_rgba_v, - &texture2d_rgba_vertex_id); - sceGxmShaderPatcherRegisterProgram(gxm_shader_patcher, gxm_program_texture2d_rgba_f, - &texture2d_rgba_fragment_id); - - const SceGxmProgram *texture2d_rgba_vertex_program = sceGxmShaderPatcherGetProgramFromId(texture2d_rgba_vertex_id); - texture2d_rgba_fragment_program = sceGxmShaderPatcherGetProgramFromId(texture2d_rgba_fragment_id); - - texture2d_rgba_position = sceGxmProgramFindParameterByName( - texture2d_rgba_vertex_program, "position"); - - texture2d_rgba_texcoord = sceGxmProgramFindParameterByName( - texture2d_rgba_vertex_program, "texcoord"); - - texture2d_rgba_alpha_cut = sceGxmProgramFindParameterByName( - texture2d_rgba_fragment_program, "alphaCut"); - - texture2d_rgba_alpha_op = sceGxmProgramFindParameterByName( - texture2d_rgba_fragment_program, "alphaOp"); - - texture2d_rgba_color = sceGxmProgramFindParameterByName( - texture2d_rgba_vertex_program, "color"); - - texture2d_rgba_tex_env = sceGxmProgramFindParameterByName( - texture2d_rgba_fragment_program, "texEnv"); - - texture2d_rgba_fog_mode = sceGxmProgramFindParameterByName( - texture2d_rgba_fragment_program, "fog_mode"); - - texture2d_rgba_fog_mode2 = sceGxmProgramFindParameterByName( - texture2d_rgba_vertex_program, "fog_mode"); - - texture2d_rgba_clip_plane0 = sceGxmProgramFindParameterByName( - texture2d_rgba_vertex_program, "clip_plane0"); - - texture2d_rgba_clip_plane0_eq = sceGxmProgramFindParameterByName( - texture2d_rgba_vertex_program, "clip_plane0_eq"); - - texture2d_rgba_mv = sceGxmProgramFindParameterByName( - texture2d_rgba_vertex_program, "modelview"); - - texture2d_rgba_fog_near = sceGxmProgramFindParameterByName( - texture2d_rgba_vertex_program, "fog_near"); - - texture2d_rgba_fog_far = sceGxmProgramFindParameterByName( - texture2d_rgba_vertex_program, "fog_far"); - - texture2d_rgba_fog_density = sceGxmProgramFindParameterByName( - texture2d_rgba_vertex_program, "fog_density"); - - texture2d_rgba_fog_color = sceGxmProgramFindParameterByName( - texture2d_rgba_fragment_program, "fogColor"); - - texture2d_rgba_tex_env_color = sceGxmProgramFindParameterByName( - texture2d_rgba_fragment_program, "texEnvColor"); - - SceGxmVertexAttribute texture2d_rgba_vertex_attribute[3]; - SceGxmVertexStream texture2d_rgba_vertex_stream[3]; - texture2d_rgba_vertex_attribute[0].streamIndex = 0; - texture2d_rgba_vertex_attribute[0].offset = 0; - texture2d_rgba_vertex_attribute[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32; - texture2d_rgba_vertex_attribute[0].componentCount = 3; - texture2d_rgba_vertex_attribute[0].regIndex = sceGxmProgramParameterGetResourceIndex( - texture2d_rgba_position); - texture2d_rgba_vertex_attribute[1].streamIndex = 1; - texture2d_rgba_vertex_attribute[1].offset = 0; - texture2d_rgba_vertex_attribute[1].format = SCE_GXM_ATTRIBUTE_FORMAT_F32; - texture2d_rgba_vertex_attribute[1].componentCount = 2; - texture2d_rgba_vertex_attribute[1].regIndex = sceGxmProgramParameterGetResourceIndex( - texture2d_rgba_texcoord); - texture2d_rgba_vertex_attribute[2].streamIndex = 2; - texture2d_rgba_vertex_attribute[2].offset = 0; - texture2d_rgba_vertex_attribute[2].format = SCE_GXM_ATTRIBUTE_FORMAT_F32; - texture2d_rgba_vertex_attribute[2].componentCount = 4; - texture2d_rgba_vertex_attribute[2].regIndex = sceGxmProgramParameterGetResourceIndex( - texture2d_rgba_color); - texture2d_rgba_vertex_stream[0].stride = sizeof(vector3f); - texture2d_rgba_vertex_stream[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT; - texture2d_rgba_vertex_stream[1].stride = sizeof(vector2f); - texture2d_rgba_vertex_stream[1].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT; - texture2d_rgba_vertex_stream[2].stride = sizeof(vector4f); - texture2d_rgba_vertex_stream[2].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT; - - sceGxmShaderPatcherCreateVertexProgram(gxm_shader_patcher, - texture2d_rgba_vertex_id, texture2d_rgba_vertex_attribute, - 3, texture2d_rgba_vertex_stream, 3, &texture2d_rgba_vertex_program_patched); - - texture2d_rgba_vertex_attribute[2].format = SCE_GXM_ATTRIBUTE_FORMAT_U8N; - texture2d_rgba_vertex_stream[2].stride = sizeof(uint8_t) * 4; - - sceGxmShaderPatcherCreateVertexProgram(gxm_shader_patcher, - texture2d_rgba_vertex_id, texture2d_rgba_vertex_attribute, - 3, texture2d_rgba_vertex_stream, 3, &texture2d_rgba_u8n_vertex_program_patched); - - sceGxmShaderPatcherCreateFragmentProgram(gxm_shader_patcher, - texture2d_rgba_fragment_id, SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4, - msaa, NULL, NULL, - &texture2d_rgba_fragment_program_patched); - - texture2d_rgba_wvp = sceGxmProgramFindParameterByName(texture2d_rgba_vertex_program, "wvp"); - - sceGxmSetTwoSidedEnable(gxm_context, SCE_GXM_TWO_SIDED_ENABLED); - - // Scissor Test shader register - sceGxmShaderPatcherCreateMaskUpdateFragmentProgram(gxm_shader_patcher, &scissor_test_fragment_program); - - scissor_test_vertices = gpu_alloc_mapped(4 * sizeof(vector2f), &type); - - // Allocate temp pool for non-VBO drawing - gpu_pool_init(gpu_pool_size); - - // Init texture units - int i, j; - for (i = 0; i < GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS; i++) { - for (j = 0; j < TEXTURES_NUM; j++) { - texture_units[i].textures[j].used = 0; - texture_units[i].textures[j].valid = 0; - } - texture_units[i].env_mode = MODULATE; - texture_units[i].tex_id = 0; - texture_units[i].enabled = 0; - texture_units[i].min_filter = SCE_GXM_TEXTURE_FILTER_LINEAR; - texture_units[i].mag_filter = SCE_GXM_TEXTURE_FILTER_LINEAR; - texture_units[i].u_mode = SCE_GXM_TEXTURE_ADDR_REPEAT; - texture_units[i].v_mode = SCE_GXM_TEXTURE_ADDR_REPEAT; - } - - // Init custom shaders - resetCustomShaders(); - - // Init buffers - for (i = 0; i < BUFFERS_NUM; i++) { - buffers[i] = BUFFERS_ADDR + i; - gpu_buffers[i].ptr = NULL; - } - - // Init scissor test state - resetScissorTestRegion(); - - // Init viewport state - gl_viewport.x = 0; - gl_viewport.y = 0; - gl_viewport.w = DISPLAY_WIDTH; - gl_viewport.h = DISPLAY_HEIGHT; - - // Getting newlib heap memblock starting address - void *addr = NULL; - sceKernelGetMemBlockBase(_newlib_heap_memblock, &addr); - - // Mapping newlib heap into sceGxm - sceGxmMapMemory(addr, _newlib_heap_size, SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE); -} - -void vglInit(uint32_t gpu_pool_size) { - vglInitExtended(gpu_pool_size, DISPLAY_WIDTH_DEF, DISPLAY_HEIGHT_DEF, 0x1000000, SCE_GXM_MULTISAMPLE_NONE); -} - -void vglEnd(void) { - // Wait for rendering to be finished - waitRenderingDone(); - - // Deallocating default vertices buffers - vitagl_mempool_free(clear_vertices, VGL_MEM_RAM); - vitagl_mempool_free(depth_vertices, VGL_MEM_RAM); - vitagl_mempool_free(depth_clear_indices, VGL_MEM_RAM); - vitagl_mempool_free(scissor_test_vertices, VGL_MEM_RAM); - - // Releasing shader programs from sceGxmShaderPatcher - sceGxmShaderPatcherReleaseFragmentProgram(gxm_shader_patcher, scissor_test_fragment_program); - sceGxmShaderPatcherReleaseFragmentProgram(gxm_shader_patcher, disable_color_buffer_fragment_program_patched); - sceGxmShaderPatcherReleaseVertexProgram(gxm_shader_patcher, clear_vertex_program_patched); - sceGxmShaderPatcherReleaseFragmentProgram(gxm_shader_patcher, clear_fragment_program_patched); - sceGxmShaderPatcherReleaseVertexProgram(gxm_shader_patcher, rgba_vertex_program_patched); - sceGxmShaderPatcherReleaseVertexProgram(gxm_shader_patcher, rgb_vertex_program_patched); - sceGxmShaderPatcherReleaseFragmentProgram(gxm_shader_patcher, rgba_fragment_program_patched); - sceGxmShaderPatcherReleaseVertexProgram(gxm_shader_patcher, texture2d_vertex_program_patched); - sceGxmShaderPatcherReleaseFragmentProgram(gxm_shader_patcher, texture2d_fragment_program_patched); - - // Unregistering shader programs from sceGxmShaderPatcher - sceGxmShaderPatcherUnregisterProgram(gxm_shader_patcher, clear_vertex_id); - sceGxmShaderPatcherUnregisterProgram(gxm_shader_patcher, clear_fragment_id); - sceGxmShaderPatcherUnregisterProgram(gxm_shader_patcher, rgb_vertex_id); - sceGxmShaderPatcherUnregisterProgram(gxm_shader_patcher, rgba_vertex_id); - sceGxmShaderPatcherUnregisterProgram(gxm_shader_patcher, rgba_fragment_id); - sceGxmShaderPatcherUnregisterProgram(gxm_shader_patcher, texture2d_vertex_id); - sceGxmShaderPatcherUnregisterProgram(gxm_shader_patcher, texture2d_fragment_id); - sceGxmShaderPatcherUnregisterProgram(gxm_shader_patcher, disable_color_buffer_fragment_id); - - // Terminating shader patcher - stopShaderPatcher(); - - // Deallocating depth and stencil surfaces for display - termDepthStencilSurfaces(); - - // Terminating display's color surfaces - termDisplayColorSurfaces(); - - // Destroing display's render target - destroyDisplayRenderTarget(); - - // Terminating sceGxm context - termGxmContext(); - - // Terminating sceGxm - sceGxmTerminate(); -} - -void vglWaitVblankStart(GLboolean enable) { - vblank = enable; -} - -// openGL implementation - -void glGenBuffers(GLsizei n, GLuint *res) { - int i = 0, j = 0; -#ifndef SKIP_ERROR_HANDLING - if (n < 0) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - for (i = 0; i < BUFFERS_NUM; i++) { - if (buffers[i] != 0x0000) { - res[j++] = buffers[i]; - buffers[i] = 0x0000; - } - if (j >= n) - break; - } -} - -void glBindBuffer(GLenum target, GLuint buffer) { -#ifndef SKIP_ERROR_HANDLING - if ((buffer != 0x0000) && ((buffer >= BUFFERS_ADDR + BUFFERS_NUM) || (buffer < BUFFERS_ADDR))) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - switch (target) { - case GL_ARRAY_BUFFER: - vertex_array_unit = buffer - BUFFERS_ADDR; - break; - case GL_ELEMENT_ARRAY_BUFFER: - index_array_unit = buffer - BUFFERS_ADDR; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} - -void glDeleteBuffers(GLsizei n, const GLuint *gl_buffers) { -#ifndef SKIP_ERROR_HANDLING - if (n < 0) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - int i, j; - for (j = 0; j < n; j++) { - if (gl_buffers[j] >= BUFFERS_ADDR && gl_buffers[j] < (BUFFERS_ADDR + BUFFERS_NUM)) { - uint8_t idx = gl_buffers[j] - BUFFERS_ADDR; - buffers[idx] = gl_buffers[j]; - if (gpu_buffers[idx].ptr != NULL) { - vitagl_mempool_free(gpu_buffers[idx].ptr, VGL_MEM_VRAM); - gpu_buffers[idx].ptr = NULL; - } - } - } -} - -void glBufferData(GLenum target, GLsizei size, const GLvoid *data, GLenum usage) { -#ifndef SKIP_ERROR_HANDLING - if (size < 0) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - int idx = 0; - switch (target) { - case GL_ARRAY_BUFFER: - idx = vertex_array_unit; - break; - case GL_ELEMENT_ARRAY_BUFFER: - idx = index_array_unit; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - vglMemType type = VGL_MEM_VRAM; - gpu_buffers[idx].ptr = gpu_alloc_mapped(size, &type); - memcpy(gpu_buffers[idx].ptr, data, size); -} - -void glBlendFunc(GLenum sfactor, GLenum dfactor) { - switch (sfactor) { - case GL_ZERO: - blend_sfactor_rgb = blend_sfactor_a = SCE_GXM_BLEND_FACTOR_ZERO; - break; - case GL_ONE: - blend_sfactor_rgb = blend_sfactor_a = SCE_GXM_BLEND_FACTOR_ONE; - break; - case GL_SRC_COLOR: - blend_sfactor_rgb = blend_sfactor_a = SCE_GXM_BLEND_FACTOR_SRC_COLOR; - break; - case GL_ONE_MINUS_SRC_COLOR: - blend_sfactor_rgb = blend_sfactor_a = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_COLOR; - break; - case GL_DST_COLOR: - blend_sfactor_rgb = blend_sfactor_a = SCE_GXM_BLEND_FACTOR_DST_COLOR; - break; - case GL_ONE_MINUS_DST_COLOR: - blend_sfactor_rgb = blend_sfactor_a = SCE_GXM_BLEND_FACTOR_ONE_MINUS_DST_COLOR; - break; - case GL_SRC_ALPHA: - blend_sfactor_rgb = blend_sfactor_a = SCE_GXM_BLEND_FACTOR_SRC_ALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - blend_sfactor_rgb = blend_sfactor_a = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; - break; - case GL_DST_ALPHA: - blend_sfactor_rgb = blend_sfactor_a = SCE_GXM_BLEND_FACTOR_DST_ALPHA; - break; - case GL_ONE_MINUS_DST_ALPHA: - blend_sfactor_rgb = blend_sfactor_a = SCE_GXM_BLEND_FACTOR_ONE_MINUS_DST_ALPHA; - break; - case GL_SRC_ALPHA_SATURATE: - blend_sfactor_rgb = blend_sfactor_a = SCE_GXM_BLEND_FACTOR_SRC_ALPHA_SATURATE; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - switch (dfactor) { - case GL_ZERO: - blend_dfactor_rgb = blend_dfactor_a = SCE_GXM_BLEND_FACTOR_ZERO; - break; - case GL_ONE: - blend_dfactor_rgb = blend_dfactor_a = SCE_GXM_BLEND_FACTOR_ONE; - break; - case GL_SRC_COLOR: - blend_dfactor_rgb = blend_dfactor_a = SCE_GXM_BLEND_FACTOR_SRC_COLOR; - break; - case GL_ONE_MINUS_SRC_COLOR: - blend_dfactor_rgb = blend_dfactor_a = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_COLOR; - break; - case GL_DST_COLOR: - blend_dfactor_rgb = blend_dfactor_a = SCE_GXM_BLEND_FACTOR_DST_COLOR; - break; - case GL_ONE_MINUS_DST_COLOR: - blend_dfactor_rgb = blend_dfactor_a = SCE_GXM_BLEND_FACTOR_ONE_MINUS_DST_COLOR; - break; - case GL_SRC_ALPHA: - blend_dfactor_rgb = blend_dfactor_a = SCE_GXM_BLEND_FACTOR_SRC_ALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - blend_dfactor_rgb = blend_dfactor_a = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; - break; - case GL_DST_ALPHA: - blend_dfactor_rgb = blend_dfactor_a = SCE_GXM_BLEND_FACTOR_DST_ALPHA; - break; - case GL_ONE_MINUS_DST_ALPHA: - blend_dfactor_rgb = blend_dfactor_a = SCE_GXM_BLEND_FACTOR_ONE_MINUS_DST_ALPHA; - break; - case GL_SRC_ALPHA_SATURATE: - blend_dfactor_rgb = blend_dfactor_a = SCE_GXM_BLEND_FACTOR_SRC_ALPHA_SATURATE; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - if (blend_state) - change_blend_factor(); -} - -void glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) { - switch (srcRGB) { - case GL_ZERO: - blend_sfactor_rgb = SCE_GXM_BLEND_FACTOR_ZERO; - break; - case GL_ONE: - blend_sfactor_rgb = SCE_GXM_BLEND_FACTOR_ONE; - break; - case GL_SRC_COLOR: - blend_sfactor_rgb = SCE_GXM_BLEND_FACTOR_SRC_COLOR; - break; - case GL_ONE_MINUS_SRC_COLOR: - blend_sfactor_rgb = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_COLOR; - break; - case GL_DST_COLOR: - blend_sfactor_rgb = SCE_GXM_BLEND_FACTOR_DST_COLOR; - break; - case GL_ONE_MINUS_DST_COLOR: - blend_sfactor_rgb = SCE_GXM_BLEND_FACTOR_ONE_MINUS_DST_COLOR; - break; - case GL_SRC_ALPHA: - blend_sfactor_rgb = SCE_GXM_BLEND_FACTOR_SRC_ALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - blend_sfactor_rgb = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; - break; - case GL_DST_ALPHA: - blend_sfactor_rgb = SCE_GXM_BLEND_FACTOR_DST_ALPHA; - break; - case GL_ONE_MINUS_DST_ALPHA: - blend_sfactor_rgb = SCE_GXM_BLEND_FACTOR_ONE_MINUS_DST_ALPHA; - break; - case GL_SRC_ALPHA_SATURATE: - blend_sfactor_rgb = SCE_GXM_BLEND_FACTOR_SRC_ALPHA_SATURATE; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - switch (dstRGB) { - case GL_ZERO: - blend_dfactor_rgb = SCE_GXM_BLEND_FACTOR_ZERO; - break; - case GL_ONE: - blend_dfactor_rgb = SCE_GXM_BLEND_FACTOR_ONE; - break; - case GL_SRC_COLOR: - blend_dfactor_rgb = SCE_GXM_BLEND_FACTOR_SRC_COLOR; - break; - case GL_ONE_MINUS_SRC_COLOR: - blend_dfactor_rgb = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_COLOR; - break; - case GL_DST_COLOR: - blend_dfactor_rgb = SCE_GXM_BLEND_FACTOR_DST_COLOR; - break; - case GL_ONE_MINUS_DST_COLOR: - blend_dfactor_rgb = SCE_GXM_BLEND_FACTOR_ONE_MINUS_DST_COLOR; - break; - case GL_SRC_ALPHA: - blend_dfactor_rgb = SCE_GXM_BLEND_FACTOR_SRC_ALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - blend_dfactor_rgb = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; - break; - case GL_DST_ALPHA: - blend_dfactor_rgb = SCE_GXM_BLEND_FACTOR_DST_ALPHA; - break; - case GL_ONE_MINUS_DST_ALPHA: - blend_dfactor_rgb = SCE_GXM_BLEND_FACTOR_ONE_MINUS_DST_ALPHA; - break; - case GL_SRC_ALPHA_SATURATE: - blend_dfactor_rgb = SCE_GXM_BLEND_FACTOR_SRC_ALPHA_SATURATE; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - switch (srcAlpha) { - case GL_ZERO: - blend_sfactor_a = SCE_GXM_BLEND_FACTOR_ZERO; - break; - case GL_ONE: - blend_sfactor_a = SCE_GXM_BLEND_FACTOR_ONE; - break; - case GL_SRC_COLOR: - blend_sfactor_a = SCE_GXM_BLEND_FACTOR_SRC_COLOR; - break; - case GL_ONE_MINUS_SRC_COLOR: - blend_sfactor_a = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_COLOR; - break; - case GL_DST_COLOR: - blend_sfactor_a = SCE_GXM_BLEND_FACTOR_DST_COLOR; - break; - case GL_ONE_MINUS_DST_COLOR: - blend_sfactor_a = SCE_GXM_BLEND_FACTOR_ONE_MINUS_DST_COLOR; - break; - case GL_SRC_ALPHA: - blend_sfactor_a = SCE_GXM_BLEND_FACTOR_SRC_ALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - blend_sfactor_a = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; - break; - case GL_DST_ALPHA: - blend_sfactor_a = SCE_GXM_BLEND_FACTOR_DST_ALPHA; - break; - case GL_ONE_MINUS_DST_ALPHA: - blend_sfactor_a = SCE_GXM_BLEND_FACTOR_ONE_MINUS_DST_ALPHA; - break; - case GL_SRC_ALPHA_SATURATE: - blend_sfactor_a = SCE_GXM_BLEND_FACTOR_SRC_ALPHA_SATURATE; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - switch (dstAlpha) { - case GL_ZERO: - blend_dfactor_a = SCE_GXM_BLEND_FACTOR_ZERO; - break; - case GL_ONE: - blend_dfactor_a = SCE_GXM_BLEND_FACTOR_ONE; - break; - case GL_SRC_COLOR: - blend_dfactor_a = SCE_GXM_BLEND_FACTOR_SRC_COLOR; - break; - case GL_ONE_MINUS_SRC_COLOR: - blend_dfactor_a = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_COLOR; - break; - case GL_DST_COLOR: - blend_dfactor_a = SCE_GXM_BLEND_FACTOR_DST_COLOR; - break; - case GL_ONE_MINUS_DST_COLOR: - blend_dfactor_a = SCE_GXM_BLEND_FACTOR_ONE_MINUS_DST_COLOR; - break; - case GL_SRC_ALPHA: - blend_dfactor_a = SCE_GXM_BLEND_FACTOR_SRC_ALPHA; - break; - case GL_ONE_MINUS_SRC_ALPHA: - blend_dfactor_a = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; - break; - case GL_DST_ALPHA: - blend_dfactor_a = SCE_GXM_BLEND_FACTOR_DST_ALPHA; - break; - case GL_ONE_MINUS_DST_ALPHA: - blend_dfactor_a = SCE_GXM_BLEND_FACTOR_ONE_MINUS_DST_ALPHA; - break; - case GL_SRC_ALPHA_SATURATE: - blend_dfactor_a = SCE_GXM_BLEND_FACTOR_SRC_ALPHA_SATURATE; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - if (blend_state) - change_blend_factor(); -} - -void glBlendEquation(GLenum mode) { - switch (mode) { - case GL_FUNC_ADD: - blend_func_rgb = blend_func_a = SCE_GXM_BLEND_FUNC_ADD; - break; - case GL_FUNC_SUBTRACT: - blend_func_rgb = blend_func_a = SCE_GXM_BLEND_FUNC_SUBTRACT; - break; - case GL_FUNC_REVERSE_SUBTRACT: - blend_func_rgb = blend_func_a = SCE_GXM_BLEND_FUNC_REVERSE_SUBTRACT; - break; - case GL_MIN: - blend_func_rgb = blend_func_a = SCE_GXM_BLEND_FUNC_MIN; - break; - case GL_MAX: - blend_func_rgb = blend_func_a = SCE_GXM_BLEND_FUNC_MAX; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - if (blend_state) - change_blend_factor(); -} - -void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) { - switch (modeRGB) { - case GL_FUNC_ADD: - blend_func_rgb = SCE_GXM_BLEND_FUNC_ADD; - break; - case GL_FUNC_SUBTRACT: - blend_func_rgb = SCE_GXM_BLEND_FUNC_SUBTRACT; - break; - case GL_FUNC_REVERSE_SUBTRACT: - blend_func_rgb = SCE_GXM_BLEND_FUNC_REVERSE_SUBTRACT; - break; - case GL_MIN: - blend_func_rgb = SCE_GXM_BLEND_FUNC_MIN; - break; - case GL_MAX: - blend_func_rgb = SCE_GXM_BLEND_FUNC_MAX; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - switch (modeAlpha) { - case GL_FUNC_ADD: - blend_func_a = SCE_GXM_BLEND_FUNC_ADD; - break; - case GL_FUNC_SUBTRACT: - blend_func_a = SCE_GXM_BLEND_FUNC_SUBTRACT; - break; - case GL_FUNC_REVERSE_SUBTRACT: - blend_func_a = SCE_GXM_BLEND_FUNC_REVERSE_SUBTRACT; - break; - case GL_MIN: - blend_func_a = SCE_GXM_BLEND_FUNC_MIN; - break; - case GL_MAX: - blend_func_a = SCE_GXM_BLEND_FUNC_MAX; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - if (blend_state) - change_blend_factor(); -} - -void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) { - blend_color_mask = SCE_GXM_COLOR_MASK_NONE; - if (red) - blend_color_mask += SCE_GXM_COLOR_MASK_R; - if (green) - blend_color_mask += SCE_GXM_COLOR_MASK_G; - if (blue) - blend_color_mask += SCE_GXM_COLOR_MASK_B; - if (alpha) - blend_color_mask += SCE_GXM_COLOR_MASK_A; - if (blend_state) - change_blend_factor(); - else - change_blend_mask(); -} - -void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) { -#ifndef SKIP_ERROR_HANDLING - if ((stride < 0) || ((size < 2) && (size > 4))) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - texture_unit *tex_unit = &texture_units[client_texture_unit]; - switch (type) { - case GL_FLOAT: - tex_unit->vertex_array.size = sizeof(GLfloat); - break; - case GL_SHORT: - tex_unit->vertex_array.size = sizeof(GLshort); - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - - tex_unit->vertex_array.num = size; - tex_unit->vertex_array.stride = stride; - tex_unit->vertex_array.pointer = pointer; -} - -void glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) { -#ifndef SKIP_ERROR_HANDLING - if ((stride < 0) || ((size < 3) && (size > 4))) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - texture_unit *tex_unit = &texture_units[client_texture_unit]; - switch (type) { - case GL_FLOAT: - tex_unit->color_array.size = sizeof(GLfloat); - break; - case GL_SHORT: - tex_unit->color_array.size = sizeof(GLshort); - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - - tex_unit->color_array.num = size; - tex_unit->color_array.stride = stride; - tex_unit->color_array.pointer = pointer; -} - -void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) { -#ifndef SKIP_ERROR_HANDLING - if ((stride < 0) || ((size < 2) && (size > 4))) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - texture_unit *tex_unit = &texture_units[client_texture_unit]; - switch (type) { - case GL_FLOAT: - tex_unit->texture_array.size = sizeof(GLfloat); - break; - case GL_SHORT: - tex_unit->texture_array.size = sizeof(GLshort); - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - - tex_unit->texture_array.num = size; - tex_unit->texture_array.stride = stride; - tex_unit->texture_array.pointer = pointer; -} - -void glDrawArrays(GLenum mode, GLint first, GLsizei count) { - texture_unit *tex_unit = &texture_units[client_texture_unit]; - int texture2d_idx = tex_unit->tex_id; - SceGxmPrimitiveType gxm_p; - GLboolean skip_draw = GL_FALSE; - if (tex_unit->vertex_array_state) { - switch (mode) { - case GL_POINTS: - gxm_p = SCE_GXM_PRIMITIVE_POINTS; - break; - case GL_LINES: - gxm_p = SCE_GXM_PRIMITIVE_LINES; - if ((count % 2) != 0) - skip_draw = GL_TRUE; - break; - case GL_TRIANGLES: - gxm_p = SCE_GXM_PRIMITIVE_TRIANGLES; - if (no_polygons_mode) - skip_draw = GL_TRUE; - else if ((count % 3) != 0) - skip_draw = GL_TRUE; - break; - case GL_TRIANGLE_STRIP: - gxm_p = SCE_GXM_PRIMITIVE_TRIANGLE_STRIP; - if (no_polygons_mode) - skip_draw = GL_TRUE; - break; - case GL_TRIANGLE_FAN: - gxm_p = SCE_GXM_PRIMITIVE_TRIANGLE_FAN; - if (no_polygons_mode) - skip_draw = GL_TRUE; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - if (!skip_draw) { - if (mvp_modified) { - matrix4x4_multiply(mvp_matrix, projection_matrix, modelview_matrix); - mvp_modified = GL_FALSE; - } - - if (tex_unit->texture_array_state) { - if (!(tex_unit->textures[texture2d_idx].valid)) - return; - if (tex_unit->color_array_state) { - sceGxmSetVertexProgram(gxm_context, texture2d_rgba_vertex_program_patched); - sceGxmSetFragmentProgram(gxm_context, texture2d_rgba_fragment_program_patched); - void *alpha_buffer; - sceGxmReserveFragmentDefaultUniformBuffer(gxm_context, &alpha_buffer); - sceGxmSetUniformDataF(alpha_buffer, texture2d_rgba_alpha_cut, 0, 1, &alpha_ref); - float alpha_operation = (float)alpha_op; - sceGxmSetUniformDataF(alpha_buffer, texture2d_rgba_alpha_op, 0, 1, &alpha_operation); - float env_mode = (float)tex_unit->env_mode; - sceGxmSetUniformDataF(alpha_buffer, texture2d_rgba_tex_env, 0, 1, &env_mode); - float fogmode = (float)internal_fog_mode; - sceGxmSetUniformDataF(alpha_buffer, texture2d_rgba_fog_mode, 0, 1, &fogmode); - sceGxmSetUniformDataF(alpha_buffer, texture2d_rgba_fog_color, 0, 4, &fog_color.r); - sceGxmSetUniformDataF(alpha_buffer, texture2d_rgba_tex_env_color, 0, 4, &texenv_color.r); - } else { - sceGxmSetVertexProgram(gxm_context, texture2d_vertex_program_patched); - sceGxmSetFragmentProgram(gxm_context, texture2d_fragment_program_patched); - void *alpha_buffer; - sceGxmReserveFragmentDefaultUniformBuffer(gxm_context, &alpha_buffer); - sceGxmSetUniformDataF(alpha_buffer, texture2d_alpha_cut, 0, 1, &alpha_ref); - float alpha_operation = (float)alpha_op; - sceGxmSetUniformDataF(alpha_buffer, texture2d_alpha_op, 0, 1, &alpha_operation); - sceGxmSetUniformDataF(alpha_buffer, texture2d_tint_color, 0, 4, ¤t_color.r); - float env_mode = (float)tex_unit->env_mode; - sceGxmSetUniformDataF(alpha_buffer, texture2d_tex_env, 0, 1, &env_mode); - float fogmode = (float)internal_fog_mode; - sceGxmSetUniformDataF(alpha_buffer, texture2d_fog_mode, 0, 1, &fogmode); - sceGxmSetUniformDataF(alpha_buffer, texture2d_fog_color, 0, 4, &fog_color.r); - sceGxmSetUniformDataF(alpha_buffer, texture2d_tex_env_color, 0, 4, &texenv_color.r); - } - } else if (tex_unit->color_array_state && (tex_unit->color_array.num == 3)) { - sceGxmSetVertexProgram(gxm_context, rgb_vertex_program_patched); - sceGxmSetFragmentProgram(gxm_context, rgba_fragment_program_patched); - } else { - sceGxmSetVertexProgram(gxm_context, rgba_vertex_program_patched); - sceGxmSetFragmentProgram(gxm_context, rgba_fragment_program_patched); - } - - void *vertex_wvp_buffer; - sceGxmReserveVertexDefaultUniformBuffer(gxm_context, &vertex_wvp_buffer); - - if (tex_unit->texture_array_state) { - float fogmode = (float)internal_fog_mode; - if (tex_unit->color_array_state) { - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_wvp, 0, 16, (const float *)mvp_matrix); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_fog_mode, 0, 1, (const float *)&fogmode); - float clipplane0 = (float)clip_plane0; - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_clip_plane0, 0, 1, &clipplane0); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_clip_plane0_eq, 0, 4, &clip_plane0_eq.x); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_mv, 0, 16, (const float *)modelview_matrix); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_fog_near, 0, 1, (const float *)&fog_near); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_fog_far, 0, 1, (const float *)&fog_far); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_fog_density, 0, 1, (const float *)&fog_density); - } else { - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_wvp, 0, 16, (const float *)mvp_matrix); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_fog_mode2, 0, 1, (const float *)&fogmode); - float clipplane0 = (float)clip_plane0; - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_clip_plane0, 0, 1, &clipplane0); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_clip_plane0_eq, 0, 4, &clip_plane0_eq.x); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_mv, 0, 16, (const float *)modelview_matrix); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_fog_near, 0, 1, (const float *)&fog_near); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_fog_far, 0, 1, (const float *)&fog_far); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_fog_density, 0, 1, (const float *)&fog_density); - } - sceGxmSetFragmentTexture(gxm_context, 0, &tex_unit->textures[texture2d_idx].gxm_tex); - vector3f *vertices = NULL; - vector2f *uv_map = NULL; - vector4f *colors = NULL; - uint16_t *indices; - uint16_t n; - if (vertex_array_unit >= 0) { - if (tex_unit->vertex_array.stride == 0) - vertices = (vector3f *)(((uint32_t)gpu_buffers[vertex_array_unit].ptr + (uint32_t)tex_unit->vertex_array.pointer) + (first * (tex_unit->vertex_array.num * tex_unit->vertex_array.size))); - else - vertices = (vector3f *)(((uint32_t)gpu_buffers[vertex_array_unit].ptr + (uint32_t)tex_unit->vertex_array.pointer) + (first * tex_unit->vertex_array.stride)); - if (tex_unit->texture_array.stride == 0) - uv_map = (vector2f *)(((uint32_t)gpu_buffers[vertex_array_unit].ptr + (uint32_t)tex_unit->texture_array.pointer) + (first * (tex_unit->texture_array.num * tex_unit->texture_array.size))); - else - uv_map = (vector2f *)(((uint32_t)gpu_buffers[vertex_array_unit].ptr + (uint32_t)tex_unit->texture_array.pointer) + (first * tex_unit->texture_array.stride)); - if (tex_unit->color_array_state) { - if (tex_unit->color_array.stride == 0) - colors = (vector4f *)(((uint32_t)gpu_buffers[vertex_array_unit].ptr + (uint32_t)tex_unit->color_array.pointer) + (first * (tex_unit->color_array.num * tex_unit->color_array.size))); - else - colors = (vector4f *)(((uint32_t)gpu_buffers[vertex_array_unit].ptr + (uint32_t)tex_unit->color_array.pointer) + (first * tex_unit->color_array.stride)); - } - indices = (uint16_t *)gpu_pool_memalign(count * sizeof(uint16_t), sizeof(uint16_t)); - for (n = 0; n < count; n++) { - indices[n] = n; - } - } else { - uint8_t *ptr; - uint8_t *ptr_tex; - uint8_t *ptr_clr; - vertices = (vector3f *)gpu_pool_memalign(count * sizeof(vector3f), sizeof(vector3f)); - uv_map = (vector2f *)gpu_pool_memalign(count * sizeof(vector2f), sizeof(vector2f)); - if (tex_unit->color_array_state) - colors = (vector4f *)gpu_pool_memalign(count * sizeof(vector4f), sizeof(vector4f)); - memset(vertices, 0, (count * sizeof(vector3f))); - uint8_t vec_set = 0, tex_set = 0, clr_set = 0; - if (tex_unit->vertex_array.stride == 0) { - ptr = ((uint8_t *)tex_unit->vertex_array.pointer) + (first * (tex_unit->vertex_array.num * tex_unit->vertex_array.size)); - memcpy(&vertices[n], ptr, count * sizeof(vector3f)); - vec_set = 1; - } else - ptr = ((uint8_t *)tex_unit->vertex_array.pointer) + (first * tex_unit->vertex_array.stride); - if (tex_unit->texture_array.stride == 0) { - ptr_tex = ((uint8_t *)tex_unit->texture_array.pointer) + (first * (tex_unit->texture_array.num * tex_unit->texture_array.size)); - memcpy(&uv_map[n], ptr_tex, count * sizeof(vector2f)); - tex_set = 1; - } else - ptr_tex = ((uint8_t *)tex_unit->texture_array.pointer) + (first * tex_unit->texture_array.stride); - if (tex_unit->color_array_state) { - if (tex_unit->color_array.stride == 0) { - ptr_clr = ((uint8_t *)tex_unit->color_array.pointer) + (first * sizeof(vector4f)); - memcpy(&colors[n], ptr_clr, count * sizeof(vector4f)); - clr_set = 1; - } else - ptr_clr = ((uint8_t *)tex_unit->color_array.pointer) + (first * tex_unit->color_array.stride); - } - indices = (uint16_t *)gpu_pool_memalign(count * sizeof(uint16_t), sizeof(uint16_t)); - for (n = 0; n < count; n++) { - if (!vec_set) { - memcpy(&vertices[n], ptr, tex_unit->vertex_array.size * tex_unit->vertex_array.num); - ptr += tex_unit->vertex_array.stride; - } - if (!tex_set) { - memcpy(&uv_map[n], ptr_tex, tex_unit->texture_array.size * tex_unit->texture_array.num); - ptr_tex += tex_unit->texture_array.stride; - } - if (tex_unit->color_array_state && (!clr_set)) { - memcpy(&colors[n], ptr_clr, tex_unit->color_array.size * tex_unit->color_array.num); - ptr_clr += tex_unit->color_array.stride; - } - indices[n] = n; - } - } - sceGxmSetVertexStream(gxm_context, 0, vertices); - sceGxmSetVertexStream(gxm_context, 1, uv_map); - if (tex_unit->color_array_state) - sceGxmSetVertexStream(gxm_context, 2, colors); - sceGxmDraw(gxm_context, gxm_p, SCE_GXM_INDEX_FORMAT_U16, indices, count); - } else if (tex_unit->color_array_state) { - if (tex_unit->color_array.num == 3) - sceGxmSetUniformDataF(vertex_wvp_buffer, rgb_wvp, 0, 16, (const float *)mvp_matrix); - else - sceGxmSetUniformDataF(vertex_wvp_buffer, rgba_wvp, 0, 16, (const float *)mvp_matrix); - vector3f *vertices = NULL; - uint8_t *colors = NULL; - uint16_t *indices; - uint16_t n = 0; - if (vertex_array_unit >= 0) { - if (tex_unit->vertex_array.stride == 0) - vertices = (vector3f *)(((uint32_t)gpu_buffers[vertex_array_unit].ptr + (uint32_t)tex_unit->vertex_array.pointer) + (first * (tex_unit->vertex_array.num * tex_unit->vertex_array.size))); - else - vertices = (vector3f *)(((uint32_t)gpu_buffers[vertex_array_unit].ptr + (uint32_t)tex_unit->vertex_array.pointer) + (first * tex_unit->vertex_array.stride)); - if (tex_unit->color_array.stride == 0) - colors = (uint8_t *)(((uint32_t)gpu_buffers[vertex_array_unit].ptr + (uint32_t)tex_unit->color_array.pointer) + (first * (tex_unit->color_array.num * tex_unit->color_array.size))); - else - colors = (uint8_t *)(((uint32_t)gpu_buffers[vertex_array_unit].ptr + (uint32_t)tex_unit->color_array.pointer) + (first * tex_unit->color_array.stride)); - indices = (uint16_t *)gpu_pool_memalign(count * sizeof(uint16_t), sizeof(uint16_t)); - for (n = 0; n < count; n++) { - indices[n] = n; - } - } else { - uint8_t *ptr; - uint8_t *ptr_clr; - vertices = (vector3f *)gpu_pool_memalign(count * sizeof(vector3f), sizeof(vector3f)); - colors = (uint8_t *)gpu_pool_memalign(count * tex_unit->color_array.num * tex_unit->color_array.size, tex_unit->color_array.num * tex_unit->color_array.size); - memset(vertices, 0, (count * sizeof(vector3f))); - uint8_t vec_set = 0, clr_set = 0; - if (tex_unit->vertex_array.stride == 0) { - ptr = ((uint8_t *)tex_unit->vertex_array.pointer) + (first * ((tex_unit->vertex_array.num * tex_unit->vertex_array.size))); - memcpy(&vertices[n], ptr, count * sizeof(vector3f)); - vec_set = 1; - } else - ptr = ((uint8_t *)tex_unit->vertex_array.pointer) + (first * (tex_unit->vertex_array.stride)); - if (tex_unit->color_array.stride == 0) { - ptr_clr = ((uint8_t *)tex_unit->color_array.pointer) + (first * ((tex_unit->color_array.num * tex_unit->color_array.size))); - memcpy(&colors[n], ptr_clr, count * tex_unit->color_array.num * tex_unit->color_array.size); - clr_set = 1; - } else - ptr_clr = ((uint8_t *)tex_unit->color_array.pointer) + (first * tex_unit->color_array.size); - indices = (uint16_t *)gpu_pool_memalign(count * sizeof(uint16_t), sizeof(uint16_t)); - for (n = 0; n < count; n++) { - if (!vec_set) { - memcpy(&vertices[n], ptr, tex_unit->vertex_array.size * tex_unit->vertex_array.num); - ptr += tex_unit->vertex_array.stride; - } - if (!clr_set) { - memcpy(&colors[n * tex_unit->color_array.num * tex_unit->color_array.size], ptr_clr, tex_unit->color_array.size * tex_unit->color_array.num); - ptr_clr += tex_unit->color_array.stride; - } - indices[n] = n; - } - } - sceGxmSetVertexStream(gxm_context, 0, vertices); - sceGxmSetVertexStream(gxm_context, 1, colors); - sceGxmDraw(gxm_context, gxm_p, SCE_GXM_INDEX_FORMAT_U16, indices, count); - } else { - sceGxmSetUniformDataF(vertex_wvp_buffer, rgba_wvp, 0, 16, (const float *)mvp_matrix); - vector3f *vertices = NULL; - vector4f *colors = NULL; - uint16_t *indices; - uint16_t n = 0; - if (vertex_array_unit >= 0) { - if (tex_unit->vertex_array.stride == 0) - vertices = (vector3f *)(((uint32_t)gpu_buffers[vertex_array_unit].ptr + (uint32_t)tex_unit->vertex_array.pointer) + (first * (tex_unit->vertex_array.num * tex_unit->vertex_array.size))); - else - vertices = (vector3f *)(((uint32_t)gpu_buffers[vertex_array_unit].ptr + (uint32_t)tex_unit->vertex_array.pointer) + (first * tex_unit->vertex_array.stride)); - colors = (vector4f *)gpu_pool_memalign(count * sizeof(vector4f), sizeof(vector4f)); - indices = (uint16_t *)gpu_pool_memalign(count * sizeof(uint16_t), sizeof(uint16_t)); - for (n = 0; n < count; n++) { - memcpy(&colors[n], ¤t_color.r, sizeof(vector4f)); - indices[n] = n; - } - } else { - uint8_t *ptr; - vertices = (vector3f *)gpu_pool_memalign(count * sizeof(vector3f), sizeof(vector3f)); - colors = (vector4f *)gpu_pool_memalign(count * sizeof(vector4f), sizeof(vector4f)); - memset(vertices, 0, (count * sizeof(vector3f))); - uint8_t vec_set = 0; - if (tex_unit->vertex_array.stride == 0) { - ptr = ((uint8_t *)tex_unit->vertex_array.pointer) + (first * ((tex_unit->vertex_array.num * tex_unit->vertex_array.size))); - memcpy(&vertices[n], ptr, count * sizeof(vector3f)); - vec_set = 1; - } else - ptr = ((uint8_t *)tex_unit->vertex_array.pointer) + (first * (tex_unit->vertex_array.stride)); - indices = (uint16_t *)gpu_pool_memalign(count * sizeof(uint16_t), sizeof(uint16_t)); - for (n = 0; n < count; n++) { - if (!vec_set) { - memcpy(&vertices[n], ptr, tex_unit->vertex_array.size * tex_unit->vertex_array.num); - ptr += tex_unit->vertex_array.stride; - } - memcpy(&colors[n], ¤t_color.r, sizeof(vector4f)); - indices[n] = n; - } - } - sceGxmSetVertexStream(gxm_context, 0, vertices); - sceGxmSetVertexStream(gxm_context, 1, colors); - sceGxmDraw(gxm_context, gxm_p, SCE_GXM_INDEX_FORMAT_U16, indices, count); - } - } - } -} - -void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *gl_indices) { - SceGxmPrimitiveType gxm_p; - SceGxmPrimitiveTypeExtra gxm_ep = SCE_GXM_PRIMITIVE_NONE; - texture_unit *tex_unit = &texture_units[client_texture_unit]; - int texture2d_idx = tex_unit->tex_id; - GLboolean skip_draw = GL_FALSE; - if (tex_unit->vertex_array_state) { -#ifndef SKIP_ERROR_HANDLING - if (type != GL_UNSIGNED_SHORT) - _vitagl_error = GL_INVALID_ENUM; - else if (phase == MODEL_CREATION) - _vitagl_error = GL_INVALID_OPERATION; - else if (count < 0) - _vitagl_error = GL_INVALID_VALUE; -#endif - switch (mode) { - case GL_POINTS: - gxm_p = SCE_GXM_PRIMITIVE_POINTS; - break; - case GL_LINES: - gxm_p = SCE_GXM_PRIMITIVE_LINES; - break; - case GL_TRIANGLES: - gxm_p = SCE_GXM_PRIMITIVE_TRIANGLES; - if (no_polygons_mode) - skip_draw = GL_TRUE; - break; - case GL_TRIANGLE_STRIP: - gxm_p = SCE_GXM_PRIMITIVE_TRIANGLE_STRIP; - if (no_polygons_mode) - skip_draw = GL_TRUE; - break; - case GL_TRIANGLE_FAN: - gxm_p = SCE_GXM_PRIMITIVE_TRIANGLE_FAN; - if (no_polygons_mode) - skip_draw = GL_TRUE; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - if (!skip_draw) { - if (mvp_modified) { - matrix4x4_multiply(mvp_matrix, projection_matrix, modelview_matrix); - mvp_modified = GL_FALSE; - } - - if (tex_unit->texture_array_state) { - if (!(tex_unit->textures[texture2d_idx].valid)) - return; - if (tex_unit->color_array_state) { - sceGxmSetVertexProgram(gxm_context, texture2d_rgba_vertex_program_patched); - sceGxmSetFragmentProgram(gxm_context, texture2d_rgba_fragment_program_patched); - void *alpha_buffer; - sceGxmReserveFragmentDefaultUniformBuffer(gxm_context, &alpha_buffer); - sceGxmSetUniformDataF(alpha_buffer, texture2d_rgba_alpha_cut, 0, 1, &alpha_ref); - float alpha_operation = (float)alpha_op; - sceGxmSetUniformDataF(alpha_buffer, texture2d_rgba_alpha_op, 0, 1, &alpha_operation); - float env_mode = (float)tex_unit->env_mode; - sceGxmSetUniformDataF(alpha_buffer, texture2d_rgba_tex_env, 0, 1, &env_mode); - float fogmode = (float)internal_fog_mode; - sceGxmSetUniformDataF(alpha_buffer, texture2d_rgba_fog_mode, 0, 1, &fogmode); - sceGxmSetUniformDataF(alpha_buffer, texture2d_rgba_fog_color, 0, 4, &fog_color.r); - sceGxmSetUniformDataF(alpha_buffer, texture2d_rgba_tex_env_color, 0, 4, &texenv_color.r); - } else { - sceGxmSetVertexProgram(gxm_context, texture2d_vertex_program_patched); - sceGxmSetFragmentProgram(gxm_context, texture2d_fragment_program_patched); - void *alpha_buffer; - sceGxmReserveFragmentDefaultUniformBuffer(gxm_context, &alpha_buffer); - sceGxmSetUniformDataF(alpha_buffer, texture2d_alpha_cut, 0, 1, &alpha_ref); - float alpha_operation = (float)alpha_op; - sceGxmSetUniformDataF(alpha_buffer, texture2d_alpha_op, 0, 1, &alpha_operation); - sceGxmSetUniformDataF(alpha_buffer, texture2d_tint_color, 0, 4, ¤t_color.r); - float env_mode = (float)tex_unit->env_mode; - sceGxmSetUniformDataF(alpha_buffer, texture2d_tex_env, 0, 1, &env_mode); - float fogmode = (float)internal_fog_mode; - sceGxmSetUniformDataF(alpha_buffer, texture2d_fog_mode, 0, 1, &fogmode); - sceGxmSetUniformDataF(alpha_buffer, texture2d_fog_color, 0, 4, &fog_color.r); - sceGxmSetUniformDataF(alpha_buffer, texture2d_tex_env_color, 0, 4, &texenv_color.r); - } - } else if (tex_unit->color_array_state && (tex_unit->color_array.num == 3)) { - sceGxmSetVertexProgram(gxm_context, rgb_vertex_program_patched); - sceGxmSetFragmentProgram(gxm_context, rgba_fragment_program_patched); - } else { - sceGxmSetVertexProgram(gxm_context, rgba_vertex_program_patched); - sceGxmSetFragmentProgram(gxm_context, rgba_fragment_program_patched); - } - - void *vertex_wvp_buffer; - sceGxmReserveVertexDefaultUniformBuffer(gxm_context, &vertex_wvp_buffer); - - if (tex_unit->texture_array_state) { - float fogmode = (float)internal_fog_mode; - if (tex_unit->color_array_state) { - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_wvp, 0, 16, (const float *)mvp_matrix); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_fog_mode, 0, 1, (const float *)&fogmode); - float clipplane0 = (float)clip_plane0; - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_clip_plane0, 0, 1, &clipplane0); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_clip_plane0_eq, 0, 4, &clip_plane0_eq.x); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_mv, 0, 16, (const float *)modelview_matrix); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_fog_near, 0, 1, (const float *)&fog_near); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_fog_far, 0, 1, (const float *)&fog_far); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_fog_density, 0, 1, (const float *)&fog_density); - } else { - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_wvp, 0, 16, (const float *)mvp_matrix); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_fog_mode2, 0, 1, (const float *)&fogmode); - float clipplane0 = (float)clip_plane0; - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_clip_plane0, 0, 1, &clipplane0); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_clip_plane0_eq, 0, 4, &clip_plane0_eq.x); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_mv, 0, 16, (const float *)modelview_matrix); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_fog_near, 0, 1, (const float *)&fog_near); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_fog_far, 0, 1, (const float *)&fog_far); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_fog_density, 0, 1, (const float *)&fog_density); - } - sceGxmSetFragmentTexture(gxm_context, 0, &texture_units[client_texture_unit].textures[texture2d_idx].gxm_tex); - vector3f *vertices = NULL; - vector2f *uv_map = NULL; - vector4f *colors = NULL; - uint16_t *indices; - if (index_array_unit >= 0) - indices = (uint16_t *)((uint32_t)gpu_buffers[index_array_unit].ptr + (uint32_t)gl_indices); - else { - indices = (uint16_t *)gpu_pool_memalign(count * sizeof(uint16_t), sizeof(uint16_t)); - memcpy(indices, gl_indices, sizeof(uint16_t) * count); - } - if (vertex_array_unit >= 0) { - vertices = (vector3f *)((uint32_t)gpu_buffers[vertex_array_unit].ptr + (uint32_t)tex_unit->vertex_array.pointer); - uv_map = (vector2f *)((uint32_t)gpu_buffers[vertex_array_unit].ptr + (uint32_t)tex_unit->texture_array.pointer); - if (tex_unit->color_array_state) - colors = (vector4f *)((uint32_t)gpu_buffers[vertex_array_unit].ptr + (uint32_t)tex_unit->color_array.pointer); - } else { - int n = 0, j = 0; - uint64_t vertex_count_int = 0; - uint16_t *ptr_idx = (uint16_t *)gl_indices; - while (j < count) { - if (ptr_idx[j] >= vertex_count_int) - vertex_count_int = ptr_idx[j] + 1; - j++; - } - vertices = (vector3f *)gpu_pool_memalign(vertex_count_int * sizeof(vector3f), sizeof(vector3f)); - uv_map = (vector2f *)gpu_pool_memalign(vertex_count_int * sizeof(vector2f), sizeof(vector2f)); - colors = (vector4f *)gpu_pool_memalign(vertex_count_int * sizeof(vector4f), sizeof(vector4f)); - if (tex_unit->vertex_array.stride == 0) - memcpy(vertices, tex_unit->vertex_array.pointer, vertex_count_int * (tex_unit->vertex_array.size * tex_unit->vertex_array.num)); - if (tex_unit->texture_array.stride == 0) - memcpy(uv_map, tex_unit->texture_array.pointer, vertex_count_int * (tex_unit->texture_array.size * tex_unit->texture_array.num)); - if (tex_unit->color_array_state && (tex_unit->color_array.stride == 0)) - memcpy(colors, tex_unit->color_array.pointer, vertex_count_int * (tex_unit->color_array.size * tex_unit->color_array.num)); - if ((tex_unit->vertex_array.stride != 0) || (tex_unit->texture_array.stride != 0)) { - if (tex_unit->vertex_array.stride != 0) - memset(vertices, 0, (vertex_count_int * sizeof(texture2d_vertex))); - uint8_t *ptr = ((uint8_t *)tex_unit->vertex_array.pointer); - uint8_t *ptr_tex = ((uint8_t *)tex_unit->texture_array.pointer); - for (n = 0; n < vertex_count_int; n++) { - if (tex_unit->vertex_array.stride != 0) - memcpy(&vertices[n], ptr, tex_unit->vertex_array.size * tex_unit->vertex_array.num); - if (tex_unit->texture_array.stride != 0) - memcpy(&uv_map[n], ptr_tex, tex_unit->texture_array.size * tex_unit->texture_array.num); - ptr += tex_unit->vertex_array.stride; - ptr_tex += tex_unit->texture_array.stride; - } - } - } - sceGxmSetVertexStream(gxm_context, 0, vertices); - sceGxmSetVertexStream(gxm_context, 1, uv_map); - if (tex_unit->color_array_state) - sceGxmSetVertexStream(gxm_context, 2, colors); - sceGxmDraw(gxm_context, gxm_p, SCE_GXM_INDEX_FORMAT_U16, indices, count); - } else if (tex_unit->color_array_state) { - if (tex_unit->color_array.num == 3) - sceGxmSetUniformDataF(vertex_wvp_buffer, rgb_wvp, 0, 16, (const float *)mvp_matrix); - else - sceGxmSetUniformDataF(vertex_wvp_buffer, rgba_wvp, 0, 16, (const float *)mvp_matrix); - vector3f *vertices = NULL; - uint8_t *colors = NULL; - uint16_t *indices; - if (index_array_unit >= 0) - indices = (uint16_t *)((uint32_t)gpu_buffers[index_array_unit].ptr + (uint32_t)gl_indices); - else { - indices = (uint16_t *)gpu_pool_memalign(count * sizeof(uint16_t), sizeof(uint16_t)); - memcpy(indices, gl_indices, sizeof(uint16_t) * count); - } - if (vertex_array_unit >= 0) { - colors = (uint8_t *)((uint32_t)gpu_buffers[vertex_array_unit].ptr + (uint32_t)tex_unit->color_array.pointer); - vertices = (vector3f *)((uint32_t)gpu_buffers[vertex_array_unit].ptr + (uint32_t)tex_unit->vertex_array.pointer); - } else { - int n = 0, j = 0; - uint64_t vertex_count_int = 0; - uint16_t *ptr_idx = (uint16_t *)gl_indices; - while (j < count) { - if (ptr_idx[j] >= vertex_count_int) - vertex_count_int = ptr_idx[j] + 1; - j++; - } - vertices = (vector3f *)gpu_pool_memalign(vertex_count_int * sizeof(vector3f), sizeof(vector3f)); - colors = (uint8_t *)gpu_pool_memalign(vertex_count_int * tex_unit->color_array.num * tex_unit->color_array.size, tex_unit->color_array.num * tex_unit->color_array.size); - if (tex_unit->vertex_array.stride == 0) - memcpy(vertices, tex_unit->vertex_array.pointer, vertex_count_int * (tex_unit->vertex_array.size * tex_unit->vertex_array.num)); - if (tex_unit->color_array.stride == 0) - memcpy(colors, tex_unit->color_array.pointer, vertex_count_int * (tex_unit->color_array.size * tex_unit->color_array.num)); - if ((tex_unit->vertex_array.stride != 0) || (tex_unit->color_array.stride != 0)) { - if (tex_unit->vertex_array.stride != 0) - memset(vertices, 0, (vertex_count_int * sizeof(texture2d_vertex))); - uint8_t *ptr = ((uint8_t *)tex_unit->vertex_array.pointer); - uint8_t *ptr_clr = ((uint8_t *)tex_unit->color_array.pointer); - for (n = 0; n < vertex_count_int; n++) { - if (tex_unit->vertex_array.stride != 0) - memcpy(&vertices[n], ptr, tex_unit->vertex_array.size * tex_unit->vertex_array.num); - if (tex_unit->color_array.stride != 0) - memcpy(&colors[n * tex_unit->color_array.num * tex_unit->color_array.size], ptr_clr, tex_unit->color_array.size * tex_unit->color_array.num); - ptr += tex_unit->vertex_array.stride; - ptr_clr += tex_unit->color_array.stride; - } - } - } - sceGxmSetVertexStream(gxm_context, 0, vertices); - sceGxmSetVertexStream(gxm_context, 1, colors); - sceGxmDraw(gxm_context, gxm_p, SCE_GXM_INDEX_FORMAT_U16, indices, count); - } else { - sceGxmSetUniformDataF(vertex_wvp_buffer, rgba_wvp, 0, 16, (const float *)mvp_matrix); - vector3f *vertices = NULL; - vector4f *colors = NULL; - uint16_t *indices; - if (index_array_unit >= 0) - indices = (uint16_t *)((uint32_t)gpu_buffers[index_array_unit].ptr + (uint32_t)gl_indices); - else { - indices = (uint16_t *)gpu_pool_memalign(count * sizeof(uint16_t), sizeof(uint16_t)); - memcpy(indices, gl_indices, sizeof(uint16_t) * count); - } - int n = 0, j = 0; - uint64_t vertex_count_int = 0; - uint16_t *ptr_idx = (uint16_t *)gl_indices; - while (j < count) { - if (ptr_idx[j] >= vertex_count_int) - vertex_count_int = ptr_idx[j] + 1; - j++; - } - if (vertex_array_unit >= 0) - vertices = (vector3f *)((uint32_t)gpu_buffers[vertex_array_unit].ptr + (uint32_t)tex_unit->vertex_array.pointer); - else - vertices = (vector3f *)gpu_pool_memalign(vertex_count_int * sizeof(vector3f), sizeof(vector3f)); - colors = (vector4f *)gpu_pool_memalign(vertex_count_int * tex_unit->color_array.num * tex_unit->color_array.size, tex_unit->color_array.num * tex_unit->color_array.size); - if ((!vertex_array_unit) && tex_unit->vertex_array.stride == 0) - memcpy(vertices, tex_unit->vertex_array.pointer, vertex_count_int * (tex_unit->vertex_array.size * tex_unit->vertex_array.num)); - if ((!vertex_array_unit) && tex_unit->vertex_array.stride != 0) - memset(vertices, 0, (vertex_count_int * sizeof(texture2d_vertex))); - uint8_t *ptr = ((uint8_t *)tex_unit->vertex_array.pointer); - for (n = 0; n < vertex_count_int; n++) { - if ((!vertex_array_unit) && tex_unit->vertex_array.stride != 0) - memcpy(&vertices[n], ptr, tex_unit->vertex_array.size * tex_unit->vertex_array.num); - memcpy(&colors[n], ¤t_color.r, sizeof(vector4f)); - if (!vertex_array_unit) - ptr += tex_unit->vertex_array.stride; - } - sceGxmSetVertexStream(gxm_context, 0, vertices); - sceGxmSetVertexStream(gxm_context, 1, colors); - sceGxmDraw(gxm_context, gxm_p, SCE_GXM_INDEX_FORMAT_U16, indices, count); - } - } - } -} - -void glEnableClientState(GLenum array) { - texture_unit *tex_unit = &texture_units[client_texture_unit]; - switch (array) { - case GL_VERTEX_ARRAY: - tex_unit->vertex_array_state = GL_TRUE; - break; - case GL_COLOR_ARRAY: - tex_unit->color_array_state = GL_TRUE; - break; - case GL_TEXTURE_COORD_ARRAY: - tex_unit->texture_array_state = GL_TRUE; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} - -void glDisableClientState(GLenum array) { - texture_unit *tex_unit = &texture_units[client_texture_unit]; - switch (array) { - case GL_VERTEX_ARRAY: - tex_unit->vertex_array_state = GL_FALSE; - break; - case GL_COLOR_ARRAY: - tex_unit->color_array_state = GL_FALSE; - break; - case GL_TEXTURE_COORD_ARRAY: - tex_unit->texture_array_state = GL_FALSE; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } -} - -void glClientActiveTexture(GLenum texture) { -#ifndef SKIP_ERROR_HANDLING - if ((texture < GL_TEXTURE0) && (texture > GL_TEXTURE31)) - _vitagl_error = GL_INVALID_ENUM; - else -#endif - client_texture_unit = texture - GL_TEXTURE0; -} - -// VGL_EXT_gpu_objects_array extension implementation - -void vglVertexPointer(GLint size, GLenum type, GLsizei stride, GLuint count, const GLvoid *pointer) { -#ifndef SKIP_ERROR_HANDLING - if ((stride < 0) || ((size < 2) && (size > 4))) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - texture_unit *tex_unit = &texture_units[client_texture_unit]; - int bpe; - switch (type) { - case GL_FLOAT: - bpe = sizeof(GLfloat); - break; - case GL_SHORT: - bpe = sizeof(GLshort); - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - tex_unit->vertex_object = gpu_pool_memalign(count * bpe * size, bpe * size); - if (stride == 0) - memcpy(tex_unit->vertex_object, pointer, count * bpe * size); - else { - int i; - uint8_t *dst = (uint8_t *)tex_unit->vertex_object; - uint8_t *src = (uint8_t *)pointer; - for (i = 0; i < count; i++) { - memcpy(dst, src, bpe * size); - dst += (bpe * size); - src += stride; - } - } -} - -void vglColorPointer(GLint size, GLenum type, GLsizei stride, GLuint count, const GLvoid *pointer) { -#ifndef SKIP_ERROR_HANDLING - if ((stride < 0) || ((size < 3) && (size > 4))) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - texture_unit *tex_unit = &texture_units[client_texture_unit]; - int bpe; - switch (type) { - case GL_FLOAT: - bpe = sizeof(GLfloat); - break; - case GL_SHORT: - bpe = sizeof(GLshort); - break; - case GL_UNSIGNED_BYTE: - bpe = sizeof(uint8_t); - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - tex_unit->color_object = gpu_pool_memalign(count * bpe * size, bpe * size); - tex_unit->color_object_type = type; - if (stride == 0) - memcpy(tex_unit->color_object, pointer, count * bpe * size); - else { - int i; - uint8_t *dst = (uint8_t *)tex_unit->color_object; - uint8_t *src = (uint8_t *)pointer; - for (i = 0; i < count; i++) { - memcpy(dst, src, bpe * size); - dst += (bpe * size); - src += stride; - } - } -} - -void vglTexCoordPointer(GLint size, GLenum type, GLsizei stride, GLuint count, const GLvoid *pointer) { -#ifndef SKIP_ERROR_HANDLING - if ((stride < 0) || ((size < 2) && (size > 4))) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - texture_unit *tex_unit = &texture_units[client_texture_unit]; - int bpe; - switch (type) { - case GL_FLOAT: - bpe = sizeof(GLfloat); - break; - case GL_SHORT: - bpe = sizeof(GLshort); - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - tex_unit->texture_object = gpu_pool_memalign(count * bpe * size, bpe * size); - if (stride == 0) - memcpy(tex_unit->texture_object, pointer, count * bpe * size); - else { - int i; - uint8_t *dst = (uint8_t *)tex_unit->texture_object; - uint8_t *src = (uint8_t *)pointer; - for (i = 0; i < count; i++) { - memcpy(dst, src, bpe * size); - dst += (bpe * size); - src += stride; - } - } -} - -void vglIndexPointer(GLenum type, GLsizei stride, GLuint count, const GLvoid *pointer) { -#ifndef SKIP_ERROR_HANDLING - if (stride < 0) { - _vitagl_error = GL_INVALID_VALUE; - return; - } -#endif - texture_unit *tex_unit = &texture_units[client_texture_unit]; - int bpe; - switch (type) { - case GL_FLOAT: - bpe = sizeof(GLfloat); - break; - case GL_SHORT: - bpe = sizeof(GLshort); - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - tex_unit->index_object = gpu_pool_memalign(count * bpe, bpe); - if (stride == 0) - memcpy(tex_unit->index_object, pointer, count * bpe); - else { - int i; - uint8_t *dst = (uint8_t *)tex_unit->index_object; - uint8_t *src = (uint8_t *)pointer; - for (i = 0; i < count; i++) { - memcpy(dst, src, bpe); - dst += bpe; - src += stride; - } - } -} - -void vglVertexPointerMapped(const GLvoid *pointer) { - texture_unit *tex_unit = &texture_units[client_texture_unit]; - tex_unit->vertex_object = (GLvoid *)pointer; -} - -void vglColorPointerMapped(GLenum type, const GLvoid *pointer) { - texture_unit *tex_unit = &texture_units[client_texture_unit]; - tex_unit->color_object = (GLvoid *)pointer; - tex_unit->color_object_type = type; -} - -void vglTexCoordPointerMapped(const GLvoid *pointer) { - texture_unit *tex_unit = &texture_units[client_texture_unit]; - tex_unit->texture_object = (GLvoid *)pointer; -} - -void vglIndexPointerMapped(const GLvoid *pointer) { - texture_unit *tex_unit = &texture_units[client_texture_unit]; - tex_unit->index_object = (GLvoid *)pointer; -} - -void vglDrawObjects(GLenum mode, GLsizei count, GLboolean implicit_wvp) { - SceGxmPrimitiveType gxm_p; - texture_unit *tex_unit = &texture_units[client_texture_unit]; - int texture2d_idx = tex_unit->tex_id; -#ifndef SKIP_ERROR_HANDLING - if (phase == MODEL_CREATION) - _vitagl_error = GL_INVALID_OPERATION; - else if (count < 0) - _vitagl_error = GL_INVALID_VALUE; -#endif - GLboolean skip_draw = GL_FALSE; - switch (mode) { - case GL_POINTS: - gxm_p = SCE_GXM_PRIMITIVE_POINTS; - break; - case GL_LINES: - gxm_p = SCE_GXM_PRIMITIVE_LINES; - break; - case GL_TRIANGLES: - gxm_p = SCE_GXM_PRIMITIVE_TRIANGLES; - if (no_polygons_mode) - skip_draw = GL_TRUE; - break; - case GL_TRIANGLE_STRIP: - gxm_p = SCE_GXM_PRIMITIVE_TRIANGLE_STRIP; - if (no_polygons_mode) - skip_draw = GL_TRUE; - break; - case GL_TRIANGLE_FAN: - gxm_p = SCE_GXM_PRIMITIVE_TRIANGLE_FAN; - if (no_polygons_mode) - skip_draw = GL_TRUE; - break; - default: - _vitagl_error = GL_INVALID_ENUM; - break; - } - if (!skip_draw) { - if (cur_program != 0) { - _vglDrawObjects_CustomShadersIMPL(mode, count, implicit_wvp); - sceGxmSetFragmentTexture(gxm_context, 0, &tex_unit->textures[texture2d_idx].gxm_tex); - sceGxmDraw(gxm_context, gxm_p, SCE_GXM_INDEX_FORMAT_U16, tex_unit->index_object, count); - vert_uniforms = NULL; - frag_uniforms = NULL; - } else { - if (tex_unit->vertex_array_state) { - if (mvp_modified) { - matrix4x4_multiply(mvp_matrix, projection_matrix, modelview_matrix); - mvp_modified = GL_FALSE; - } - if (tex_unit->texture_array_state) { - if (!(tex_unit->textures[texture2d_idx].valid)) - return; - if (tex_unit->color_array_state) { - if (tex_unit->color_object_type == GL_FLOAT) - sceGxmSetVertexProgram(gxm_context, texture2d_rgba_vertex_program_patched); - else - sceGxmSetVertexProgram(gxm_context, texture2d_rgba_u8n_vertex_program_patched); - sceGxmSetFragmentProgram(gxm_context, texture2d_rgba_fragment_program_patched); - void *alpha_buffer; - sceGxmReserveFragmentDefaultUniformBuffer(gxm_context, &alpha_buffer); - sceGxmSetUniformDataF(alpha_buffer, texture2d_rgba_alpha_cut, 0, 1, &alpha_ref); - float alpha_operation = (float)alpha_op; - sceGxmSetUniformDataF(alpha_buffer, texture2d_rgba_alpha_op, 0, 1, &alpha_operation); - float env_mode = (float)tex_unit->env_mode; - sceGxmSetUniformDataF(alpha_buffer, texture2d_rgba_tex_env, 0, 1, &env_mode); - float fogmode = (float)internal_fog_mode; - sceGxmSetUniformDataF(alpha_buffer, texture2d_rgba_fog_mode, 0, 1, &fogmode); - sceGxmSetUniformDataF(alpha_buffer, texture2d_rgba_fog_color, 0, 4, &fog_color.r); - sceGxmSetUniformDataF(alpha_buffer, texture2d_rgba_tex_env_color, 0, 4, &texenv_color.r); - } else { - sceGxmSetVertexProgram(gxm_context, texture2d_vertex_program_patched); - sceGxmSetFragmentProgram(gxm_context, texture2d_fragment_program_patched); - void *alpha_buffer; - sceGxmReserveFragmentDefaultUniformBuffer(gxm_context, &alpha_buffer); - sceGxmSetUniformDataF(alpha_buffer, texture2d_alpha_cut, 0, 1, &alpha_ref); - float alpha_operation = (float)alpha_op; - sceGxmSetUniformDataF(alpha_buffer, texture2d_alpha_op, 0, 1, &alpha_operation); - sceGxmSetUniformDataF(alpha_buffer, texture2d_tint_color, 0, 4, ¤t_color.r); - float env_mode = (float)tex_unit->env_mode; - sceGxmSetUniformDataF(alpha_buffer, texture2d_tex_env, 0, 1, &env_mode); - float fogmode = (float)internal_fog_mode; - sceGxmSetUniformDataF(alpha_buffer, texture2d_fog_mode, 0, 1, &fogmode); - sceGxmSetUniformDataF(alpha_buffer, texture2d_fog_color, 0, 4, &fog_color.r); - sceGxmSetUniformDataF(alpha_buffer, texture2d_tint_color, 0, 4, ¤t_color.r); - sceGxmSetUniformDataF(alpha_buffer, texture2d_tex_env_color, 0, 4, &texenv_color.r); - } - } else if (tex_unit->color_array_state && (tex_unit->color_array.num == 3)) { - if (tex_unit->color_object_type == GL_FLOAT) - sceGxmSetVertexProgram(gxm_context, rgb_vertex_program_patched); - else - sceGxmSetVertexProgram(gxm_context, rgb_u8n_vertex_program_patched); - sceGxmSetFragmentProgram(gxm_context, rgba_fragment_program_patched); - } else { - if (tex_unit->color_object_type == GL_FLOAT) - sceGxmSetVertexProgram(gxm_context, rgba_vertex_program_patched); - else - sceGxmSetVertexProgram(gxm_context, rgba_u8n_vertex_program_patched); - sceGxmSetFragmentProgram(gxm_context, rgba_fragment_program_patched); - } - void *vertex_wvp_buffer; - sceGxmReserveVertexDefaultUniformBuffer(gxm_context, &vertex_wvp_buffer); - if (tex_unit->texture_array_state) { - float fogmode = (float)internal_fog_mode; - if (tex_unit->color_array_state) { - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_wvp, 0, 16, (const float *)mvp_matrix); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_fog_mode2, 0, 1, (const float *)&fogmode); - float clipplane0 = (float)clip_plane0; - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_clip_plane0, 0, 1, &clipplane0); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_clip_plane0_eq, 0, 4, &clip_plane0_eq.x); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_mv, 0, 16, (const float *)modelview_matrix); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_fog_near, 0, 1, (const float *)&fog_near); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_fog_far, 0, 1, (const float *)&fog_far); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_rgba_fog_density, 0, 1, (const float *)&fog_density); - } else { - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_wvp, 0, 16, (const float *)mvp_matrix); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_fog_mode2, 0, 1, (const float *)&fogmode); - float clipplane0 = (float)clip_plane0; - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_clip_plane0, 0, 1, &clipplane0); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_clip_plane0_eq, 0, 4, &clip_plane0_eq.x); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_mv, 0, 16, (const float *)modelview_matrix); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_fog_near, 0, 1, (const float *)&fog_near); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_fog_far, 0, 1, (const float *)&fog_far); - sceGxmSetUniformDataF(vertex_wvp_buffer, texture2d_fog_density, 0, 1, (const float *)&fog_density); - } - sceGxmSetFragmentTexture(gxm_context, 0, &tex_unit->textures[texture2d_idx].gxm_tex); - sceGxmSetVertexStream(gxm_context, 0, tex_unit->vertex_object); - sceGxmSetVertexStream(gxm_context, 1, tex_unit->texture_object); - if (tex_unit->color_array_state) - sceGxmSetVertexStream(gxm_context, 2, tex_unit->color_object); - sceGxmDraw(gxm_context, gxm_p, SCE_GXM_INDEX_FORMAT_U16, tex_unit->index_object, count); - } else if (tex_unit->color_array_state) { - if (tex_unit->color_array.num == 3) - sceGxmSetUniformDataF(vertex_wvp_buffer, rgb_wvp, 0, 16, (const float *)mvp_matrix); - else - sceGxmSetUniformDataF(vertex_wvp_buffer, rgba_wvp, 0, 16, (const float *)mvp_matrix); - sceGxmSetVertexStream(gxm_context, 0, tex_unit->vertex_object); - sceGxmSetVertexStream(gxm_context, 1, tex_unit->color_object); - sceGxmDraw(gxm_context, gxm_p, SCE_GXM_INDEX_FORMAT_U16, tex_unit->index_object, count); - } else { - sceGxmSetUniformDataF(vertex_wvp_buffer, rgba_wvp, 0, 16, (const float *)mvp_matrix); - vector4f *colors = (vector4f *)gpu_pool_memalign(count * sizeof(vector4f), sizeof(vector4f)); - int n; - for (n = 0; n < count; n++) { - memcpy(&colors[n], ¤t_color.r, sizeof(vector4f)); - } - sceGxmSetVertexStream(gxm_context, 0, tex_unit->vertex_object); - sceGxmSetVertexStream(gxm_context, 1, colors); - sceGxmDraw(gxm_context, gxm_p, SCE_GXM_INDEX_FORMAT_U16, tex_unit->index_object, count); - } - } - } - } -} - -size_t vglMemFree(vglMemType type) { - if (type >= VGL_MEM_TYPE_COUNT) - return 0; - return vitagl_mempool_get_free_space(type); -} - -void *vglAlloc(uint32_t size, vglMemType type) { - if (type >= VGL_MEM_TYPE_COUNT) - return NULL; - return vitagl_mempool_alloc(size, type); -} - -void vglFree(void *addr) { - vitagl_mempool_free(addr, VGL_MEM_RAM); // Type is discarded so we just pass a random one -} diff --git a/deps/vitaGL/source/vitaGL.h b/deps/vitaGL/source/vitaGL.h deleted file mode 100644 index 32b1205968..0000000000 --- a/deps/vitaGL/source/vitaGL.h +++ /dev/null @@ -1,386 +0,0 @@ -#ifndef _VITAGL_H_ -#define _VITAGL_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -// clang-format off -#define GLfloat float -#define GLint int32_t -#define GLdouble double -#define GLshort int16_t -#define GLuint uint32_t -#define GLsizei int32_t -#define GLenum uint16_t -#define GLubyte uint8_t -#define GLvoid void -#define GLbyte int8_t -#define GLboolean uint8_t -#define GLchar char - -#define GL_FALSE 0 -#define GL_TRUE 1 - -#define GL_NO_ERROR 0 - -#define GL_ZERO 0 -#define GL_ONE 1 - -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 -#define GL_QUADS 0x0007 -#define GL_ADD 0x0104 -#define GL_NEVER 0x0200 -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_FRONT_AND_BACK 0x0408 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_STACK_OVERFLOW 0x0503 -#define GL_STACK_UNDERFLOW 0x0504 -#define GL_OUT_OF_MEMORY 0x0505 -#define GL_EXP 0x0800 -#define GL_EXP2 0x0801 -#define GL_CW 0x0900 -#define GL_CCW 0x0901 -#define GL_POLYGON_MODE 0x0B40 -#define GL_CULL_FACE 0x0B44 -#define GL_FOG 0x0B60 -#define GL_FOG_DENSITY 0x0B62 -#define GL_FOG_START 0x0B63 -#define GL_FOG_END 0x0B64 -#define GL_FOG_MODE 0x0B65 -#define GL_FOG_COLOR 0x0B66 -#define GL_DEPTH_TEST 0x0B71 -#define GL_STENCIL_TEST 0x0B90 -#define GL_VIEWPORT 0x0BA2 -#define GL_MODELVIEW_MATRIX 0x0BA6 -#define GL_ALPHA_TEST 0x0BC0 -#define GL_BLEND 0x0BE2 -#define GL_SCISSOR_BOX 0x0C10 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 -#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 -#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 -#define GL_TEXTURE_2D 0x0DE1 -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_FLOAT 0x1406 -#define GL_FIXED 0x140C -#define GL_INVERT 0x150A -#define GL_MODELVIEW 0x1700 -#define GL_PROJECTION 0x1701 -#define GL_COLOR_INDEX 0x1900 -#define GL_RED 0x1903 -#define GL_GREEN 0x1904 -#define GL_BLUE 0x1905 -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -#define GL_LUMINANCE 0x1909 -#define GL_LUMINANCE_ALPHA 0x190A -#define GL_POINT 0x1B00 -#define GL_LINE 0x1B01 -#define GL_FILL 0x1B02 -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 -#define GL_MODULATE 0x2100 -#define GL_DECAL 0x2101 -#define GL_TEXTURE_ENV_MODE 0x2200 -#define GL_TEXTURE_ENV_COLOR 0x2201 -#define GL_TEXTURE_ENV 0x2300 -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 -#define GL_REPEAT 0x2901 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -#define GL_POLYGON_OFFSET_POINT 0x2A01 -#define GL_POLYGON_OFFSET_LINE 0x2A02 -#define GL_CLIP_PLANE0 0x3000 -#define GL_FUNC_ADD 0x8006 -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_INTENSITY 0x8049 -#define GL_TEXTURE_BINDING_2D 0x8069 -#define GL_VERTEX_ARRAY 0x8074 -#define GL_COLOR_ARRAY 0x8076 -#define GL_TEXTURE_COORD_ARRAY 0x8078 -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_COLOR_TABLE 0x80D0 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_RG 0x8227 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_MIRRORED_REPEAT 0x8370 -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_STREAM_DRAW 0x88E0 -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_DRAW 0x88E4 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_READ_FRAMEBUFFER 0x8CA8 -#define GL_DRAW_FRAMEBUFFER 0x8CA9 -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_FRAMEBUFFER 0x8D40 - -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 32 - -typedef enum GLbitfield{ - GL_DEPTH_BUFFER_BIT = 0x00000100, - GL_STENCIL_BUFFER_BIT = 0x00000400, - GL_COLOR_BUFFER_BIT = 0x00004000 -} GLbitfield; -// clang-format on - -// gl* -void glActiveTexture(GLenum texture); -void glAlphaFunc(GLenum func, GLfloat ref); -void glArrayElement(GLint i); -void glAttachShader(GLuint prog, GLuint shad); -void glBegin(GLenum mode); -void glBindBuffer(GLenum target, GLuint buffer); -void glBindFramebuffer(GLenum target, GLuint framebuffer); -void glBindTexture(GLenum target, GLuint texture); -void glBlendEquation(GLenum mode); -void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha); -void glBlendFunc(GLenum sfactor, GLenum dfactor); -void glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -void glBufferData(GLenum target, GLsizei size, const GLvoid *data, GLenum usage); -void glClear(GLbitfield mask); -void glClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -void glClearDepth(GLdouble depth); -void glClearStencil(GLint s); -void glClientActiveTexture(GLenum texture); -void glClipPlane(GLenum plane, const GLdouble *equation); -void glColor3f(GLfloat red, GLfloat green, GLfloat blue); -void glColor3fv(const GLfloat *v); -void glColor3ub(GLubyte red, GLubyte green, GLubyte blue); -void glColor3ubv(const GLubyte *v); -void glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -void glColor4fv(const GLfloat *v); -void glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); -void glColor4ubv(const GLubyte *v); -void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -void glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -void glColorTable(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *data); -GLuint glCreateProgram(void); -GLuint glCreateShader(GLenum shaderType); -void glCullFace(GLenum mode); -void glDeleteBuffers(GLsizei n, const GLuint *gl_buffers); -void glDeleteFramebuffers(GLsizei n, GLuint *framebuffers); -void glDeleteProgram(GLuint prog); -void glDeleteShader(GLuint shad); -void glDeleteTextures(GLsizei n, const GLuint *textures); -void glDepthFunc(GLenum func); -void glDepthMask(GLboolean flag); -void glDepthRange(GLdouble nearVal, GLdouble farVal); -void glDepthRangef(GLfloat nearVal, GLfloat farVal); -void glDisable(GLenum cap); -void glDisableClientState(GLenum array); -void glDrawArrays(GLenum mode, GLint first, GLsizei count); -void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); -void glEnable(GLenum cap); -void glEnableClientState(GLenum array); -void glEnd(void); -void glFinish(void); -void glFogf(GLenum pname, GLfloat param); -void glFogfv(GLenum pname, const GLfloat *params); -void glFogi(GLenum pname, const GLint param); -void glFramebufferTexture(GLenum target, GLenum attachment, GLuint texture, GLint level); -void glFrontFace(GLenum mode); -void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal); -void glGenBuffers(GLsizei n, GLuint *buffers); -void glGenerateMipmap(GLenum target); -void glGenFramebuffers(GLsizei n, GLuint *ids); -void glGenTextures(GLsizei n, GLuint *textures); -void glGetBooleanv(GLenum pname, GLboolean *params); -void glGetFloatv(GLenum pname, GLfloat *data); -GLenum glGetError(void); -void glGetIntegerv(GLenum pname, GLint *data); -const GLubyte *glGetString(GLenum name); -GLint glGetUniformLocation(GLuint prog, const GLchar *name); -GLboolean glIsEnabled(GLenum cap); -void glLineWidth(GLfloat width); -void glLinkProgram(GLuint progr); -void glLoadIdentity(void); -void glLoadMatrixf(const GLfloat *m); -void glMatrixMode(GLenum mode); -void glMultMatrixf(const GLfloat *m); -void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal); -void glPointSize(GLfloat size); -void glPolygonMode(GLenum face, GLenum mode); -void glPolygonOffset(GLfloat factor, GLfloat units); -void glPopMatrix(void); -void glPushMatrix(void); -void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *data); -void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -void glScalef(GLfloat x, GLfloat y, GLfloat z); -void glScissor(GLint x, GLint y, GLsizei width, GLsizei height); -void glShaderBinary(GLsizei count, const GLuint *handles, GLenum binaryFormat, const void *binary, GLsizei length); // NOTE: Uses GXP shaders -void glStencilFunc(GLenum func, GLint ref, GLuint mask); -void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask); -void glStencilMask(GLuint mask); -void glStencilMaskSeparate(GLenum face, GLuint mask); -void glStencilOp(GLenum sfail, GLenum dpfail, GLenum dppass); -void glStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -void glTexCoord2f(GLfloat s, GLfloat t); -void glTexCoord2fv(GLfloat *f); -void glTexCoord2i(GLint s, GLint t); -void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -void glTexEnvf(GLenum target, GLenum pname, GLfloat param); -void glTexEnvi(GLenum target, GLenum pname, GLint param); -void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *data); -void glTexParameterf(GLenum target, GLenum pname, GLfloat param); -void glTexParameteri(GLenum target, GLenum pname, GLint param); -void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -void glTranslatef(GLfloat x, GLfloat y, GLfloat z); -void glUniform1f(GLint location, GLfloat v0); -void glUniform2fv(GLint location, GLsizei count, const GLfloat *value); -void glUniform4fv(GLint location, GLsizei count, const GLfloat *value); -void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -void glUseProgram(GLuint program); -void glVertex2f(GLfloat x, GLfloat y); -void glVertex3f(GLfloat x, GLfloat y, GLfloat z); -void glVertex3fv(const GLfloat *v); -void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -void glViewport(GLint x, GLint y, GLsizei width, GLsizei height); - -// VGL_EXT_gpu_objects_array extension -void vglColorPointer(GLint size, GLenum type, GLsizei stride, GLuint count, const GLvoid *pointer); -void vglColorPointerMapped(GLenum type, const GLvoid *pointer); -void vglDrawObjects(GLenum mode, GLsizei count, GLboolean implicit_wvp); -void vglIndexPointer(GLenum type, GLsizei stride, GLuint count, const GLvoid *pointer); -void vglIndexPointerMapped(const GLvoid *pointer); -void vglTexCoordPointer(GLint size, GLenum type, GLsizei stride, GLuint count, const GLvoid *pointer); -void vglTexCoordPointerMapped(const GLvoid *pointer); -void vglVertexPointer(GLint size, GLenum type, GLsizei stride, GLuint count, const GLvoid *pointer); -void vglVertexPointerMapped(const GLvoid *pointer); - -// VGL_EXT_gxp_shaders extension implementation -void vglBindAttribLocation(GLuint prog, GLuint index, const GLchar *name, const GLuint num, const GLenum type); -void vglVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint count, const GLvoid *pointer); -void vglVertexAttribPointerMapped(GLuint index, const GLvoid *pointer); - -typedef enum { - VGL_MEM_ALL = 0, // any memory type (used to monitor total heap usage) - VGL_MEM_VRAM, // CDRAM - VGL_MEM_RAM, // USER_RW RAM - VGL_MEM_SLOW, // PHYCONT_USER_RW RAM - VGL_MEM_EXTERNAL, // newlib mem - VGL_MEM_TYPE_COUNT -} vglMemType; - -// vgl* -void *vglAlloc(uint32_t size, vglMemType type); -void vglEnd(void); -void vglFree(void *addr); -void *vglGetTexDataPointer(GLenum target); -void vglInit(uint32_t gpu_pool_size); -void vglInitExtended(uint32_t gpu_pool_size, int width, int height, int ram_threshold, SceGxmMultisampleMode msaa); -size_t vglMemFree(vglMemType type); -void vglStartRendering(); -void vglStopRendering(); -void vglStopRenderingInit(); -void vglStopRenderingTerm(); -void vglUpdateCommonDialog(); -void vglUseVram(GLboolean usage); -void vglWaitVblankStart(GLboolean enable); - -#ifdef __cplusplus -} -#endif - -#endif