mirror of
https://github.com/libretro/RetroArch
synced 2025-02-11 06:40:48 +00:00
Squashed 'deps/vitaShaRK/' content from commit f54dc7bdd5
git-subtree-dir: deps/vitaShaRK git-subtree-split: f54dc7bdd5cb14fb9de9dc21962ccd8b6938e56d
This commit is contained in:
commit
2b1146d46e
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Auto detect text files and perform LF normalization
|
||||||
|
* text=auto
|
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
patreon: Rinnegatamante
|
59
.gitignore
vendored
Normal file
59
.gitignore
vendored
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
*.vpk
|
||||||
|
*.elf
|
||||||
|
*.velf
|
||||||
|
*.bin
|
||||||
|
*.sfo
|
||||||
|
*.S
|
||||||
|
*.wo
|
||||||
|
|
||||||
|
# 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
|
165
LICENSE
Normal file
165
LICENSE
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
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.
|
37
Makefile
Normal file
37
Makefile
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
TARGET := libvitashark
|
||||||
|
SOURCES := source
|
||||||
|
SHADERS := shaders
|
||||||
|
|
||||||
|
CFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.c))
|
||||||
|
ASMFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.S))
|
||||||
|
CGFILES := $(foreach dir,$(SHADERS), $(wildcard $(dir)/*.cg))
|
||||||
|
HEADERS := $(CGFILES:.cg=.h)
|
||||||
|
OBJS := $(CFILES:.c=.o) $(ASMFILES:.S=.o)
|
||||||
|
|
||||||
|
PREFIX = arm-vita-eabi
|
||||||
|
CC = $(PREFIX)-gcc
|
||||||
|
AR = $(PREFIX)-gcc-ar
|
||||||
|
CFLAGS = -g -Wl,-q -O2 -ffast-math -mtune=cortex-a9 -mfpu=neon -ftree-vectorize
|
||||||
|
ASFLAGS = $(CFLAGS)
|
||||||
|
|
||||||
|
all: $(TARGET).a
|
||||||
|
|
||||||
|
$(TARGET).a: $(OBJS)
|
||||||
|
$(AR) -rc $@ $^
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@rm -rf $(TARGET).a $(TARGET).elf $(OBJS)
|
||||||
|
@make -C samples/sample1 clean
|
||||||
|
@make -C samples/sample2 clean
|
||||||
|
|
||||||
|
install: $(TARGET).a
|
||||||
|
@mkdir -p $(VITASDK)/$(PREFIX)/lib/
|
||||||
|
cp $(TARGET).a $(VITASDK)/$(PREFIX)/lib/
|
||||||
|
@mkdir -p $(VITASDK)/$(PREFIX)/include/
|
||||||
|
cp source/vitashark.h $(VITASDK)/$(PREFIX)/include/
|
||||||
|
|
||||||
|
samples: $(TARGET).a
|
||||||
|
@make -C samples/sample1
|
||||||
|
cp "samples/sample1/vitaShaRK-Sample001.vpk" .
|
||||||
|
@make -C samples/sample2
|
||||||
|
cp "samples/sample1/vitaShaRK-Sample002.vpk" .
|
18
README.md
Normal file
18
README.md
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# vitaShaRK
|
||||||
|
**vita** **Sha**ders **R**untime **K**ompiler is a runtime shader compiler library for PSVITA/PSTV using the SceShaccCg module contained inside the PSM runtime.
|
||||||
|
|
||||||
|
# Build Instructions
|
||||||
|
In order to build vitaShaRK, you'll first need to build SceShaccCg stubs. This is a full list of commands you can use to install this library and the required stubs:
|
||||||
|
```
|
||||||
|
vita-libs-gen SceShaccCg.yml build
|
||||||
|
cd build
|
||||||
|
make install
|
||||||
|
cd ..
|
||||||
|
cp shacccg.h $VITASDK/arm-vita-eabi/psp2/shacccg.h
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
|
||||||
|
**frangarcj** for the original vita2d shader compiler source used as base to build up this library.
|
43
SceShaccCg.yml
Normal file
43
SceShaccCg.yml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
version: 2
|
||||||
|
firmware: 3.60
|
||||||
|
modules:
|
||||||
|
SceShaccCg:
|
||||||
|
nid: 0xB3B90A35
|
||||||
|
libraries:
|
||||||
|
SceShaccCg:
|
||||||
|
kernel: false
|
||||||
|
nid: 0xA05BBEBB
|
||||||
|
functions:
|
||||||
|
SceShaccCg_0205DE96: 0x0205DE96
|
||||||
|
SceShaccCg_07DDFC78: 0x07DDFC78
|
||||||
|
SceShaccCg_0E1285A6: 0x0E1285A6
|
||||||
|
SceShaccCg_152971B1: 0x152971B1
|
||||||
|
SceShaccCg_17223BEB: 0x17223BEB
|
||||||
|
SceShaccCg_2654E73A: 0x2654E73A
|
||||||
|
SceShaccCg_268FAEE9: 0x268FAEE9
|
||||||
|
sceShaccCgInitializeCompileOptions: 0x3B58AFA0
|
||||||
|
SceShaccCg_4595A388: 0x4595A388
|
||||||
|
SceShaccCg_46FA0303: 0x46FA0303
|
||||||
|
SceShaccCg_56BFA825: 0x56BFA825
|
||||||
|
SceShaccCg_648739F3: 0x648739F3
|
||||||
|
sceShaccCgCompileProgram: 0x66814F35
|
||||||
|
SceShaccCg_6BB58825: 0x6BB58825
|
||||||
|
sceShaccCgSetDefaultAllocator: 0x6F01D573
|
||||||
|
SceShaccCg_6FB40CA9: 0x6FB40CA9
|
||||||
|
SceShaccCg_7B2CF324: 0x7B2CF324
|
||||||
|
SceShaccCg_7BC25091: 0x7BC25091
|
||||||
|
SceShaccCg_7F430CCD: 0x7F430CCD
|
||||||
|
SceShaccCg_95F57A23: 0x95F57A23
|
||||||
|
SceShaccCg_A067C481: 0xA067C481
|
||||||
|
SceShaccCg_A13A8A1E: 0xA13A8A1E
|
||||||
|
SceShaccCg_A56B1A5B: 0xA56B1A5B
|
||||||
|
SceShaccCg_A7930FF6: 0xA7930FF6
|
||||||
|
sceShaccCgInitializeCallbackList: 0xA8C2C1C8
|
||||||
|
sceShaccCgDestroyCompileOutput: 0xAA82EF0C
|
||||||
|
SceShaccCg_B4AC9943: 0xB4AC9943
|
||||||
|
SceShaccCg_BB703EE1: 0xBB703EE1
|
||||||
|
SceShaccCg_D4378DB1: 0xD4378DB1
|
||||||
|
SceShaccCg_DAD4AAE4: 0xDAD4AAE4
|
||||||
|
SceShaccCg_DF3DDCFD: 0xDF3DDCFD
|
||||||
|
SceShaccCg_EF8D59D6: 0xEF8D59D6
|
||||||
|
SceShaccCg_F4BAB902: 0xF4BAB902
|
37
samples/sample1/Makefile
Normal file
37
samples/sample1/Makefile
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
SAMPLE_NUM := 001
|
||||||
|
TARGET := vitaShaRK-Sample$(SAMPLE_NUM)
|
||||||
|
SOURCES := .
|
||||||
|
|
||||||
|
INCLUDES := include
|
||||||
|
|
||||||
|
LIBS = -lvitashark -lSceLibKernel_stub -lSceShaccCg_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=VSHARK$(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
|
59
samples/sample1/main.c
Normal file
59
samples/sample1/main.c
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
// Simple compiler with no logging
|
||||||
|
|
||||||
|
#include <vitashark.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
const char fragment_shader[] =
|
||||||
|
"float4 main(uniform float4 u_clear_color) : COLOR\n"
|
||||||
|
"{\n"
|
||||||
|
" return u_clear_color;\n"
|
||||||
|
"}"
|
||||||
|
;
|
||||||
|
|
||||||
|
const char vertex_shader[] =
|
||||||
|
"void main(\n"
|
||||||
|
"float3 aPosition,\n"
|
||||||
|
"float3 aColor,\n"
|
||||||
|
"uniform float4x4 wvp,\n"
|
||||||
|
"float4 out vPosition: POSITION,\n"
|
||||||
|
"float4 out vColor: COLOR)\n"
|
||||||
|
"{\n"
|
||||||
|
" vPosition = mul(float4(aPosition, 1.f), wvp);\n"
|
||||||
|
" vColor = float4(aColor, 1.f);\n"
|
||||||
|
"}"
|
||||||
|
;
|
||||||
|
|
||||||
|
void saveGXP(SceGxmProgram *p, uint32_t size, const char *fname) {
|
||||||
|
FILE *f = fopen(fname, "wb");
|
||||||
|
fwrite(p, 1, size, f);
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
// Initializing vitaShaRK
|
||||||
|
if (shark_init(NULL) < 0) // NOTE: libshacccg.suprx will need to be placed in ur0:data
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
// Compiling fragment shader
|
||||||
|
uint32_t size = sizeof(fragment_shader) - 1;
|
||||||
|
SceGxmProgram *p = shark_compile_shader(fragment_shader, &size, SHARK_FRAGMENT_SHADER);
|
||||||
|
|
||||||
|
// Saving compiled GXP file on SD
|
||||||
|
if (p) saveGXP(p, size, "ux0:data/clear_f.gxp");
|
||||||
|
|
||||||
|
shark_clear_output();
|
||||||
|
|
||||||
|
// Compiling vertex shader
|
||||||
|
size = sizeof(vertex_shader) - 1;
|
||||||
|
p = shark_compile_shader(vertex_shader, &size, SHARK_VERTEX_SHADER);
|
||||||
|
|
||||||
|
// Saving compiled GXP file on SD
|
||||||
|
if (p) saveGXP(p, size, "ux0:data/rgb_v.gxp");
|
||||||
|
|
||||||
|
shark_clear_output();
|
||||||
|
|
||||||
|
shark_end();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
37
samples/sample2/Makefile
Normal file
37
samples/sample2/Makefile
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
SAMPLE_NUM := 002
|
||||||
|
TARGET := vitaShaRK-Sample$(SAMPLE_NUM)
|
||||||
|
SOURCES := .
|
||||||
|
|
||||||
|
INCLUDES := include
|
||||||
|
|
||||||
|
LIBS = -lvitashark -lSceLibKernel_stub -lSceShaccCg_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=VSHARK$(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
|
85
samples/sample2/main.c
Normal file
85
samples/sample2/main.c
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
// Simple compiler with file logging
|
||||||
|
|
||||||
|
#include <vitashark.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
const char fragment_shader[] =
|
||||||
|
"float4 main(uniform float4 u_clear_color) : COLOR\n"
|
||||||
|
"{\n"
|
||||||
|
" return u_clear_color;\n"
|
||||||
|
"}"
|
||||||
|
;
|
||||||
|
|
||||||
|
const char vertex_shader[] =
|
||||||
|
"void main(\n"
|
||||||
|
"float3 aPosition,\n"
|
||||||
|
"float3 aColor,\n"
|
||||||
|
"uniform float4x4 wvp,\n"
|
||||||
|
"float4 out vPosition: POSITION,\n"
|
||||||
|
"float4 out vColor: COLOR)\n"
|
||||||
|
"{\n"
|
||||||
|
" vPosition = mul(float4(aPosition, 1.f), wvp);\n"
|
||||||
|
" vColor = float4(aColor, 1.f);\n"
|
||||||
|
"}"
|
||||||
|
;
|
||||||
|
|
||||||
|
char curr_compilation[256];
|
||||||
|
|
||||||
|
void log_cb(const char *msg, shark_log_level msg_level, int line) {
|
||||||
|
FILE *f = fopen("ux0:/data/shark.log", "a+");
|
||||||
|
switch (msg_level) {
|
||||||
|
case SHARK_LOG_INFO:
|
||||||
|
fprintf(f, "%s) INFO: %s at line %d\n", curr_compilation, msg, line);
|
||||||
|
break;
|
||||||
|
case SHARK_LOG_WARNING:
|
||||||
|
fprintf(f, "%s) WARNING: %s at line %d\n", curr_compilation, msg, line);
|
||||||
|
break;
|
||||||
|
case SHARK_LOG_ERROR:
|
||||||
|
fprintf(f, "%s) ERROR: %s at line %d\n", curr_compilation, msg, line);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void saveGXP(SceGxmProgram *p, uint32_t size, const char *fname) {
|
||||||
|
FILE *f = fopen(fname, "wb");
|
||||||
|
fwrite(p, 1, size, f);
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
// Initializing vitaShaRK
|
||||||
|
if (shark_init(NULL) < 0) // NOTE: libshacccg.suprx will need to be placed in ur0:data
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
// Setting up logger
|
||||||
|
shark_install_log_cb(log_cb);
|
||||||
|
shark_set_warnings_level(SHARK_WARN_MAX);
|
||||||
|
|
||||||
|
// Compiling fragment shader
|
||||||
|
sprintf(curr_compilation, "clear_f.gxp");
|
||||||
|
uint32_t size = sizeof(fragment_shader) - 1;
|
||||||
|
SceGxmProgram *p = shark_compile_shader(fragment_shader, &size, SHARK_FRAGMENT_SHADER);
|
||||||
|
|
||||||
|
// Saving compiled GXP file on SD
|
||||||
|
if (p) saveGXP(p, size, "ux0:data/clear_f.gxp");
|
||||||
|
|
||||||
|
shark_clear_output();
|
||||||
|
|
||||||
|
// Compiling vertex shader
|
||||||
|
sprintf(curr_compilation, "rgb_v.gxp");
|
||||||
|
size = sizeof(vertex_shader) - 1;
|
||||||
|
p = shark_compile_shader(vertex_shader, &size, SHARK_VERTEX_SHADER);
|
||||||
|
|
||||||
|
// Saving compiled GXP file on SD
|
||||||
|
if (p) saveGXP(p, size, "ux0:data/rgb_v.gxp");
|
||||||
|
|
||||||
|
shark_clear_output();
|
||||||
|
|
||||||
|
shark_end();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
185
shacccg.h
Normal file
185
shacccg.h
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
#ifndef _PSP2_SHACCCG_H
|
||||||
|
#define _PSP2_SHACCCG_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif // def __cplusplus
|
||||||
|
|
||||||
|
typedef struct SceShaccCgCompileOptions SceShaccCgCompileOptions;
|
||||||
|
typedef struct SceShaccCgSourceFile SceShaccCgSourceFile;
|
||||||
|
typedef struct SceShaccCgSourceLocation SceShaccCgSourceLocation;
|
||||||
|
typedef void const *SceShaccCgParameter;
|
||||||
|
|
||||||
|
typedef SceShaccCgSourceFile* (*SceShaccCgCallbackOpenFile)(
|
||||||
|
const char *fileName,
|
||||||
|
const SceShaccCgSourceLocation *includedFrom,
|
||||||
|
const SceShaccCgCompileOptions *compileOptions,
|
||||||
|
const char **errorString);
|
||||||
|
|
||||||
|
typedef void (*SceShaccCgCallbackReleaseFile)(
|
||||||
|
const SceShaccCgSourceFile *file,
|
||||||
|
const SceShaccCgCompileOptions *compileOptions);
|
||||||
|
|
||||||
|
typedef const char* (*SceShaccCgCallbackLocateFile)(
|
||||||
|
const char *fileName,
|
||||||
|
const SceShaccCgSourceLocation *includedFrom,
|
||||||
|
uint32_t searchPathCount,
|
||||||
|
const char *const*searchPaths,
|
||||||
|
const SceShaccCgCompileOptions *compileOptions,
|
||||||
|
const char **errorString);
|
||||||
|
|
||||||
|
typedef const char* (*SceShaccCgCallbackAbsolutePath)(
|
||||||
|
const char *fileName,
|
||||||
|
const SceShaccCgSourceLocation *includedFrom,
|
||||||
|
const SceShaccCgCompileOptions *compileOptions);
|
||||||
|
|
||||||
|
typedef void (*SceShaccCgCallbackReleaseFileName)(
|
||||||
|
const char *fileName,
|
||||||
|
const SceShaccCgCompileOptions *compileOptions);
|
||||||
|
|
||||||
|
typedef int32_t (*SceShaccCgCallbackFileDate)(
|
||||||
|
const SceShaccCgSourceFile *file,
|
||||||
|
const SceShaccCgSourceLocation *includedFrom,
|
||||||
|
const SceShaccCgCompileOptions *compileOptions,
|
||||||
|
int64_t *timeLastStatusChange,
|
||||||
|
int64_t *timeLastModified);
|
||||||
|
|
||||||
|
typedef enum SceShaccCgDiagnosticLevel {
|
||||||
|
SCE_SHACCCG_DIAGNOSTIC_LEVEL_INFO,
|
||||||
|
SCE_SHACCCG_DIAGNOSTIC_LEVEL_WARNING,
|
||||||
|
SCE_SHACCCG_DIAGNOSTIC_LEVEL_ERROR
|
||||||
|
} SceShaccCgDiagnosticLevel;
|
||||||
|
|
||||||
|
typedef enum SceShaccCgTargetProfile {
|
||||||
|
SCE_SHACCCG_PROFILE_VP,
|
||||||
|
SCE_SHACCCG_PROFILE_FP
|
||||||
|
} SceShaccCgTargetProfile;
|
||||||
|
|
||||||
|
typedef enum SceShaccCgCallbackDefaults {
|
||||||
|
SCE_SHACCCG_SYSTEM_FILES,
|
||||||
|
SCE_SHACCCG_TRIVIAL
|
||||||
|
} SceShaccCgCallbackDefaults;
|
||||||
|
|
||||||
|
typedef enum SceShaccCgLocale {
|
||||||
|
SCE_SHACCCG_ENGLISH,
|
||||||
|
SCE_SHACCCG_JAPANESE
|
||||||
|
} SceShaccCgLocale;
|
||||||
|
|
||||||
|
typedef struct SceShaccCgSourceFile {
|
||||||
|
const char *fileName;
|
||||||
|
const char *text;
|
||||||
|
uint32_t size;
|
||||||
|
} SceShaccCgSourceFile;
|
||||||
|
|
||||||
|
typedef struct SceShaccCgSourceLocation {
|
||||||
|
const SceShaccCgSourceFile *file;
|
||||||
|
uint32_t lineNumber;
|
||||||
|
uint32_t columnNumber;
|
||||||
|
} SceShaccCgSourceLocation;
|
||||||
|
|
||||||
|
typedef struct SceShaccCgCallbackList {
|
||||||
|
SceShaccCgCallbackOpenFile openFile;
|
||||||
|
SceShaccCgCallbackReleaseFile releaseFile;
|
||||||
|
SceShaccCgCallbackLocateFile locateFile;
|
||||||
|
SceShaccCgCallbackAbsolutePath absolutePath;
|
||||||
|
SceShaccCgCallbackReleaseFileName releaseFileName;
|
||||||
|
SceShaccCgCallbackFileDate fileDate;
|
||||||
|
} SceShaccCgCallbackList;
|
||||||
|
|
||||||
|
typedef struct SceShaccCgCompileOptions {
|
||||||
|
const char *mainSourceFile;
|
||||||
|
SceShaccCgTargetProfile targetProfile;
|
||||||
|
const char *entryFunctionName;
|
||||||
|
uint32_t searchPathCount;
|
||||||
|
const char* const *searchPaths;
|
||||||
|
uint32_t macroDefinitionCount;
|
||||||
|
const char* const *macroDefinitions;
|
||||||
|
uint32_t includeFileCount;
|
||||||
|
const char* const *includeFiles;
|
||||||
|
uint32_t suppressedWarningsCount;
|
||||||
|
const uint32_t *suppressedWarnings;
|
||||||
|
SceShaccCgLocale locale;
|
||||||
|
int32_t useFx;
|
||||||
|
int32_t noStdlib;
|
||||||
|
int32_t optimizationLevel;
|
||||||
|
int32_t useFastmath;
|
||||||
|
int32_t useFastprecision;
|
||||||
|
int32_t useFastint;
|
||||||
|
int32_t warningsAsErrors;
|
||||||
|
int32_t performanceWarnings;
|
||||||
|
int32_t warningLevel;
|
||||||
|
int32_t pedantic;
|
||||||
|
int32_t pedanticError;
|
||||||
|
int field_5C;
|
||||||
|
int field_60;
|
||||||
|
int field_64;
|
||||||
|
} SceShaccCgCompileOptions;
|
||||||
|
|
||||||
|
typedef struct SceShaccCgDiagnosticMessage {
|
||||||
|
SceShaccCgDiagnosticLevel level;
|
||||||
|
uint32_t code;
|
||||||
|
const SceShaccCgSourceLocation *location;
|
||||||
|
const char *message;
|
||||||
|
} SceShaccCgDiagnosticMessage;
|
||||||
|
|
||||||
|
typedef struct SceShaccCgCompileOutput {
|
||||||
|
const uint8_t *programData;
|
||||||
|
uint32_t programSize;
|
||||||
|
int32_t diagnosticCount;
|
||||||
|
const SceShaccCgDiagnosticMessage *diagnostics;
|
||||||
|
} SceShaccCgCompileOutput;
|
||||||
|
|
||||||
|
|
||||||
|
int SceShaccCg_0205DE96(int);
|
||||||
|
int SceShaccCg_07DDFC78(int);
|
||||||
|
int SceShaccCg_0E1285A6(int);
|
||||||
|
int SceShaccCg_152971B1(int);
|
||||||
|
int SceShaccCg_17223BEB(int);
|
||||||
|
int SceShaccCg_2654E73A(int);
|
||||||
|
int SceShaccCg_268FAEE9(int);
|
||||||
|
|
||||||
|
int sceShaccCgInitializeCompileOptions(
|
||||||
|
SceShaccCgCompileOptions *options);
|
||||||
|
|
||||||
|
int SceShaccCg_4595A388(int);
|
||||||
|
int SceShaccCg_46FA0303(int);
|
||||||
|
int SceShaccCg_56BFA825(int);
|
||||||
|
int SceShaccCg_648739F3(int);
|
||||||
|
|
||||||
|
SceShaccCgCompileOutput const *sceShaccCgCompileProgram(
|
||||||
|
const SceShaccCgCompileOptions *options,
|
||||||
|
const SceShaccCgCallbackList *callbacks,
|
||||||
|
int unk);
|
||||||
|
|
||||||
|
int SceShaccCg_6BB58825(int);
|
||||||
|
int sceShaccCgSetDefaultAllocator(void *(*malloc_cb)(unsigned int), void (*free_cb)(void *));
|
||||||
|
int SceShaccCg_6FB40CA9(int);
|
||||||
|
int SceShaccCg_7B2CF324(int);
|
||||||
|
int SceShaccCg_7BC25091(int);
|
||||||
|
int SceShaccCg_7F430CCD(int);
|
||||||
|
int SceShaccCg_95F57A23(int);
|
||||||
|
int SceShaccCg_A067C481(int);
|
||||||
|
int SceShaccCg_A13A8A1E(int);
|
||||||
|
int SceShaccCg_A56B1A5B(int);
|
||||||
|
int SceShaccCg_A7930FF6(int);
|
||||||
|
|
||||||
|
void sceShaccCgInitializeCallbackList(
|
||||||
|
SceShaccCgCallbackList *callbacks,
|
||||||
|
SceShaccCgCallbackDefaults defaults);
|
||||||
|
|
||||||
|
void sceShaccCgDestroyCompileOutput(
|
||||||
|
SceShaccCgCompileOutput const *output);
|
||||||
|
|
||||||
|
int SceShaccCg_B4AC9943(int);
|
||||||
|
int SceShaccCg_BB703EE1(int);
|
||||||
|
int SceShaccCg_D4378DB1(int);
|
||||||
|
int SceShaccCg_DAD4AAE4(int);
|
||||||
|
int SceShaccCg_DF3DDCFD(int);
|
||||||
|
int SceShaccCg_EF8D59D6(int);
|
||||||
|
int SceShaccCg_F4BAB902(int);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _PSP2_SHACCCG_H */
|
124
source/vitashark.c
Normal file
124
source/vitashark.c
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of vitaGL
|
||||||
|
* Copyright 2017, 2018, 2019, 2020 Rinnegatamante
|
||||||
|
* Copyright 2020 Asakura Reiko
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published
|
||||||
|
* by the Free Software Foundation, version 3 of the License, or (at your
|
||||||
|
* option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "vitashark.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <psp2/shacccg.h>
|
||||||
|
|
||||||
|
// Default path for SceShaccCg module location
|
||||||
|
#define DEFAULT_SHACCCG_PATH "ur0:/data/libshacccg.suprx"
|
||||||
|
|
||||||
|
static void (*shark_log_cb)(const char *msg, shark_log_level msg_level, int line) = NULL;
|
||||||
|
static shark_warn_level shark_warnings_level = SHARK_WARN_SILENT;
|
||||||
|
|
||||||
|
static SceUID shark_module_id = 0;
|
||||||
|
static uint8_t shark_initialized = 0;
|
||||||
|
static SceShaccCgCompileOutput *shark_output = NULL;
|
||||||
|
static SceShaccCgSourceFile shark_input;
|
||||||
|
|
||||||
|
// Dummy Open File callback
|
||||||
|
static SceShaccCgSourceFile *shark_open_file_cb(const char *fileName,
|
||||||
|
const SceShaccCgSourceLocation *includedFrom,
|
||||||
|
const SceShaccCgCompileOptions *compileOptions,
|
||||||
|
const char **errorString)
|
||||||
|
{
|
||||||
|
return &shark_input;
|
||||||
|
}
|
||||||
|
|
||||||
|
int shark_init(const char *path) {
|
||||||
|
// Initializing sceShaccCg module
|
||||||
|
if (!shark_initialized) {
|
||||||
|
shark_module_id = sceKernelLoadStartModule(path ? path : DEFAULT_SHACCCG_PATH, 0, NULL, 0, NULL, NULL);
|
||||||
|
if (shark_module_id < 0) return -1;
|
||||||
|
sceShaccCgSetDefaultAllocator(malloc, free);
|
||||||
|
shark_initialized = 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void shark_end() {
|
||||||
|
if (!shark_initialized) return;
|
||||||
|
|
||||||
|
// Terminating sceShaccCg module
|
||||||
|
sceKernelStopUnloadModule(shark_module_id, 0, NULL, 0, NULL, NULL);
|
||||||
|
shark_initialized = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void shark_install_log_cb(void (*cb)(const char *msg, shark_log_level msg_level, int line)) {
|
||||||
|
shark_log_cb = cb;
|
||||||
|
}
|
||||||
|
|
||||||
|
void shark_set_warnings_level(shark_warn_level level) {
|
||||||
|
// Changing current warnings level
|
||||||
|
shark_warnings_level = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
void shark_clear_output() {
|
||||||
|
// Clearing sceShaccCg output
|
||||||
|
if (shark_output) {
|
||||||
|
sceShaccCgDestroyCompileOutput(shark_output);
|
||||||
|
shark_output = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SceGxmProgram *shark_compile_shader_extended(const char *src, uint32_t *size, shark_type type, shark_opt opt, int32_t use_fastmath, int32_t use_fastprecision, int32_t use_fastint) {
|
||||||
|
if (!shark_initialized) return NULL;
|
||||||
|
|
||||||
|
// Forcing usage for memory source for the shader to compile
|
||||||
|
shark_input.fileName = "<built-in>";
|
||||||
|
shark_input.text = src;
|
||||||
|
shark_input.size = *size;
|
||||||
|
|
||||||
|
// Properly configuring SceShaccCg with requqested settings
|
||||||
|
SceShaccCgCompileOptions options = {0};
|
||||||
|
options.mainSourceFile = shark_input.fileName;
|
||||||
|
options.targetProfile = type;
|
||||||
|
options.entryFunctionName = "main";
|
||||||
|
options.macroDefinitions = NULL;
|
||||||
|
options.useFx = 1;
|
||||||
|
options.warningLevel = shark_warnings_level;
|
||||||
|
options.optimizationLevel = opt;
|
||||||
|
options.useFastmath = use_fastmath;
|
||||||
|
options.useFastint = use_fastint;
|
||||||
|
options.useFastprecision = use_fastprecision;
|
||||||
|
options.pedantic = shark_warnings_level > SHARK_WARN_MEDIUM ? SHARK_ENABLE : SHARK_DISABLE;
|
||||||
|
options.performanceWarnings = shark_warnings_level > SHARK_WARN_SILENT ? SHARK_ENABLE : SHARK_DISABLE;
|
||||||
|
|
||||||
|
// Executing shader compilation
|
||||||
|
SceShaccCgCallbackList callbacks = {0};
|
||||||
|
sceShaccCgInitializeCallbackList(&callbacks, SCE_SHACCCG_TRIVIAL);
|
||||||
|
callbacks.openFile = shark_open_file_cb;
|
||||||
|
const SceShaccCgCompileOutput *shark_output = sceShaccCgCompileProgram(&options, &callbacks, 0);
|
||||||
|
|
||||||
|
// Executing logging
|
||||||
|
if (shark_log_cb) {
|
||||||
|
for (int i = 0; i < shark_output->diagnosticCount; ++i) {
|
||||||
|
const SceShaccCgDiagnosticMessage *log = &shark_output->diagnostics[i];
|
||||||
|
shark_log_cb(log->message, log->level, log->location->lineNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returning output
|
||||||
|
if (shark_output->programData) *size = shark_output->programSize;
|
||||||
|
return (SceGxmProgram *)shark_output->programData;
|
||||||
|
}
|
||||||
|
|
||||||
|
SceGxmProgram *shark_compile_shader(const char *src, uint32_t *size, shark_type type) {
|
||||||
|
return shark_compile_shader_extended(src, size, type, SHARK_OPT_DEFAULT, SHARK_DISABLE, SHARK_DISABLE, SHARK_DISABLE);
|
||||||
|
}
|
75
source/vitashark.h
Normal file
75
source/vitashark.h
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of vitaShaRK
|
||||||
|
* Copyright 2017, 2018, 2019, 2020 Rinnegatamante
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published
|
||||||
|
* by the Free Software Foundation, version 3 of the License, or (at your
|
||||||
|
* option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _VITASHARK_H_
|
||||||
|
#define _VITASHARK_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <vitasdk.h>
|
||||||
|
|
||||||
|
typedef enum shark_opt {
|
||||||
|
SHARK_OPT_SLOW, //!< Equivalent to O0
|
||||||
|
SHARK_OPT_SAFE, //!< Equivalent to O1
|
||||||
|
SHARK_OPT_DEFAULT, //!< Equivalent to O2
|
||||||
|
SHARK_OPT_FAST, //!< Equivalent to O3
|
||||||
|
SHARK_OPT_UNSAFE //!< Equivalent to Ofast
|
||||||
|
} shark_opt;
|
||||||
|
|
||||||
|
typedef enum shark_type {
|
||||||
|
SHARK_VERTEX_SHADER,
|
||||||
|
SHARK_FRAGMENT_SHADER
|
||||||
|
} shark_type;
|
||||||
|
|
||||||
|
typedef enum shark_log_level {
|
||||||
|
SHARK_LOG_INFO,
|
||||||
|
SHARK_LOG_WARNING,
|
||||||
|
SHARK_LOG_ERROR
|
||||||
|
} shark_log_level;
|
||||||
|
|
||||||
|
typedef enum shark_warn_level {
|
||||||
|
SHARK_WARN_SILENT,
|
||||||
|
SHARK_WARN_LOW,
|
||||||
|
SHARK_WARN_MEDIUM,
|
||||||
|
SHARK_WARN_HIGH,
|
||||||
|
SHARK_WARN_MAX
|
||||||
|
} shark_warn_level;
|
||||||
|
|
||||||
|
#define SHARK_DISABLE 0
|
||||||
|
#define SHARK_ENABLE 1
|
||||||
|
|
||||||
|
// Init/term routines
|
||||||
|
int shark_init(const char *path); //!< Initializes runtime shader compiler
|
||||||
|
void shark_end(); //!< Terminates runtime shader compiler and frees used memory
|
||||||
|
|
||||||
|
// Compiling routines
|
||||||
|
SceGxmProgram *shark_compile_shader_extended(const char *src, uint32_t *size, shark_type type, shark_opt opt, int32_t use_fastmath, int32_t use_fastprecision, int32_t use_fastint); //!< Compiles a shader with extended settings
|
||||||
|
SceGxmProgram *shark_compile_shader(const char *src, uint32_t *size, shark_type type); //!< Compiles a shader
|
||||||
|
void shark_clear_output(); //!< Clears output of a compilation attempt
|
||||||
|
|
||||||
|
// Logging routines
|
||||||
|
void shark_install_log_cb(void (*cb)(const char *msg, shark_log_level msg_level, int line)); //!< Installs a log function for info, warnings and errors
|
||||||
|
void shark_set_warnings_level(shark_warn_level level); //!< Sets warnings level for logging
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user