mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 16:09:47 +00:00
Squashed 'deps/vitaGL/' content from commit 9a6e4b3397
git-subtree-dir: deps/vitaGL git-subtree-split: 9a6e4b3397c207e136b2d618fa4b58e2b37c383e
This commit is contained in:
commit
78c27dc77a
99
.clang-format
Normal file
99
.clang-format
Normal file
@ -0,0 +1,99 @@
|
||||
---
|
||||
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
|
||||
...
|
17
.gitattributes
vendored
Normal file
17
.gitattributes
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
# 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
|
57
.gitignore
vendored
Normal file
57
.gitignore
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
*.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
|
674
COPYING
Normal file
674
COPYING
Normal file
@ -0,0 +1,674 @@
|
||||
GNU 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.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU 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
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
165
COPYING.LESSER
Normal file
165
COPYING.LESSER
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.
|
67
Makefile
Normal file
67
Makefile
Normal file
@ -0,0 +1,67 @@
|
||||
TARGET := libvitaGL
|
||||
SOURCES := source source/utils
|
||||
SHADERS := shaders
|
||||
|
||||
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 -DSTB_DXT_IMPLEMENTATION
|
||||
ASFLAGS = $(CFLAGS)
|
||||
|
||||
all: $(TARGET).a
|
||||
|
||||
$(TARGET).a: $(OBJS)
|
||||
$(AR) -rc $@ $^
|
||||
|
||||
%_f.h:
|
||||
psp2cgc -profile sce_fp_psp2 $(@:_f.h=_f.cg) -Wperf -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 -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" .
|
44
README.md
Normal file
44
README.md
Normal file
@ -0,0 +1,44 @@
|
||||
# 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.
|
||||
|
||||
# Build Instructions
|
||||
In order to build vitaGL use the following command: `make HAVE_SBRK=1 install`.
|
||||
If you already have a newlib sbrk replacement in your app (eg. RetroArch), use instead this command: `make install`.
|
||||
|
||||
# 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:<br>
|
||||
[vitaQuake](https://vitadb.rinnegatamante.it/#/info/10) - Port of Quake I and mission packs<br>
|
||||
[vitaQuakeII](https://vitadb.rinnegatamante.it/#/info/278) -Port of Quake II and mission packs<br>
|
||||
[vitaQuakeIII](https://vitadb.rinnegatamante.it/#/info/375) - Port of ioquake3 (Quake III: Arena, Quake III: Team Arena, OpenArena)<br>
|
||||
[vitaRTCW](https://vitadb.rinnegatamante.it/#/info/459) - Port of iortcw (Return to Castle Wolfenstein)<br>
|
||||
[vitaHexenII](https://vitadb.rinnegatamante.it/#/info/196) - Port of Hexen II<br>
|
||||
[vitaXash3D](https://vitadb.rinnegatamante.it/#/info/365) - Port of Xash3D (Half Life, Counter Strike 1.6)<br>
|
||||
[Fade to Black](https://vitadb.rinnegatamante.it/#/info/367) - Port of Fade to Black<br>
|
||||
[vitaVoyager](https://vitadb.rinnegatamante.it/#/info/367) - Port of lilium-voyager (Star Trek Voyager: Elite Force)<br>
|
||||
[Daedalus X64](https://github.com/Rinnegatamante/daedalusx64-vitagl) - Port of Daedalus X64 (N64 Emulator)<br>
|
||||
[RetroArch](https://github.com/libretro/RetroArch) - Vita's GL1 video driver of RetroArch<br>
|
||||
[vitaET](https://github.com/Rinnegatamante/vitaET) - Port of ET:Legacy (Wolfenstein: Enemy Territory)<br>
|
||||
|
||||
Libraries:<br>
|
||||
[sdl12_gl](https://github.com/Rinnegatamante/SDL-Vita/tree/sdl12_gl/src) - SDL 1.2 Vita port adapted to work with vitaGL as renderer<br>
|
||||
[imgui_vita](https://github.com/Rinnegatamante/imgui-vita) - Port of dear imGui <br>
|
||||
|
||||
sdl12_gl Apps:<br>
|
||||
[SuperMarioWar](https://vitadb.rinnegatamante.it/#/info/422) - Port of Super Mario War<br>
|
||||
[ZeldaOLB](https://vitadb.rinnegatamante.it/#/info/265) - Port of Zelda: Oni Link Begins<br>
|
||||
[ZeldaROTH](https://vitadb.rinnegatamante.it/#/info/109) - Port of Zelda: Return of the Hylian<br>
|
||||
[Zelda3T](https://vitadb.rinnegatamante.it/#/info/334) - Port of Zelda: Time to Triumph<br>
|
||||
[ZeldaNSQ](https://vitadb.rinnegatamante.it/#/info/350) - Port of Zelda: Navi's Quest<br>
|
||||
[vitaWolfen](https://vitadb.rinnegatamante.it/#/info/31) - Port of Wolf4SDL<br>
|
||||
[meritous](https://vitadb.rinnegatamante.it/#/info/411) - Port of meritous<br>
|
6
format.bat
Normal file
6
format.bat
Normal file
@ -0,0 +1,6 @@
|
||||
@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 ..
|
40
samples/sample1/Makefile
Normal file
40
samples/sample1/Makefile
Normal file
@ -0,0 +1,40 @@
|
||||
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
|
67
samples/sample1/main.c
Normal file
67
samples/sample1/main.c
Normal file
@ -0,0 +1,67 @@
|
||||
// Drawing a fullscreen image on screen with glBegin/glEnd
|
||||
|
||||
#include <vitaGL.h>
|
||||
#include <vita2d.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
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();
|
||||
|
||||
}
|
BIN
samples/sample1/texture.bmp
Normal file
BIN
samples/sample1/texture.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 MiB |
42
samples/sample2/Makefile
Normal file
42
samples/sample2/Makefile
Normal file
@ -0,0 +1,42 @@
|
||||
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
|
||||
|
39
samples/sample2/main.c
Normal file
39
samples/sample2/main.c
Normal file
@ -0,0 +1,39 @@
|
||||
// Drawing a triangle on screen with vertex array
|
||||
|
||||
#include <vitaGL.h>
|
||||
|
||||
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();
|
||||
|
||||
}
|
38
samples/sample3/Makefile
Normal file
38
samples/sample3/Makefile
Normal file
@ -0,0 +1,38 @@
|
||||
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
|
36
samples/sample3/main.c
Normal file
36
samples/sample3/main.c
Normal file
@ -0,0 +1,36 @@
|
||||
// Drawing a colored quad with glBegin/glEnd
|
||||
|
||||
#include <vitaGL.h>
|
||||
|
||||
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();
|
||||
|
||||
}
|
37
samples/sample4/Makefile
Normal file
37
samples/sample4/Makefile
Normal file
@ -0,0 +1,37 @@
|
||||
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
|
38
samples/sample4/main.c
Normal file
38
samples/sample4/main.c
Normal file
@ -0,0 +1,38 @@
|
||||
// Drawing a quad on screen with glDrawElements
|
||||
|
||||
#include <vitaGL.h>
|
||||
|
||||
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();
|
||||
|
||||
}
|
37
samples/sample5/Makefile
Normal file
37
samples/sample5/Makefile
Normal file
@ -0,0 +1,37 @@
|
||||
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
|
82
samples/sample5/main.c
Normal file
82
samples/sample5/main.c
Normal file
@ -0,0 +1,82 @@
|
||||
// Drawing a rotating cube
|
||||
|
||||
#include <vitaGL.h>
|
||||
#include <math.h>
|
||||
|
||||
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();
|
||||
|
||||
}
|
37
samples/sample6/Makefile
Normal file
37
samples/sample6/Makefile
Normal file
@ -0,0 +1,37 @@
|
||||
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
|
96
samples/sample6/main.c
Normal file
96
samples/sample6/main.c
Normal file
@ -0,0 +1,96 @@
|
||||
// Drawing a rotating cube with VBO
|
||||
|
||||
#include <vitaGL.h>
|
||||
#include <math.h>
|
||||
|
||||
#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();
|
||||
|
||||
}
|
40
samples/sample7/Makefile
Normal file
40
samples/sample7/Makefile
Normal file
@ -0,0 +1,40 @@
|
||||
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
|
91
samples/sample7/main.c
Normal file
91
samples/sample7/main.c
Normal file
@ -0,0 +1,91 @@
|
||||
// Drawing a fullscreen image on screen with glBegin/glEnd
|
||||
|
||||
#include <vitaGL.h>
|
||||
#include <vita2d.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
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();
|
||||
|
||||
}
|
BIN
samples/sample7/texture.bmp
Normal file
BIN
samples/sample7/texture.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 MiB |
4
shaders/clear_f.cg
Normal file
4
shaders/clear_f.cg
Normal file
@ -0,0 +1,4 @@
|
||||
float4 main(uniform float4 u_clear_color) : COLOR
|
||||
{
|
||||
return u_clear_color;
|
||||
}
|
7
shaders/clear_v.cg
Normal file
7
shaders/clear_v.cg
Normal file
@ -0,0 +1,7 @@
|
||||
float4 main(unsigned int idx : INDEX, uniform float4 position) : POSITION
|
||||
{
|
||||
float x = (idx == 1 || idx == 2) ? position[1] : position[0];
|
||||
float y = (idx == 2 || idx == 3) ? position[3] : position[2];
|
||||
|
||||
return float4(x, y, 1.f, 1.f);
|
||||
}
|
5
shaders/disable_color_buffer_f.cg
Normal file
5
shaders/disable_color_buffer_f.cg
Normal file
@ -0,0 +1,5 @@
|
||||
float main(
|
||||
uniform float depth_clear) : DEPTH
|
||||
{
|
||||
return depth_clear;
|
||||
}
|
11
shaders/rgb_v.cg
Normal file
11
shaders/rgb_v.cg
Normal file
@ -0,0 +1,11 @@
|
||||
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.f);
|
||||
}
|
||||
|
4
shaders/rgba_f.cg
Normal file
4
shaders/rgba_f.cg
Normal file
@ -0,0 +1,4 @@
|
||||
float4 main(float4 vColor : COLOR) : COLOR
|
||||
{
|
||||
return vColor;
|
||||
}
|
11
shaders/rgba_v.cg
Normal file
11
shaders/rgba_v.cg
Normal file
@ -0,0 +1,11 @@
|
||||
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;
|
||||
}
|
||||
|
83
shaders/texture2d_f.cg
Normal file
83
shaders/texture2d_f.cg
Normal file
@ -0,0 +1,83 @@
|
||||
float4 main(
|
||||
float2 vTexcoord : TEXCOORD0,
|
||||
float4 coords: WPOS,
|
||||
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,
|
||||
uniform float fog_near,
|
||||
uniform float fog_far,
|
||||
uniform float fog_density
|
||||
)
|
||||
{
|
||||
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){
|
||||
float vFog;
|
||||
if (fog_mode == 0){ // GL_LINEAR
|
||||
vFog = (fog_far - coords.z) / (fog_far - fog_near);
|
||||
}else if (fog_mode == 1){ // GL_EXP
|
||||
vFog = exp(-fog_density * coords.z);
|
||||
}else{ // GL_EXP2
|
||||
const float LOG2 = -1.442695;
|
||||
float d = fog_density * coords.z;
|
||||
vFog = exp(d * d * LOG2);
|
||||
}
|
||||
vFog = clamp(vFog, 0.0, 1.0);
|
||||
texColor.rgb = lerp(fogColor.rgb, texColor.rgb, vFog);
|
||||
}
|
||||
|
||||
return texColor;
|
||||
}
|
83
shaders/texture2d_rgba_f.cg
Normal file
83
shaders/texture2d_rgba_f.cg
Normal file
@ -0,0 +1,83 @@
|
||||
float4 main(
|
||||
float2 vTexcoord : TEXCOORD0,
|
||||
float4 vColor : COLOR,
|
||||
float4 coords: WPOS,
|
||||
uniform sampler2D tex,
|
||||
uniform float alphaCut,
|
||||
uniform int alphaOp,
|
||||
uniform int texEnv,
|
||||
uniform int fog_mode,
|
||||
uniform float4 fogColor,
|
||||
uniform float4 texEnvColor,
|
||||
uniform float fog_near,
|
||||
uniform float fog_far,
|
||||
uniform float fog_density
|
||||
)
|
||||
{
|
||||
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){
|
||||
float vFog;
|
||||
if (fog_mode == 0){ // GL_LINEAR
|
||||
vFog = (fog_far - coords.z) / (fog_far - fog_near);
|
||||
}else if (fog_mode == 1){ // GL_EXP
|
||||
vFog = exp(-fog_density * coords.z);
|
||||
}else{ // GL_EXP2
|
||||
const float LOG2 = -1.442695;
|
||||
float d = fog_density * coords.z;
|
||||
vFog = exp(d * d * LOG2);
|
||||
}
|
||||
vFog = clamp(vFog, 0.0, 1.0);
|
||||
texColor.rgb = lerp(fogColor.rgb, texColor.rgb, vFog);
|
||||
}
|
||||
|
||||
return texColor;
|
||||
}
|
27
shaders/texture2d_rgba_v.cg
Normal file
27
shaders/texture2d_rgba_v.cg
Normal file
@ -0,0 +1,27 @@
|
||||
void main(
|
||||
float3 position,
|
||||
float2 texcoord,
|
||||
float4 color,
|
||||
column_major uniform float4x4 wvp,
|
||||
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,
|
||||
float4 out vPosition : POSITION,
|
||||
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);
|
||||
vTexcoord = texcoord;
|
||||
vColor = color;
|
||||
}
|
24
shaders/texture2d_v.cg
Normal file
24
shaders/texture2d_v.cg
Normal file
@ -0,0 +1,24 @@
|
||||
void main(
|
||||
float3 position,
|
||||
float2 texcoord,
|
||||
column_major uniform float4x4 wvp,
|
||||
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,
|
||||
float4 out vPosition : POSITION,
|
||||
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);
|
||||
vTexcoord = texcoord;
|
||||
}
|
447
source/custom_shaders.c
Normal file
447
source/custom_shaders.c
Normal file
@ -0,0 +1,447 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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:
|
||||
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
|
||||
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:
|
||||
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) {
|
||||
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:
|
||||
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);
|
||||
}
|
184
source/framebuffers.c
Normal file
184
source/framebuffers.c
Normal file
@ -0,0 +1,184 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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:
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
mempool_free(fb->depth_buffer_addr, fb->depth_buffer_mem_type);
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
}
|
202
source/get_info.c
Normal file
202
source/get_info.c
Normal file
@ -0,0 +1,202 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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:
|
||||
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:
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void glGetFloatv(GLenum pname, GLfloat *data) {
|
||||
int i, j;
|
||||
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
|
||||
// Since we use column-major matrices internally, wee need to transpose it before returning it to the application
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (j = 0; j < 4; j++) {
|
||||
data[i*4+j] = modelview_matrix[j][i];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_PROJECTION_MATRIX: // Projection matrix
|
||||
// Since we use column-major matrices internally, wee need to transpose it before returning it to the application
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (j = 0; j < 4; j++) {
|
||||
data[i*4+j] = projection_matrix[j][i];
|
||||
}
|
||||
}
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
GLenum glGetError(void) {
|
||||
GLenum ret = error;
|
||||
error = GL_NO_ERROR;
|
||||
return ret;
|
||||
}
|
397
source/gxm.c
Normal file
397
source/gxm.c
Normal file
@ -0,0 +1,397 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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 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) {
|
||||
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
|
||||
mempool_free(vdm_ring_buffer_addr, VGL_MEM_VRAM);
|
||||
mempool_free(vertex_ring_buffer_addr, VGL_MEM_VRAM);
|
||||
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++) {
|
||||
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_LINEAR,
|
||||
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
|
||||
mempool_free(gxm_depth_surface_addr, VGL_MEM_VRAM);
|
||||
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
|
||||
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
|
||||
sceGxmSetViewport(gxm_context, x_port, x_scale, y_port, y_scale, z_port, z_scale);
|
||||
|
||||
if (scissor_test_state)
|
||||
sceGxmSetRegionClip(gxm_context, SCE_GXM_REGION_CLIP_OUTSIDE, region.x, region.y, region.x + region.w - 1, region.y + region.h - 1);
|
||||
else
|
||||
sceGxmSetRegionClip(gxm_context, SCE_GXM_REGION_CLIP_OUTSIDE, 0, 0, DISPLAY_WIDTH - 1, DISPLAY_HEIGHT - 1);
|
||||
}
|
||||
|
||||
void vglStopRenderingInit(void) {
|
||||
// Ending drawing scene
|
||||
sceGxmEndScene(gxm_context, NULL, NULL);
|
||||
}
|
||||
|
||||
void vglStopRenderingTerm(void) {
|
||||
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);
|
||||
}
|
114
source/hacks/sbrk.c
Normal file
114
source/hacks/sbrk.c
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 vitasdk
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <reent.h>
|
||||
#include <vitasdk.h>
|
||||
|
||||
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;
|
||||
}
|
599
source/legacy.c
Normal file
599
source/legacy.c
Normal file
@ -0,0 +1,599 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
error = GL_INVALID_VALUE;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Aliasing client texture unit for better code readability
|
||||
texture_unit *tex_unit = &texture_units[client_texture_unit];
|
||||
|
||||
// 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) {
|
||||
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:
|
||||
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) {
|
||||
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);
|
||||
sceGxmSetUniformDataF(alpha_buffer, texture2d_fog_near, 0, 1, (const float *)&fog_near);
|
||||
sceGxmSetUniformDataF(alpha_buffer, texture2d_fog_far, 0, 1, (const float *)&fog_far);
|
||||
sceGxmSetUniformDataF(alpha_buffer, texture2d_fog_density, 0, 1, (const float *)&fog_density);
|
||||
|
||||
} 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 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);
|
||||
|
||||
// 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;
|
||||
}
|
222
source/matrices.c
Normal file
222
source/matrices.c
Normal file
@ -0,0 +1,222 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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:
|
||||
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) {
|
||||
error = GL_INVALID_OPERATION;
|
||||
return;
|
||||
} else if ((left == right) || (bottom == top) || (nearVal == farVal)) {
|
||||
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) {
|
||||
error = GL_INVALID_OPERATION;
|
||||
return;
|
||||
} else if ((left == right) || (bottom == top) || (nearVal < 0) || (farVal < 0)) {
|
||||
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;
|
||||
|
||||
// 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);
|
||||
|
||||
// Copying result to in use matrix
|
||||
matrix4x4_copy(*matrix, res);
|
||||
mvp_modified = GL_TRUE;
|
||||
}
|
||||
|
||||
void glLoadMatrixf(const GLfloat *m) {
|
||||
// Properly ordering matrix
|
||||
int i, j;
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (j = 0; j < 4; j++) {
|
||||
(*matrix)[i][j] = m[j * 4 + i];
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
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) {
|
||||
error = GL_INVALID_OPERATION;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (matrix == &modelview_matrix) {
|
||||
#ifndef SKIP_ERROR_HANDLING
|
||||
// Error handling
|
||||
if (modelview_stack_counter >= MODELVIEW_STACK_DEPTH) {
|
||||
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) {
|
||||
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) {
|
||||
error = GL_INVALID_OPERATION;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (matrix == &modelview_matrix) {
|
||||
#ifndef SKIP_ERROR_HANDLING
|
||||
// Error handling
|
||||
if (modelview_stack_counter == 0)
|
||||
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)
|
||||
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;
|
||||
}
|
554
source/misc.c
Normal file
554
source/misc.c
Normal file
@ -0,0 +1,554 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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:
|
||||
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:
|
||||
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)) {
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void glEnable(GLenum cap) {
|
||||
#ifndef SKIP_ERROR_HANDLING
|
||||
if (phase == MODEL_CREATION) {
|
||||
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:
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void glDisable(GLenum cap) {
|
||||
#ifndef SKIP_ERROR_HANDLING
|
||||
if (phase == MODEL_CREATION) {
|
||||
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:
|
||||
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, *vertex_buffer;
|
||||
sceGxmReserveFragmentDefaultUniformBuffer(gxm_context, &color_buffer);
|
||||
sceGxmSetUniformDataF(color_buffer, clear_color, 0, 4, &clear_rgba_val.r);
|
||||
sceGxmReserveVertexDefaultUniformBuffer(gxm_context, &vertex_buffer);
|
||||
sceGxmSetUniformDataF(vertex_buffer, clear_position, 0, 4, &clear_vertices->x);
|
||||
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 ? 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, *vertex_buffer;
|
||||
sceGxmReserveFragmentDefaultUniformBuffer(gxm_context, &depth_buffer);
|
||||
float temp = depth_value;
|
||||
sceGxmSetUniformDataF(depth_buffer, clear_depth, 0, 1, &temp);
|
||||
sceGxmReserveVertexDefaultUniformBuffer(gxm_context, &vertex_buffer);
|
||||
sceGxmSetUniformDataF(vertex_buffer, clear_position, 0, 4, &clear_vertices->x);
|
||||
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 ? 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, *vertex_buffer;
|
||||
sceGxmReserveFragmentDefaultUniformBuffer(gxm_context, &depth_buffer);
|
||||
float temp = 1.0f;
|
||||
sceGxmSetUniformDataF(depth_buffer, clear_depth, 0, 1, &temp);
|
||||
sceGxmReserveVertexDefaultUniformBuffer(gxm_context, &vertex_buffer);
|
||||
sceGxmSetUniformDataF(vertex_buffer, clear_position, 0, 4, &clear_vertices->x);
|
||||
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 ? 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:
|
||||
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:
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void glLineWidth(GLfloat width) {
|
||||
#ifndef SKIP_ERROR_HANDLING
|
||||
// Error handling
|
||||
if (width <= 0) {
|
||||
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) {
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
}
|
105
source/shaders.h
Normal file
105
source/shaders.h
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
*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_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_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
|
23
source/shaders/clear_f.h
Normal file
23
source/shaders/clear_f.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef __clear_f__
|
||||
#define __clear_f__
|
||||
|
||||
static unsigned int size_clear_f = 236;
|
||||
static unsigned char clear_f[] __attribute__((aligned(16))) = {
|
||||
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03, 0xea, 0x00, 0x00, 0x00, 0x31, 0xc7, 0xbe, 0x93,
|
||||
0x4c, 0xc3, 0x26, 0xba, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x64, 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, 0x5c, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa, 0x02, 0x80, 0x19, 0xf0,
|
||||
0x7e, 0x0d, 0x80, 0x40, 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
|
32
source/shaders/clear_v.h
Normal file
32
source/shaders/clear_v.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef __clear_v__
|
||||
#define __clear_v__
|
||||
|
||||
static unsigned int size_clear_v = 372;
|
||||
static unsigned char clear_v[] __attribute__((aligned(16))) = {
|
||||
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03, 0x71, 0x01, 0x00, 0x00, 0xf3, 0x7d, 0x64, 0x50,
|
||||
0xb9, 0x22, 0xc8, 0x0c, 0x04, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x30, 0x01, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0d, 0x00, 0x00, 0x00,
|
||||
0x88, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
|
||||
0x03, 0x00, 0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xc4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbc, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0xb4, 0x00, 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, 0x04,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x10, 0x81,
|
||||
0x0a, 0x05, 0x84, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa,
|
||||
0x04, 0xc0, 0x07, 0xb0, 0x85, 0x01, 0x88, 0x48, 0x06, 0xc0, 0x07, 0xb0, 0x81, 0x01, 0x88, 0x48,
|
||||
0x04, 0xc0, 0x07, 0xb0, 0x81, 0x01, 0x88, 0x4d, 0x00, 0x04, 0x40, 0xe0, 0x09, 0x00, 0x81, 0x50,
|
||||
0x40, 0x00, 0x04, 0xc1, 0x01, 0x05, 0x80, 0x3d, 0x05, 0xc0, 0x07, 0xb0, 0x85, 0x01, 0x88, 0x4e,
|
||||
0x00, 0x00, 0x00, 0xe0, 0x09, 0x00, 0x81, 0x50, 0x00, 0x00, 0x00, 0xc1, 0x09, 0x05, 0x80, 0x3a,
|
||||
0x40, 0x00, 0x00, 0x42, 0x01, 0x05, 0x80, 0x38, 0x01, 0x00, 0x04, 0x50, 0x85, 0x11, 0xa5, 0x08,
|
||||
0x01, 0x80, 0x56, 0x90, 0x81, 0x11, 0x83, 0x08, 0x00, 0x00, 0x20, 0xa0, 0x00, 0x50, 0x27, 0xfb,
|
||||
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
|
||||
0x13, 0x00, 0x00, 0x00, 0x04, 0x00, 0x03, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
#endif
|
26
source/shaders/disable_color_buffer_f.h
Normal file
26
source/shaders/disable_color_buffer_f.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef __disable_color_buffer_f__
|
||||
#define __disable_color_buffer_f__
|
||||
|
||||
static unsigned int size_disable_color_buffer_f = 276;
|
||||
static unsigned char disable_color_buffer_f[] __attribute__((aligned(16))) = {
|
||||
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03, 0x14, 0x01, 0x00, 0x00, 0x4d, 0x94, 0xc7, 0x39,
|
||||
0x5b, 0xce, 0x5e, 0x9b, 0x15, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00,
|
||||
0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x64, 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, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x00, 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
|
36
source/shaders/rgb_v.h
Normal file
36
source/shaders/rgb_v.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef __rgb_v__
|
||||
#define __rgb_v__
|
||||
|
||||
static unsigned int size_rgb_v = 448;
|
||||
static unsigned char rgb_v[] __attribute__((aligned(16))) = {
|
||||
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03, 0xbd, 0x01, 0x00, 0x00, 0xcf, 0x61, 0x92, 0x9a,
|
||||
0x71, 0x82, 0x84, 0xfc, 0x04, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x50, 0x01, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||
0x08, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0a, 0x00, 0x00, 0x00,
|
||||
0xe0, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0xd0, 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, 0x08, 0x01, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe4, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, 0x00, 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, 0x01, 0xc0, 0xa2,
|
||||
0x0a, 0x00, 0x81, 0x50, 0xc0, 0x00, 0x2c, 0x82, 0x02, 0x05, 0x80, 0x38, 0x00, 0x05, 0x00, 0xa3,
|
||||
0x0a, 0x00, 0x81, 0x50, 0xc0, 0x01, 0x30, 0x82, 0x02, 0x05, 0x80, 0x38, 0x07, 0x01, 0x43, 0xa2,
|
||||
0x8e, 0x0d, 0x80, 0x40, 0x0f, 0x05, 0x83, 0xa2, 0x8e, 0x0d, 0x80, 0x40, 0x05, 0x00, 0xc3, 0xa1,
|
||||
0x8e, 0x0d, 0x80, 0x40, 0x0d, 0x04, 0x03, 0xa2, 0x8e, 0x0d, 0x80, 0x40, 0x00, 0x00, 0x40, 0xa0,
|
||||
0x0a, 0x00, 0x81, 0x50, 0x80, 0x00, 0x04, 0x82, 0x02, 0x05, 0x80, 0x38, 0x00, 0x04, 0x00, 0xa0,
|
||||
0x0a, 0x00, 0x81, 0x50, 0x80, 0x01, 0x00, 0x82, 0x02, 0x05, 0x84, 0x38, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa, 0x81, 0x00, 0x84, 0x90, 0x85, 0x19, 0xa5, 0x08,
|
||||
0x02, 0x80, 0x81, 0xaf, 0x9c, 0x0d, 0xc0, 0x40, 0x14, 0x89, 0xb9, 0xff, 0xbc, 0x0d, 0xc0, 0x40,
|
||||
0x0b, 0x11, 0x49, 0xcf, 0x80, 0x8f, 0xb1, 0x18, 0x07, 0x11, 0x45, 0xcf, 0x80, 0x8f, 0xb1, 0x18,
|
||||
0x01, 0x11, 0x01, 0xc0, 0x81, 0x81, 0xb1, 0x18, 0x00, 0xd1, 0x42, 0xc0, 0x81, 0x81, 0xb1, 0x18,
|
||||
0xc1, 0x00, 0xd4, 0x90, 0x89, 0x11, 0xc1, 0x08, 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
|
22
source/shaders/rgba_f.h
Normal file
22
source/shaders/rgba_f.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef __rgba_f__
|
||||
#define __rgba_f__
|
||||
|
||||
static unsigned int size_rgba_f = 212;
|
||||
static unsigned char rgba_f[] __attribute__((aligned(16))) = {
|
||||
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03, 0xd4, 0x00, 0x00, 0x00, 0x9c, 0xd6, 0x9b, 0xf7,
|
||||
0x94, 0x1a, 0xc4, 0x74, 0x01, 0x10, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x74, 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, 0x6c, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 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, 0xd0, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa, 0x02, 0x80, 0x19, 0xa0,
|
||||
0x7e, 0x0d, 0x80, 0x40,
|
||||
};
|
||||
|
||||
#endif
|
36
source/shaders/rgba_v.h
Normal file
36
source/shaders/rgba_v.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef __rgba_v__
|
||||
#define __rgba_v__
|
||||
|
||||
static unsigned int size_rgba_v = 440;
|
||||
static unsigned char rgba_v[] __attribute__((aligned(16))) = {
|
||||
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03, 0xb5, 0x01, 0x00, 0x00, 0x24, 0xdc, 0x9e, 0xbb,
|
||||
0xe8, 0xbd, 0x34, 0xb5, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x48, 0x01, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||
0x08, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x09, 0x00, 0x00, 0x00,
|
||||
0xe0, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0xd0, 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, 0x00, 0x01, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf4, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xe4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x00, 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, 0x01, 0xc0, 0xa2,
|
||||
0x0a, 0x00, 0x81, 0x50, 0xc0, 0x00, 0x2c, 0x82, 0x02, 0x05, 0x80, 0x38, 0x00, 0x05, 0x00, 0xa3,
|
||||
0x0a, 0x00, 0x81, 0x50, 0xc0, 0x01, 0x30, 0x82, 0x02, 0x05, 0x80, 0x38, 0x07, 0x01, 0x43, 0xa2,
|
||||
0x8e, 0x0d, 0x80, 0x40, 0x0f, 0x05, 0x83, 0xa2, 0x8e, 0x0d, 0x80, 0x40, 0x05, 0x00, 0xc3, 0xa1,
|
||||
0x8e, 0x0d, 0x80, 0x40, 0x0d, 0x04, 0x03, 0xa2, 0x8e, 0x0d, 0x80, 0x40, 0x00, 0x00, 0x40, 0xa0,
|
||||
0x0a, 0x00, 0x81, 0x50, 0x80, 0x00, 0x04, 0x82, 0x02, 0x05, 0x80, 0x38, 0x00, 0x04, 0x00, 0xa0,
|
||||
0x0a, 0x00, 0x81, 0x50, 0x80, 0x01, 0x00, 0x82, 0x02, 0x05, 0x84, 0x38, 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, 0xc0, 0x40, 0x14, 0x89, 0xb9, 0xff, 0xbc, 0x0d, 0xc0, 0x40,
|
||||
0x0b, 0x11, 0x49, 0xcf, 0x80, 0x8f, 0xb1, 0x18, 0x07, 0x11, 0x45, 0xcf, 0x80, 0x8f, 0xb1, 0x18,
|
||||
0x01, 0x11, 0x01, 0xc0, 0x81, 0x81, 0xb1, 0x18, 0x00, 0xd1, 0x42, 0xc0, 0x81, 0x81, 0xb1, 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
|
89
source/shaders/texture2d_f.h
Normal file
89
source/shaders/texture2d_f.h
Normal file
@ -0,0 +1,89 @@
|
||||
#ifndef __texture2d_f__
|
||||
#define __texture2d_f__
|
||||
|
||||
static unsigned int size_texture2d_f = 1284;
|
||||
static unsigned char texture2d_f[] __attribute__((aligned(16))) = {
|
||||
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03, 0x01, 0x05, 0x00, 0x00, 0xa0, 0xad, 0x6e, 0x36,
|
||||
0x32, 0x6a, 0xc9, 0x2c, 0x09, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa8, 0x03, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||
0x08, 0x00, 0x24, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x4d, 0x00, 0x00, 0x00,
|
||||
0xc0, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x58, 0x03, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
|
||||
0x0b, 0x00, 0x00, 0x00, 0xf4, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x03, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3c, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x03, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x2c, 0x03, 0x00, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x01, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x00, 0xd9, 0xc0, 0x0e, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
|
||||
0x47, 0x10, 0x44, 0xa4, 0xa6, 0x41, 0xa4, 0x08, 0x88, 0x10, 0x04, 0xa4, 0xaa, 0x00, 0xc0, 0x08,
|
||||
0xcf, 0x00, 0x04, 0xa2, 0xa6, 0x08, 0xa4, 0x08, 0x49, 0x12, 0x04, 0xaf, 0xa4, 0x10, 0xa4, 0x08,
|
||||
0x02, 0x3e, 0x00, 0x00, 0x02, 0x00, 0x80, 0x30, 0x40, 0x82, 0xe4, 0xa1, 0x82, 0x10, 0x84, 0x08,
|
||||
0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0x04, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x44, 0xfa, 0x17, 0x84, 0x07, 0xf0, 0x81, 0x06, 0xa8, 0x48,
|
||||
0x04, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x04, 0x02, 0x03, 0xa0, 0x8c, 0x0d, 0x80, 0x40,
|
||||
0x06, 0x03, 0x43, 0xa0, 0x8c, 0x0d, 0x80, 0x40, 0x1a, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf8,
|
||||
0x15, 0x84, 0x07, 0xf0, 0x81, 0x01, 0xa8, 0x48, 0x81, 0x00, 0x04, 0xb0, 0x84, 0x41, 0xa4, 0x08,
|
||||
0xc2, 0x00, 0x44, 0xb0, 0x88, 0x41, 0xc0, 0x08, 0x16, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9,
|
||||
0x16, 0x84, 0x07, 0xf0, 0x81, 0x01, 0xa8, 0x48, 0x0f, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9,
|
||||
0x18, 0x84, 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,
|
||||
0x02, 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,
|
||||
0x03, 0x0f, 0x4c, 0x20, 0x00, 0x11, 0x80, 0x08, 0x0a, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf8,
|
||||
0x41, 0x24, 0x00, 0xf0, 0x84, 0x91, 0xa0, 0x00, 0x02, 0x34, 0x40, 0xf0, 0x84, 0x00, 0x80, 0x00,
|
||||
0x83, 0x00, 0x46, 0xe0, 0x08, 0x11, 0xc0, 0x08, 0x06, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf8,
|
||||
0x80, 0x02, 0x60, 0xe0, 0x08, 0x00, 0xc1, 0x50, 0x04, 0x81, 0x81, 0xff, 0x9c, 0x0d, 0xc0, 0x40,
|
||||
0x43, 0x00, 0x11, 0x8f, 0xc0, 0x8b, 0xb1, 0x18, 0xbc, 0x30, 0x04, 0x80, 0x84, 0x91, 0x80, 0x00,
|
||||
0xfc, 0x30, 0x50, 0x80, 0x84, 0x40, 0x80, 0x00, 0x9a, 0x83, 0x07, 0xf0, 0x81, 0x06, 0xa8, 0x48,
|
||||
0x03, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x0c, 0xa0, 0x85, 0x01, 0x8b, 0x48,
|
||||
0x12, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf8, 0x95, 0x83, 0x07, 0xf0, 0x81, 0x01, 0xa8, 0x48,
|
||||
0x80, 0x80, 0x03, 0x30, 0x15, 0xc9, 0x88, 0x48, 0x0f, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9,
|
||||
0x96, 0x83, 0x07, 0xf0, 0x81, 0x01, 0xa8, 0x48, 0x80, 0x80, 0x03, 0x30, 0x95, 0xca, 0x88, 0x48,
|
||||
0x0c, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x98, 0x83, 0x07, 0xf0, 0x81, 0x01, 0xa8, 0x48,
|
||||
0x80, 0x80, 0x03, 0x30, 0x95, 0xc2, 0x88, 0x48, 0x09, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9,
|
||||
0x99, 0x83, 0x07, 0xf0, 0x81, 0x01, 0xa8, 0x48, 0x80, 0x80, 0x03, 0x30, 0x95, 0xc1, 0x88, 0x48,
|
||||
0x06, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x97, 0x83, 0x07, 0xf0, 0x81, 0x01, 0xa8, 0x48,
|
||||
0x80, 0x80, 0x03, 0x30, 0x15, 0xc5, 0x88, 0x48, 0x03, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9,
|
||||
0x9b, 0x83, 0x07, 0xf0, 0x85, 0x01, 0x88, 0x48, 0x80, 0x80, 0x03, 0x30, 0x95, 0xc6, 0x88, 0x4a,
|
||||
0x14, 0x0a, 0x00, 0xf0, 0x06, 0x04, 0x30, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0x04, 0xf8,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa, 0x99, 0x84, 0x07, 0xf0, 0x81, 0x06, 0xa8, 0x48,
|
||||
0x14, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xfd, 0x95, 0x84, 0x07, 0xf0, 0x81, 0x01, 0xa8, 0x48,
|
||||
0x0b, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x96, 0x84, 0x07, 0xf0, 0x81, 0x01, 0xa8, 0x48,
|
||||
0x06, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0xc1, 0x00, 0x00, 0xe0, 0x82, 0x08, 0x80, 0x08,
|
||||
0x00, 0x00, 0x00, 0xaf, 0x80, 0x08, 0x80, 0x08, 0x4e, 0x80, 0x01, 0xcf, 0x80, 0x80, 0xe1, 0x18,
|
||||
0x01, 0x3e, 0x00, 0x00, 0x02, 0x06, 0x80, 0x30, 0x05, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf8,
|
||||
0x01, 0x02, 0x00, 0xe0, 0x82, 0x00, 0x80, 0x08, 0x01, 0x00, 0x00, 0x80, 0x02, 0x06, 0x80, 0x30,
|
||||
0x02, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf8, 0x07, 0x10, 0x10, 0xf0, 0xa6, 0x00, 0x80, 0x00,
|
||||
0x0e, 0x50, 0x04, 0xb0, 0x86, 0x08, 0xa4, 0x08, 0x00, 0x60, 0x00, 0x9f, 0x80, 0x08, 0xa5, 0x08,
|
||||
0x0c, 0x85, 0xa1, 0xff, 0x9c, 0x0d, 0xc0, 0x40, 0x3d, 0x11, 0x41, 0x0f, 0xc0, 0x8b, 0xb1, 0x18,
|
||||
0x00, 0x11, 0x01, 0x00, 0x80, 0x81, 0xb1, 0x18, 0x01, 0x90, 0x40, 0x00, 0x80, 0x80, 0xb1, 0x18,
|
||||
0x02, 0x80, 0x19, 0x00, 0x7e, 0x0d, 0x80, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 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,
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x09, 0x00, 0x00, 0x00, 0x26, 0x35, 0x05, 0xc0,
|
||||
0x0a, 0x00, 0x00, 0x00, 0x3b, 0xaa, 0xb8, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00,
|
||||
0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x13, 0x00, 0x00, 0x00, 0x14, 0x00, 0x0b, 0x00,
|
||||
0xd0, 0x00, 0x00, 0x00, 0x01, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xc9, 0x00, 0x00, 0x00, 0x41, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
|
||||
0xc1, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0xbb, 0x00, 0x00, 0x00, 0x41, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
|
||||
0xb2, 0x00, 0x00, 0x00, 0x41, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
|
||||
0xab, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
|
||||
0xa4, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
|
||||
0xa0, 0x00, 0x00, 0x00, 0x01, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00,
|
||||
0x99, 0x00, 0x00, 0x00, 0x01, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
|
||||
0x91, 0x00, 0x00, 0x00, 0x01, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
|
||||
0x8d, 0x00, 0x00, 0x00, 0x02, 0x04, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x03, 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, 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,
|
||||
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, 0x74, 0x65, 0x78,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
#endif
|
91
source/shaders/texture2d_rgba_f.h
Normal file
91
source/shaders/texture2d_rgba_f.h
Normal file
@ -0,0 +1,91 @@
|
||||
#ifndef __texture2d_rgba_f__
|
||||
#define __texture2d_rgba_f__
|
||||
|
||||
static unsigned int size_texture2d_rgba_f = 1320;
|
||||
static unsigned char texture2d_rgba_f[] __attribute__((aligned(16))) = {
|
||||
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03, 0x27, 0x05, 0x00, 0x00, 0xf0, 0x40, 0x0f, 0xe9,
|
||||
0x85, 0x99, 0xb7, 0x4d, 0x09, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||
0x0c, 0x00, 0x1b, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x55, 0x00, 0x00, 0x00,
|
||||
0xc0, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x98, 0x03, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
|
||||
0x0b, 0x00, 0x00, 0x00, 0x34, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x94, 0x03, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x7c, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x03, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x6c, 0x03, 0x00, 0x00, 0x18, 0x04, 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, 0xd0, 0xc0, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x0d, 0x80, 0x68, 0xa3, 0xa6, 0x08, 0xc0, 0x08, 0xc7, 0x11, 0x04, 0xaf, 0xa4, 0x10, 0xa4, 0x08,
|
||||
0x02, 0x3e, 0x40, 0x00, 0x02, 0x00, 0x80, 0x30, 0xc2, 0x81, 0xe4, 0xa1, 0x82, 0x10, 0x84, 0x08,
|
||||
0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0x04, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x44, 0xfa, 0x93, 0x81, 0x07, 0xf0, 0x81, 0x06, 0xa8, 0x48,
|
||||
0x04, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x04, 0x02, 0x03, 0xa0, 0x8c, 0x0d, 0x80, 0x40,
|
||||
0x06, 0x03, 0x43, 0xa0, 0x8e, 0x0d, 0x80, 0x40, 0x20, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf8,
|
||||
0x91, 0x81, 0x07, 0xf0, 0x81, 0x01, 0xa8, 0x48, 0x80, 0x00, 0x04, 0xa0, 0x84, 0x41, 0xa4, 0x08,
|
||||
0xc1, 0x00, 0x04, 0xa1, 0x8a, 0x41, 0xc0, 0x08, 0x1b, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9,
|
||||
0x92, 0x81, 0x07, 0xf0, 0x81, 0x01, 0xa8, 0x48, 0x13, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9,
|
||||
0x94, 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, 0x84, 0x09, 0xa5, 0x08, 0x40, 0x6f, 0x4d, 0x10, 0x82, 0x00, 0x81, 0x08,
|
||||
0x03, 0x0f, 0x4c, 0x20, 0x02, 0x11, 0x80, 0x08, 0x10, 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, 0x05, 0x01, 0x91, 0xdf, 0x80, 0x8b, 0xb1, 0x18,
|
||||
0x3d, 0x21, 0x11, 0x00, 0xc0, 0x89, 0xb1, 0x18, 0xbd, 0xa0, 0x48, 0x00, 0xc2, 0x80, 0xb1, 0x18,
|
||||
0x03, 0x0f, 0x4c, 0x20, 0x02, 0x11, 0x80, 0x08, 0x08, 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, 0x80, 0x81, 0xa0, 0x00,
|
||||
0xc1, 0xc0, 0x5b, 0xa0, 0x82, 0x00, 0x80, 0x00, 0x02, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf8,
|
||||
0x08, 0x04, 0x43, 0xa0, 0x8e, 0x0d, 0x80, 0x40, 0x16, 0x81, 0x07, 0xf0, 0x81, 0x06, 0xa8, 0x48,
|
||||
0x03, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x0c, 0xa0, 0x85, 0x01, 0x8b, 0x48,
|
||||
0x12, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf8, 0x11, 0x81, 0x07, 0xf0, 0x81, 0x01, 0xa8, 0x48,
|
||||
0x80, 0x80, 0x03, 0xb0, 0x15, 0xc9, 0x88, 0x48, 0x0f, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9,
|
||||
0x12, 0x81, 0x07, 0xf0, 0x81, 0x01, 0xa8, 0x48, 0x80, 0x80, 0x03, 0xb0, 0x95, 0xca, 0x88, 0x48,
|
||||
0x0c, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x14, 0x81, 0x07, 0xf0, 0x81, 0x01, 0xa8, 0x48,
|
||||
0x80, 0x80, 0x03, 0xb0, 0x95, 0xc2, 0x88, 0x48, 0x09, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9,
|
||||
0x15, 0x81, 0x07, 0xf0, 0x81, 0x01, 0xa8, 0x48, 0x80, 0x80, 0x03, 0xb0, 0x95, 0xc1, 0x88, 0x48,
|
||||
0x06, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x13, 0x81, 0x07, 0xf0, 0x81, 0x01, 0xa8, 0x48,
|
||||
0x80, 0x80, 0x03, 0xb0, 0x15, 0xc5, 0x88, 0x48, 0x03, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9,
|
||||
0x17, 0x81, 0x07, 0xf0, 0x85, 0x01, 0x88, 0x48, 0x80, 0x80, 0x03, 0xb0, 0x95, 0xc6, 0x88, 0x4a,
|
||||
0x10, 0x08, 0x00, 0xf0, 0x06, 0x04, 0x30, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0x04, 0xf8,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa, 0x15, 0x82, 0x07, 0xf0, 0x81, 0x06, 0xa8, 0x48,
|
||||
0x03, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x03, 0x00, 0x8e, 0x0d, 0x80, 0x40,
|
||||
0x14, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf8, 0x11, 0x82, 0x07, 0xf0, 0x81, 0x01, 0xa8, 0x48,
|
||||
0x0b, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x12, 0x82, 0x07, 0xf0, 0x81, 0x01, 0xa8, 0x48,
|
||||
0x06, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf9, 0x05, 0x80, 0x24, 0xe0, 0x82, 0x08, 0x84, 0x08,
|
||||
0x00, 0x00, 0x00, 0xaf, 0x80, 0x08, 0x80, 0x08, 0x4c, 0x80, 0x01, 0xcf, 0x80, 0x80, 0xe1, 0x18,
|
||||
0x01, 0x3e, 0x00, 0x00, 0x02, 0x06, 0x80, 0x30, 0x05, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf8,
|
||||
0x45, 0x03, 0x00, 0xe0, 0x82, 0x00, 0x80, 0x08, 0x01, 0x00, 0x00, 0x80, 0x02, 0x06, 0x80, 0x30,
|
||||
0x02, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xf8, 0x87, 0x50, 0x10, 0xf0, 0xa6, 0x00, 0x80, 0x00,
|
||||
0x0c, 0x50, 0x04, 0xb0, 0x86, 0x08, 0xa4, 0x08, 0x00, 0x60, 0x00, 0x9f, 0x80, 0x08, 0xa5, 0x08,
|
||||
0x08, 0x83, 0xa1, 0xff, 0x9c, 0x0d, 0xc0, 0x40, 0x3d, 0x11, 0x41, 0x0f, 0xc0, 0x8b, 0xb1, 0x18,
|
||||
0x00, 0x11, 0x01, 0x00, 0x82, 0x81, 0xb1, 0x18, 0x01, 0x90, 0x40, 0x80, 0x82, 0x80, 0xb1, 0x18,
|
||||
0x02, 0x80, 0x19, 0xa0, 0x7e, 0x0d, 0x80, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 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,
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x09, 0x00, 0x00, 0x00, 0x26, 0x35, 0x05, 0xc0,
|
||||
0x0a, 0x00, 0x00, 0x00, 0x3b, 0xaa, 0xb8, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00,
|
||||
0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x10, 0x00, 0x0b, 0x00,
|
||||
0xc0, 0x00, 0x00, 0x00, 0x01, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xb9, 0x00, 0x00, 0x00, 0x41, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0xb1, 0x00, 0x00, 0x00, 0x41, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0xa8, 0x00, 0x00, 0x00, 0x41, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0xa1, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
|
||||
0x9a, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
|
||||
0x96, 0x00, 0x00, 0x00, 0x01, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
|
||||
0x8f, 0x00, 0x00, 0x00, 0x01, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
|
||||
0x87, 0x00, 0x00, 0x00, 0x01, 0xe1, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x83, 0x00, 0x00, 0x00, 0x02, 0x04, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x03, 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, 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, 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, 0x74, 0x65, 0x78, 0x00, 0x00,
|
||||
};
|
||||
|
||||
#endif
|
50
source/shaders/texture2d_rgba_v.h
Normal file
50
source/shaders/texture2d_rgba_v.h
Normal file
@ -0,0 +1,50 @@
|
||||
#ifndef __texture2d_rgba_v__
|
||||
#define __texture2d_rgba_v__
|
||||
|
||||
static unsigned int size_texture2d_rgba_v = 668;
|
||||
static unsigned char texture2d_rgba_v[] __attribute__((aligned(16))) = {
|
||||
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03, 0x99, 0x02, 0x00, 0x00, 0x03, 0x54, 0x4f, 0xaa,
|
||||
0x6e, 0x7a, 0x89, 0x04, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||
0x0c, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x15, 0x00, 0x00, 0x00,
|
||||
0xe0, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x70, 0x01, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x54, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x54, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x01, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x44, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0x0f, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x18, 0x00, 0x0b,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xa6,
|
||||
0x0a, 0x00, 0x81, 0x50, 0xc0, 0x00, 0x60, 0x82, 0x02, 0x05, 0x80, 0x38, 0x00, 0x05, 0x40, 0xa6,
|
||||
0x0a, 0x00, 0x81, 0x50, 0xc0, 0x01, 0x64, 0x82, 0x02, 0x05, 0x80, 0x38, 0x07, 0x01, 0x83, 0xa5,
|
||||
0x8e, 0x0d, 0x80, 0x40, 0x0f, 0x05, 0xc3, 0xa5, 0x8e, 0x0d, 0x80, 0x40, 0x05, 0x00, 0x03, 0xa5,
|
||||
0x8e, 0x0d, 0x80, 0x40, 0x0d, 0x04, 0x43, 0xa5, 0x8e, 0x0d, 0x80, 0x40, 0x00, 0x00, 0x40, 0xa0,
|
||||
0x0a, 0x00, 0x81, 0x50, 0x80, 0x00, 0x04, 0x82, 0x02, 0x05, 0x80, 0x38, 0x00, 0x04, 0x00, 0xa0,
|
||||
0x0a, 0x00, 0x81, 0x50, 0x80, 0x01, 0x00, 0x82, 0x02, 0x05, 0x84, 0x38, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa, 0x01, 0x0e, 0x01, 0x01, 0x02, 0x00, 0x10, 0xfa,
|
||||
0x80, 0x00, 0x08, 0x83, 0x21, 0x25, 0x80, 0x38, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x10, 0xfa,
|
||||
0x27, 0x90, 0x07, 0xf0, 0x81, 0x06, 0xc8, 0x48, 0xc0, 0x04, 0xf0, 0xc1, 0x00, 0x05, 0x80, 0x38,
|
||||
0x41, 0x92, 0x40, 0x41, 0x81, 0x80, 0xd3, 0x18, 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, 0x24, 0x91, 0x99, 0xff, 0xbc, 0x0d, 0x80, 0x40,
|
||||
0x02, 0xa2, 0x51, 0x81, 0x81, 0x80, 0xd1, 0x18, 0x00, 0x00, 0x00, 0x00, 0x40, 0x09, 0x00, 0xf8,
|
||||
0x02, 0x80, 0x81, 0xaf, 0x9c, 0x0d, 0xc0, 0x40, 0x2e, 0x96, 0xb9, 0xff, 0xbc, 0x0d, 0xc0, 0x40,
|
||||
0x18, 0x11, 0x49, 0xcf, 0x80, 0x8f, 0xb1, 0x18, 0x14, 0x11, 0x45, 0xcf, 0x80, 0x8f, 0xb1, 0x18,
|
||||
0x01, 0x11, 0x01, 0xc0, 0x81, 0x81, 0xb1, 0x18, 0x00, 0xd1, 0x42, 0xc0, 0x81, 0x81, 0xb1, 0x18,
|
||||
0x00, 0x00, 0x20, 0xa0, 0x00, 0x50, 0x27, 0xfb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f,
|
||||
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x00,
|
||||
0x13, 0x00, 0x00, 0x00, 0x26, 0x00, 0x02, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x41, 0xe1, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x10, 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, 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, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
#endif
|
48
source/shaders/texture2d_v.h
Normal file
48
source/shaders/texture2d_v.h
Normal file
@ -0,0 +1,48 @@
|
||||
#ifndef __texture2d_v__
|
||||
#define __texture2d_v__
|
||||
|
||||
static unsigned int size_texture2d_v = 628;
|
||||
static unsigned char texture2d_v[] __attribute__((aligned(16))) = {
|
||||
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03, 0x73, 0x02, 0x00, 0x00, 0xd5, 0xed, 0x20, 0x1e,
|
||||
0xe4, 0x17, 0x9c, 0x83, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||
0x08, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x13, 0x00, 0x00, 0x00,
|
||||
0xe0, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x44, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x44, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x01, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x34, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x07,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xa6,
|
||||
0x0a, 0x00, 0x81, 0x50, 0xc0, 0x00, 0x60, 0x82, 0x02, 0x05, 0x80, 0x38, 0x00, 0x05, 0x40, 0xa6,
|
||||
0x0a, 0x00, 0x81, 0x50, 0xc0, 0x01, 0x64, 0x82, 0x02, 0x05, 0x80, 0x38, 0x07, 0x01, 0x83, 0xa5,
|
||||
0x8e, 0x0d, 0x80, 0x40, 0x0f, 0x05, 0xc3, 0xa5, 0x8e, 0x0d, 0x80, 0x40, 0x05, 0x00, 0x03, 0xa5,
|
||||
0x8e, 0x0d, 0x80, 0x40, 0x0d, 0x04, 0x43, 0xa5, 0x8e, 0x0d, 0x80, 0x40, 0x00, 0x00, 0x40, 0xa0,
|
||||
0x0a, 0x00, 0x81, 0x50, 0x80, 0x00, 0x04, 0x82, 0x02, 0x05, 0x80, 0x38, 0x00, 0x04, 0x00, 0xa0,
|
||||
0x0a, 0x00, 0x81, 0x50, 0x80, 0x01, 0x00, 0x82, 0x02, 0x05, 0x84, 0x38, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa, 0x80, 0x00, 0x08, 0x83, 0x21, 0x05, 0x80, 0x38,
|
||||
0x27, 0x90, 0x07, 0xf0, 0x81, 0x06, 0xc8, 0x48, 0xc0, 0x04, 0xf0, 0xc1, 0x00, 0x05, 0x80, 0x38,
|
||||
0x41, 0x92, 0xc0, 0x40, 0x81, 0x80, 0xd3, 0x18, 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, 0x24, 0x91, 0x99, 0xff, 0xbc, 0x0d, 0x80, 0x40,
|
||||
0x00, 0xa2, 0xd1, 0x40, 0x81, 0x80, 0xd1, 0x18, 0x00, 0x00, 0x00, 0x00, 0x40, 0x09, 0x00, 0xf8,
|
||||
0x02, 0x80, 0x81, 0xaf, 0x9c, 0x0d, 0xc0, 0x40, 0x2e, 0x96, 0xb9, 0xff, 0xbc, 0x0d, 0xc0, 0x40,
|
||||
0x18, 0x11, 0x49, 0xcf, 0x80, 0x8f, 0xb1, 0x18, 0x14, 0x11, 0x45, 0xcf, 0x80, 0x8f, 0xb1, 0x18,
|
||||
0x01, 0x11, 0x01, 0xc0, 0x81, 0x81, 0xb1, 0x18, 0x00, 0xd1, 0x42, 0xc0, 0x81, 0x81, 0xb1, 0x18,
|
||||
0x00, 0x00, 0x20, 0xa0, 0x00, 0x50, 0x27, 0xfb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f,
|
||||
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x00,
|
||||
0x13, 0x00, 0x00, 0x00, 0x26, 0x00, 0x02, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x41, 0xe1, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x10, 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, 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, 0x00,
|
||||
};
|
||||
|
||||
#endif
|
191
source/shared.h
Normal file
191
source/shared.h
Normal file
@ -0,0 +1,191 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <vitasdk.h>
|
||||
|
||||
#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;
|
||||
extern GLboolean use_extra_mem;
|
||||
|
||||
// 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;
|
||||
|
||||
// Fullscreen sceGxm viewport (NOTE: origin is on center screen)
|
||||
extern float fullscreen_x_port;
|
||||
extern float fullscreen_y_port;
|
||||
extern float fullscreen_z_port;
|
||||
extern float fullscreen_x_scale;
|
||||
extern float fullscreen_y_scale;
|
||||
extern float fullscreen_z_scale;
|
||||
|
||||
extern SceGxmContext *gxm_context; // sceGxm context instance
|
||||
extern GLenum 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 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 vector4f *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 vector4f *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 vector4f_convert_to_local_space(vector4f *out, int x, int y, int width, int height); // Converts screen coords to local space
|
||||
|
||||
#endif
|
71
source/state.c
Normal file
71
source/state.c
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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
|
209
source/state.h
Normal file
209
source/state.h
Normal file
@ -0,0 +1,209 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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
|
508
source/tests.c
Normal file
508
source/tests.c
Normal file
@ -0,0 +1,508 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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
|
||||
vector4f *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 ? 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() {
|
||||
// Restoring original depth test state
|
||||
depth_test_state = orig_depth_test;
|
||||
|
||||
// Invoking a depth function update
|
||||
change_depth_func();
|
||||
}
|
||||
|
||||
void invalidate_viewport() {
|
||||
// Invalidating current viewport
|
||||
sceGxmSetViewport(gxm_context, fullscreen_x_port, fullscreen_x_scale, fullscreen_y_port, fullscreen_y_scale, fullscreen_z_port, fullscreen_z_scale);
|
||||
}
|
||||
|
||||
void validate_viewport() {
|
||||
// Restoring original viewport
|
||||
sceGxmSetViewport(gxm_context, x_port, x_scale, y_port, y_scale, z_port, z_scale);
|
||||
}
|
||||
|
||||
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() {
|
||||
// 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);
|
||||
|
||||
// Invalidating viewport
|
||||
invalidate_viewport();
|
||||
|
||||
// Invalidating internal tile based region clip
|
||||
sceGxmSetRegionClip(gxm_context, SCE_GXM_REGION_CLIP_OUTSIDE, 0, 0, DISPLAY_WIDTH - 1, DISPLAY_HEIGHT - 1);
|
||||
|
||||
if (scissor_test_state) {
|
||||
// Calculating scissor test region vertices
|
||||
vector4f_convert_to_local_space(scissor_test_vertices, region.x, region.y, region.w, region.h);
|
||||
|
||||
void *vertex_buffer;
|
||||
sceGxmReserveVertexDefaultUniformBuffer(gxm_context, &vertex_buffer);
|
||||
sceGxmSetUniformDataF(vertex_buffer, clear_position, 0, 4, &clear_vertices->x);
|
||||
|
||||
// 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);
|
||||
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);
|
||||
|
||||
void *vertex_buffer;
|
||||
sceGxmReserveVertexDefaultUniformBuffer(gxm_context, &vertex_buffer);
|
||||
if (scissor_test_state)
|
||||
sceGxmSetUniformDataF(vertex_buffer, clear_position, 0, 4, &scissor_test_vertices->x);
|
||||
else
|
||||
sceGxmSetUniformDataF(vertex_buffer, clear_position, 0, 4, &clear_vertices->x);
|
||||
sceGxmDraw(gxm_context, SCE_GXM_PRIMITIVE_TRIANGLE_FAN, SCE_GXM_INDEX_FORMAT_U16, depth_clear_indices, 4);
|
||||
|
||||
// Restoring viewport
|
||||
validate_viewport();
|
||||
|
||||
// Reducing GPU workload by performing tile granularity clipping
|
||||
if (scissor_test_state)
|
||||
sceGxmSetRegionClip(gxm_context, SCE_GXM_REGION_CLIP_OUTSIDE, region.x, region.y, region.x + region.w - 1, region.y + region.h - 1);
|
||||
|
||||
// Restoring original stencil test settings
|
||||
change_stencil_settings();
|
||||
}
|
||||
|
||||
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)) {
|
||||
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) {
|
||||
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 ? 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))
|
||||
error = GL_INVALID_ENUM;
|
||||
if (!change_stencil_config(&depth_fail_front, dpfail))
|
||||
error = GL_INVALID_ENUM;
|
||||
if (!change_stencil_config(&depth_pass_front, dppass))
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
case GL_BACK:
|
||||
if (!change_stencil_config(&stencil_fail_back, sfail))
|
||||
error = GL_INVALID_ENUM;
|
||||
if (!change_stencil_config(&depth_fail_back, dpfail))
|
||||
error = GL_INVALID_ENUM;
|
||||
if (!change_stencil_config(&depth_pass_front, dppass))
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
case GL_FRONT_AND_BACK:
|
||||
if (!change_stencil_config(&stencil_fail_front, sfail))
|
||||
error = GL_INVALID_ENUM;
|
||||
if (!change_stencil_config(&stencil_fail_back, sfail))
|
||||
error = GL_INVALID_ENUM;
|
||||
if (!change_stencil_config(&depth_fail_front, dpfail))
|
||||
error = GL_INVALID_ENUM;
|
||||
if (!change_stencil_config(&depth_fail_back, dpfail))
|
||||
error = GL_INVALID_ENUM;
|
||||
if (!change_stencil_config(&depth_pass_front, dppass))
|
||||
error = GL_INVALID_ENUM;
|
||||
if (!change_stencil_config(&depth_pass_back, dppass))
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
default:
|
||||
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))
|
||||
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))
|
||||
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))
|
||||
error = GL_INVALID_ENUM;
|
||||
if (!change_stencil_func_config(&stencil_func_back, func))
|
||||
error = GL_INVALID_ENUM;
|
||||
stencil_mask_front = stencil_mask_back = mask;
|
||||
stencil_ref_front = stencil_ref_back = ref;
|
||||
break;
|
||||
default:
|
||||
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:
|
||||
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;
|
||||
}
|
95
source/texture_callbacks.c
Normal file
95
source/texture_callbacks.c
Normal file
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* texture_callbacks.c:
|
||||
* Implementation for texture data reading/writing callbacks
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <vitasdk.h>
|
||||
|
||||
#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);
|
||||
}
|
41
source/texture_callbacks.h
Normal file
41
source/texture_callbacks.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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
|
748
source/textures.c
Normal file
748
source/textures.c
Normal file
@ -0,0 +1,748 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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) {
|
||||
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:
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void glDeleteTextures(GLsizei n, const GLuint *gl_textures) {
|
||||
#ifndef SKIP_ERROR_HANDLING
|
||||
// Error handling
|
||||
if (n < 0) {
|
||||
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:
|
||||
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:
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case GL_RGB:
|
||||
switch (type) {
|
||||
case GL_UNSIGNED_BYTE:
|
||||
data_bpp = 3;
|
||||
read_cb = readRGB;
|
||||
break;
|
||||
default:
|
||||
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:
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
switch (target) {
|
||||
case GL_TEXTURE_2D:
|
||||
|
||||
// Detecting proper write callback and texture format
|
||||
switch (internalFormat) {
|
||||
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
||||
tex_format = SCE_GXM_TEXTURE_FORMAT_UBC1_ABGR;
|
||||
break;
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
|
||||
tex_format = SCE_GXM_TEXTURE_FORMAT_UBC3_ABGR;
|
||||
break;
|
||||
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:
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
|
||||
// Checking if texture is too big for sceGxm
|
||||
if (width > GXM_TEX_MAX_SIZE || height > GXM_TEX_MAX_SIZE) {
|
||||
error = GL_INVALID_VALUE;
|
||||
return;
|
||||
}
|
||||
|
||||
// Allocating texture/mipmaps depending on user call
|
||||
tex->type = internalFormat;
|
||||
tex->write_cb = write_cb;
|
||||
if (level == 0)
|
||||
if (tex->write_cb) gpu_alloc_texture(width, height, tex_format, data, tex, data_bpp, read_cb, write_cb);
|
||||
else gpu_alloc_compressed_texture(width, height, tex_format, data, tex, data_bpp, read_cb);
|
||||
else {
|
||||
gpu_alloc_mipmaps(level, tex);
|
||||
sceGxmTextureSetMipFilter(&tex->gxm_tex, SCE_GXM_TEXTURE_MIP_FILTER_ENABLED);
|
||||
}
|
||||
|
||||
// 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:
|
||||
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
|
||||
uint32_t orig_w = sceGxmTextureGetWidth(&target_texture->gxm_tex);
|
||||
uint32_t orig_h = sceGxmTextureGetHeight(&target_texture->gxm_tex);
|
||||
SceGxmTextureFormat tex_format = sceGxmTextureGetFormat(&target_texture->gxm_tex);
|
||||
uint8_t bpp = tex_format_to_bytespp(tex_format);
|
||||
uint32_t stride = ALIGN(orig_w, 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;
|
||||
|
||||
if (xoffset + width > orig_w) {
|
||||
error = GL_INVALID_VALUE;
|
||||
return;
|
||||
} else if (yoffset + height > orig_h) {
|
||||
error = GL_INVALID_VALUE;
|
||||
return;
|
||||
}
|
||||
|
||||
// Support for legacy GL1.0 format
|
||||
switch (format) {
|
||||
case 1:
|
||||
format = GL_RED;
|
||||
break;
|
||||
case 2:
|
||||
format = GL_RG;
|
||||
break;
|
||||
case 3:
|
||||
format = GL_RGB;
|
||||
break;
|
||||
case 4:
|
||||
format = 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 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:
|
||||
error = GL_INVALID_ENUM;
|
||||
return;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case GL_RG:
|
||||
switch (type) {
|
||||
case GL_UNSIGNED_BYTE:
|
||||
read_cb = readRG;
|
||||
data_bpp = 2;
|
||||
break;
|
||||
default:
|
||||
error = GL_INVALID_ENUM;
|
||||
return;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case GL_RGB:
|
||||
switch (type) {
|
||||
case GL_UNSIGNED_BYTE:
|
||||
data_bpp = 3;
|
||||
read_cb = readRGB;
|
||||
break;
|
||||
default:
|
||||
error = GL_INVALID_ENUM;
|
||||
return;
|
||||
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:
|
||||
error = GL_INVALID_ENUM;
|
||||
return;
|
||||
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 = writeRG;
|
||||
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:
|
||||
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:
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
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:
|
||||
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:
|
||||
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;
|
||||
case GL_MIRROR_CLAMP_EXT: // Mirror Clamp
|
||||
tex_unit->u_mode = SCE_GXM_TEXTURE_ADDR_MIRROR_CLAMP;
|
||||
break;
|
||||
default:
|
||||
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;
|
||||
case GL_MIRROR_CLAMP_EXT: // Mirror Clamp
|
||||
tex_unit->u_mode = SCE_GXM_TEXTURE_ADDR_MIRROR_CLAMP;
|
||||
break;
|
||||
default:
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
sceGxmTextureSetVAddrMode(&tex->gxm_tex, tex_unit->v_mode);
|
||||
break;
|
||||
default:
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
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
|
||||
else if (param == GL_MIRROR_CLAMP_EXT)
|
||||
tex_unit->u_mode = SCE_GXM_TEXTURE_ADDR_MIRROR_CLAMP; // Mirror Clamp
|
||||
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
|
||||
else if (param == GL_MIRROR_CLAMP_EXT)
|
||||
tex_unit->u_mode = SCE_GXM_TEXTURE_ADDR_MIRROR_CLAMP; // Mirror Clamp
|
||||
sceGxmTextureSetVAddrMode(&tex->gxm_tex, tex_unit->v_mode);
|
||||
break;
|
||||
default:
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
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))
|
||||
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:
|
||||
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:
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error = GL_INVALID_ENUM;
|
||||
}
|
||||
}
|
||||
|
||||
void glTexEnvfv(GLenum target, GLenum pname, GLfloat *param) {
|
||||
// Properly changing texture environment settings as per request
|
||||
switch (target) {
|
||||
case GL_TEXTURE_ENV:
|
||||
switch (pname) {
|
||||
case GL_TEXTURE_ENV_COLOR:
|
||||
memcpy(&texenv_color.r, param, sizeof(GLfloat) * 4);
|
||||
break;
|
||||
default:
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
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:
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
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:
|
||||
error = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
464
source/utils/gpu_utils.c
Normal file
464
source/utils/gpu_utils.c
Normal file
@ -0,0 +1,464 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* gpu_utils.c:
|
||||
* Utilities for GPU usage
|
||||
*/
|
||||
|
||||
#include "../shared.h"
|
||||
#include "stb_dxt.h"
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#define MAX(a,b) (((a)<(b))?(b):(a))
|
||||
#endif
|
||||
|
||||
// VRAM usage setting
|
||||
uint8_t use_vram = 0;
|
||||
uint8_t use_vram_for_usse = 0;
|
||||
|
||||
// Newlib mempool usage setting
|
||||
GLboolean use_extra_mem = GL_TRUE;
|
||||
|
||||
// vitaGL memory pool setup
|
||||
static void *pool_addr = NULL;
|
||||
static unsigned int pool_index = 0;
|
||||
static unsigned int pool_size = 0;
|
||||
|
||||
// USSE memory settings
|
||||
vglMemType frag_usse_type;
|
||||
vglMemType vert_usse_type;
|
||||
|
||||
uint64_t morton_1(uint64_t x)
|
||||
{
|
||||
x = x & 0x5555555555555555;
|
||||
x = (x | (x >> 1)) & 0x3333333333333333;
|
||||
x = (x | (x >> 2)) & 0x0F0F0F0F0F0F0F0F;
|
||||
x = (x | (x >> 4)) & 0x00FF00FF00FF00FF;
|
||||
x = (x | (x >> 8)) & 0x0000FFFF0000FFFF;
|
||||
x = (x | (x >> 16)) & 0xFFFFFFFFFFFFFFFF;
|
||||
return x;
|
||||
}
|
||||
|
||||
void d2xy_morton(uint64_t d, uint64_t *x, uint64_t *y)
|
||||
{
|
||||
*x = morton_1(d);
|
||||
*y = morton_1(d >> 1);
|
||||
}
|
||||
|
||||
void extract_block(const uint8_t *src, int width, uint8_t *block) {
|
||||
int j;
|
||||
for (j = 0; j < 4; j++) {
|
||||
memcpy(&block[j * 4 * 4], src, 16);
|
||||
src += width * 4;
|
||||
}
|
||||
}
|
||||
|
||||
void dxt_compress(uint8_t *dst, uint8_t *src, int w, int h, int isdxt5) {
|
||||
uint8_t block[64];
|
||||
int s = MAX(w, h);
|
||||
uint32_t num_blocks = (s * s) / 16;
|
||||
uint64_t d, offs_x, offs_y;
|
||||
for (d = 0; d < num_blocks; d++) {
|
||||
d2xy_morton(d, &offs_x, &offs_y);
|
||||
if (offs_x * 4 >= h) continue;
|
||||
if (offs_y * 4 >= w) continue;
|
||||
extract_block(src + offs_y * 16 + offs_x * w * 16, w, block);
|
||||
stb_compress_dxt_block(dst, block, isdxt5, STB_DXT_HIGHQUAL);
|
||||
dst += isdxt5 ? 16 : 8;
|
||||
}
|
||||
}
|
||||
|
||||
void *gpu_alloc_mapped(size_t size, vglMemType *type) {
|
||||
// Allocating requested memblock
|
||||
void *res = mempool_alloc(size, *type);
|
||||
|
||||
// Requested memory type finished, using other one
|
||||
if (res == NULL) {
|
||||
*type = *type == VGL_MEM_VRAM ? VGL_MEM_RAM : VGL_MEM_VRAM;
|
||||
res = mempool_alloc(size, *type);
|
||||
}
|
||||
|
||||
// Even the other one failed, using our last resort
|
||||
if (res == NULL) {
|
||||
*type = VGL_MEM_SLOW;
|
||||
res = mempool_alloc(size, *type);
|
||||
}
|
||||
|
||||
if (res == NULL && use_extra_mem) {
|
||||
*type = VGL_MEM_EXTERNAL;
|
||||
res = malloc(size);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void *gpu_vertex_usse_alloc_mapped(size_t size, unsigned int *usse_offset) {
|
||||
// Allocating memblock
|
||||
vert_usse_type = use_vram_for_usse ? VGL_MEM_VRAM : VGL_MEM_RAM;
|
||||
void *addr = gpu_alloc_mapped(size, &vert_usse_type);
|
||||
|
||||
// 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
|
||||
mempool_free(addr, vert_usse_type);
|
||||
}
|
||||
|
||||
void *gpu_fragment_usse_alloc_mapped(size_t size, unsigned int *usse_offset) {
|
||||
// Allocating memblock
|
||||
frag_usse_type = use_vram_for_usse ? VGL_MEM_VRAM : VGL_MEM_RAM;
|
||||
void *addr = gpu_alloc_mapped(size, &frag_usse_type);
|
||||
|
||||
// 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
|
||||
mempool_free(addr, frag_usse_type);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
int tex_format_to_alignment(SceGxmTextureFormat format) {
|
||||
switch (format & 0x9f000000U) {
|
||||
case SCE_GXM_TEXTURE_BASE_FORMAT_UBC3:
|
||||
return 16;
|
||||
default:
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
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_compressed_texture(uint32_t w, uint32_t h, SceGxmTextureFormat format, const void *data, texture *tex, uint8_t src_bpp, uint32_t (*read_cb)(void *)) {
|
||||
// If there's already a texture in passed texture object we first dealloc it
|
||||
if (tex->valid)
|
||||
gpu_free_texture(tex);
|
||||
|
||||
// Getting texture format alignment
|
||||
uint8_t alignment = tex_format_to_alignment(format);
|
||||
|
||||
// Calculating swizzled compressed texture size on memory
|
||||
tex->mtype = use_vram ? VGL_MEM_VRAM : VGL_MEM_RAM;
|
||||
int tex_size = w * h;
|
||||
if (alignment == 8) tex_size /= 2;
|
||||
|
||||
// Allocating texture data buffer
|
||||
void *texture_data = gpu_alloc_mapped(tex_size, &tex->mtype);
|
||||
|
||||
// NOTE: Supports only GL_RGBA source format for now
|
||||
|
||||
// Initializing texture data buffer
|
||||
if (texture_data != NULL) {
|
||||
// Initializing texture data buffer
|
||||
if (data != NULL) {
|
||||
//void *tmp = malloc(w * h * 4);
|
||||
//void *tmp2 = malloc(tex_size);
|
||||
/*int i, j;
|
||||
uint8_t *src = (uint8_t *)data;
|
||||
uint32_t *dst = (uint32_t*)tmp;
|
||||
for (i = 0; i < h * w; i++) {
|
||||
uint32_t clr = read_cb(src);
|
||||
writeRGBA(dst++, src);
|
||||
src += src_bpp;
|
||||
}*/
|
||||
|
||||
// Performing swizzling and DXT compression
|
||||
dxt_compress(texture_data, (void*)data, w, h, alignment == 16);
|
||||
|
||||
|
||||
//swizzle(texture_data, tmp2, w, h, alignment << 3);
|
||||
//free(tmp);
|
||||
//free(tmp2);
|
||||
} else
|
||||
memset(texture_data, 0, tex_size);
|
||||
|
||||
// Initializing texture and validating it
|
||||
sceGxmTextureInitSwizzled(&tex->gxm_tex, texture_data, format, w, h, 0);
|
||||
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;
|
||||
mempool_free(pal->data, pal->type);
|
||||
free(pal);
|
||||
}
|
102
source/utils/gpu_utils.h
Normal file
102
source/utils/gpu_utils.h
Normal file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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));
|
||||
|
||||
// Alloc a compresseed texture
|
||||
void gpu_alloc_compressed_texture(uint32_t w, uint32_t h, SceGxmTextureFormat format, const void *data, texture *tex, uint8_t src_bpp, uint32_t (*read_cb)(void *));
|
||||
|
||||
// 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
|
252
source/utils/math_utils.c
Normal file
252
source/utils/math_utils.c
Normal file
@ -0,0 +1,252 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* math_utils.c:
|
||||
* Utilities for math operations
|
||||
*/
|
||||
|
||||
#include "../shared.h"
|
||||
#include <math.h>
|
||||
#include <math_neon.h>
|
||||
|
||||
// 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;
|
||||
|
||||
const float a0 = m[0][0] * m[1][1] - m[0][1] * m[1][0];
|
||||
const float a1 = m[0][0] * m[1][2] - m[0][2] * m[1][0];
|
||||
const float a2 = m[0][0] * m[1][3] - m[0][3] * m[1][0];
|
||||
const float a3 = m[0][1] * m[1][2] - m[0][2] * m[1][1];
|
||||
const float a4 = m[0][1] * m[1][3] - m[0][3] * m[1][1];
|
||||
const float a5 = m[0][2] * m[1][3] - m[0][3] * m[1][2];
|
||||
const float b0 = m[2][0] * m[3][1] - m[2][1] * m[3][0];
|
||||
const float b1 = m[2][0] * m[3][2] - m[2][2] * m[3][0];
|
||||
const float b2 = m[2][0] * m[3][3] - m[2][3] * m[3][0];
|
||||
const float b3 = m[2][1] * m[3][2] - m[2][2] * m[3][1];
|
||||
const float b4 = m[2][1] * m[3][3] - m[2][3] * m[3][1];
|
||||
const float b5 = m[2][2] * m[3][3] - m[2][3] * m[3][2];
|
||||
|
||||
float det = a0 * b5 - a1 * b4 + a2 * b3 + a3 * b2 - a4 * b1 + a5 * b0;
|
||||
|
||||
if (fabsf(det) > 0.0001f) {
|
||||
out[0][0] = m[0][1] * b5 - m[1][2] * b4 + m[1][3] * b3;
|
||||
out[1][0] = -m[1][0] * b5 + m[1][2] * b2 - m[1][3] * b1;
|
||||
out[2][0] = m[1][0] * b4 - m[1][1] * b2 + m[1][3] * b0;
|
||||
out[3][0] = -m[1][0] * b3 + m[1][1] * b1 - m[1][2] * b0;
|
||||
out[0][1] = -m[0][1] * b5 + m[0][2] * b4 - m[0][3] * b3;
|
||||
out[1][1] = m[0][0] * b5 - m[0][2] * b2 + m[0][3] * b1;
|
||||
out[2][1] = -m[0][0] * b4 + m[0][1] * b2 - m[0][3] * b0;
|
||||
out[3][1] = m[0][0] * b3 - m[0][1] * b1 + m[0][2] * b0;
|
||||
out[0][2] = m[3][1] * a5 - m[3][2] * a4 + m[3][3] * a3;
|
||||
out[1][2] = -m[3][0] * a5 + m[3][2] * a2 - m[3][3] * a1;
|
||||
out[2][2] = m[3][0] * a4 - m[3][1] * a2 + m[3][3] * a0;
|
||||
out[3][2] = -m[3][0] * a3 + m[3][1] * a1 - m[3][2] * a0;
|
||||
out[0][3] = -m[2][1] * a5 + m[2][2] * a4 - m[2][3] * a3;
|
||||
out[1][3] = m[2][0] * a5 - m[2][2] * a2 + m[2][3] * a1;
|
||||
out[2][3] = -m[2][0] * a4 + m[2][1] * a2 - m[2][3] * a0;
|
||||
out[3][3] = m[2][0] * a3 - m[2][1] * a1 + m[2][2] * a0;
|
||||
|
||||
det = 1.0f / det;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (j = 0; j < 4; j++)
|
||||
out[i][j] *= det;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
92
source/utils/math_utils.h
Normal file
92
source/utils/math_utils.h
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* math_utils.h:
|
||||
* Header file for the math utilities exposed by math_utils.c
|
||||
*/
|
||||
|
||||
#ifndef _MATH_UTILS_H_
|
||||
#define _MATH_UTILS_H_
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#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
|
315
source/utils/mem_utils.c
Normal file
315
source/utils/mem_utils.c
Normal file
@ -0,0 +1,315 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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 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 mem_init(size_t size_ram, size_t size_cdram, size_t size_phycont) {
|
||||
if (mempool_addr[0] != NULL)
|
||||
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 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 *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 mempool_get_free_space(vglMemType type) {
|
||||
return tm_free[type];
|
||||
}
|
33
source/utils/mem_utils.h
Normal file
33
source/utils/mem_utils.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* mem_utils.h:
|
||||
* Header file for the memory management utilities exposed by mem_utils.c
|
||||
*/
|
||||
|
||||
#ifndef _MEM_UTILS_H_
|
||||
#define _MEM_UTILS_H_
|
||||
|
||||
int mem_init(size_t size_ram, size_t size_cdram, size_t size_phycont); // Initialize mempools
|
||||
void mem_term(void); // Terminate both CDRAM and RAM mempools
|
||||
size_t mempool_get_free_space(vglMemType type); // Return free space in bytes for a mempool
|
||||
void *mempool_alloc(size_t size, vglMemType type); // Allocate a memory block on a mempool
|
||||
void mempool_free(void *ptr, vglMemType type); // Free a memory block on a mempool
|
||||
|
||||
#endif
|
748
source/utils/stb_dxt.h
Normal file
748
source/utils/stb_dxt.h
Normal file
@ -0,0 +1,748 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
// stb_dxt.h - v1.09 - DXT1/DXT5 compressor - public domain
|
||||
// original by fabian "ryg" giesen - ported to C by stb
|
||||
// use '#define STB_DXT_IMPLEMENTATION' before including to create the implementation
|
||||
//
|
||||
// USAGE:
|
||||
// call stb_compress_dxt_block() for every block (you must pad)
|
||||
// source should be a 4x4 block of RGBA data in row-major order;
|
||||
// Alpha channel is not stored if you specify alpha=0 (but you
|
||||
// must supply some constant alpha in the alpha channel).
|
||||
// You can turn on dithering and "high quality" using mode.
|
||||
//
|
||||
// version history:
|
||||
// v1.09 - (stb) update documentation re: surprising alpha channel requirement
|
||||
// v1.08 - (stb) fix bug in dxt-with-alpha block
|
||||
// v1.07 - (stb) bc4; allow not using libc; add STB_DXT_STATIC
|
||||
// v1.06 - (stb) fix to known-broken 1.05
|
||||
// v1.05 - (stb) support bc5/3dc (Arvids Kokins), use extern "C" in C++ (Pavel Krajcevski)
|
||||
// v1.04 - (ryg) default to no rounding bias for lerped colors (as per S3TC/DX10 spec);
|
||||
// single color match fix (allow for inexact color interpolation);
|
||||
// optimal DXT5 index finder; "high quality" mode that runs multiple refinement steps.
|
||||
// v1.03 - (stb) endianness support
|
||||
// v1.02 - (stb) fix alpha encoding bug
|
||||
// v1.01 - (stb) fix bug converting to RGB that messed up quality, thanks ryg & cbloom
|
||||
// v1.00 - (stb) first release
|
||||
//
|
||||
// contributors:
|
||||
// Kevin Schmidt (#defines for "freestanding" compilation)
|
||||
// github:ppiastucki (BC4 support)
|
||||
//
|
||||
// LICENSE
|
||||
//
|
||||
// See end of file for license information.
|
||||
|
||||
#ifndef STB_INCLUDE_STB_DXT_H
|
||||
#define STB_INCLUDE_STB_DXT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef STB_DXT_STATIC
|
||||
#define STBDDEF static
|
||||
#else
|
||||
#define STBDDEF extern
|
||||
#endif
|
||||
|
||||
// compression mode (bitflags)
|
||||
#define STB_DXT_NORMAL 0
|
||||
#define STB_DXT_DITHER 1 // use dithering. dubious win. never use for normal maps and the like!
|
||||
#define STB_DXT_HIGHQUAL 2 // high quality mode, does two refinement steps instead of 1. ~30-40% slower.
|
||||
|
||||
STBDDEF void stb_compress_dxt_block(unsigned char *dest, const unsigned char *src_rgba_four_bytes_per_pixel, int alpha, int mode);
|
||||
STBDDEF void stb_compress_bc4_block(unsigned char *dest, const unsigned char *src_r_one_byte_per_pixel);
|
||||
STBDDEF void stb_compress_bc5_block(unsigned char *dest, const unsigned char *src_rg_two_byte_per_pixel);
|
||||
|
||||
#define STB_COMPRESS_DXT_BLOCK
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // STB_INCLUDE_STB_DXT_H
|
||||
|
||||
#ifdef STB_DXT_IMPLEMENTATION
|
||||
|
||||
// configuration options for DXT encoder. set them in the project/makefile or just define
|
||||
// them at the top.
|
||||
|
||||
// STB_DXT_USE_ROUNDING_BIAS
|
||||
// use a rounding bias during color interpolation. this is closer to what "ideal"
|
||||
// interpolation would do but doesn't match the S3TC/DX10 spec. old versions (pre-1.03)
|
||||
// implicitly had this turned on.
|
||||
//
|
||||
// in case you're targeting a specific type of hardware (e.g. console programmers):
|
||||
// NVidia and Intel GPUs (as of 2010) as well as DX9 ref use DXT decoders that are closer
|
||||
// to STB_DXT_USE_ROUNDING_BIAS. AMD/ATI, S3 and DX10 ref are closer to rounding with no bias.
|
||||
// you also see "(a*5 + b*3) / 8" on some old GPU designs.
|
||||
// #define STB_DXT_USE_ROUNDING_BIAS
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if !defined(STBD_ABS) || !defined(STBI_FABS)
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
#ifndef STBD_ABS
|
||||
#define STBD_ABS(i) abs(i)
|
||||
#endif
|
||||
|
||||
#ifndef STBD_FABS
|
||||
#define STBD_FABS(x) fabs(x)
|
||||
#endif
|
||||
|
||||
#ifndef STBD_MEMSET
|
||||
#include <string.h>
|
||||
#define STBD_MEMSET memset
|
||||
#endif
|
||||
|
||||
static unsigned char stb__Expand5[32];
|
||||
static unsigned char stb__Expand6[64];
|
||||
static unsigned char stb__OMatch5[256][2];
|
||||
static unsigned char stb__OMatch6[256][2];
|
||||
static unsigned char stb__QuantRBTab[256+16];
|
||||
static unsigned char stb__QuantGTab[256+16];
|
||||
|
||||
static int stb__Mul8Bit(int a, int b)
|
||||
{
|
||||
int t = a*b + 128;
|
||||
return (t + (t >> 8)) >> 8;
|
||||
}
|
||||
|
||||
static void stb__From16Bit(unsigned char *out, unsigned short v)
|
||||
{
|
||||
int rv = (v & 0xf800) >> 11;
|
||||
int gv = (v & 0x07e0) >> 5;
|
||||
int bv = (v & 0x001f) >> 0;
|
||||
|
||||
out[0] = stb__Expand5[rv];
|
||||
out[1] = stb__Expand6[gv];
|
||||
out[2] = stb__Expand5[bv];
|
||||
out[3] = 0;
|
||||
}
|
||||
|
||||
static unsigned short stb__As16Bit(int r, int g, int b)
|
||||
{
|
||||
return (unsigned short)((stb__Mul8Bit(r,31) << 11) + (stb__Mul8Bit(g,63) << 5) + stb__Mul8Bit(b,31));
|
||||
}
|
||||
|
||||
// linear interpolation at 1/3 point between a and b, using desired rounding type
|
||||
static int stb__Lerp13(int a, int b)
|
||||
{
|
||||
#ifdef STB_DXT_USE_ROUNDING_BIAS
|
||||
// with rounding bias
|
||||
return a + stb__Mul8Bit(b-a, 0x55);
|
||||
#else
|
||||
// without rounding bias
|
||||
// replace "/ 3" by "* 0xaaab) >> 17" if your compiler sucks or you really need every ounce of speed.
|
||||
return (2*a + b) / 3;
|
||||
#endif
|
||||
}
|
||||
|
||||
// lerp RGB color
|
||||
static void stb__Lerp13RGB(unsigned char *out, unsigned char *p1, unsigned char *p2)
|
||||
{
|
||||
out[0] = (unsigned char)stb__Lerp13(p1[0], p2[0]);
|
||||
out[1] = (unsigned char)stb__Lerp13(p1[1], p2[1]);
|
||||
out[2] = (unsigned char)stb__Lerp13(p1[2], p2[2]);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
// compute table to reproduce constant colors as accurately as possible
|
||||
static void stb__PrepareOptTable(unsigned char *Table,const unsigned char *expand,int size)
|
||||
{
|
||||
int i,mn,mx;
|
||||
for (i=0;i<256;i++) {
|
||||
int bestErr = 256;
|
||||
for (mn=0;mn<size;mn++) {
|
||||
for (mx=0;mx<size;mx++) {
|
||||
int mine = expand[mn];
|
||||
int maxe = expand[mx];
|
||||
int err = STBD_ABS(stb__Lerp13(maxe, mine) - i);
|
||||
|
||||
// DX10 spec says that interpolation must be within 3% of "correct" result,
|
||||
// add this as error term. (normally we'd expect a random distribution of
|
||||
// +-1.5% error, but nowhere in the spec does it say that the error has to be
|
||||
// unbiased - better safe than sorry).
|
||||
err += STBD_ABS(maxe - mine) * 3 / 100;
|
||||
|
||||
if(err < bestErr)
|
||||
{
|
||||
Table[i*2+0] = (unsigned char)mx;
|
||||
Table[i*2+1] = (unsigned char)mn;
|
||||
bestErr = err;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void stb__EvalColors(unsigned char *color,unsigned short c0,unsigned short c1)
|
||||
{
|
||||
stb__From16Bit(color+ 0, c0);
|
||||
stb__From16Bit(color+ 4, c1);
|
||||
stb__Lerp13RGB(color+ 8, color+0, color+4);
|
||||
stb__Lerp13RGB(color+12, color+4, color+0);
|
||||
}
|
||||
|
||||
// Block dithering function. Simply dithers a block to 565 RGB.
|
||||
// (Floyd-Steinberg)
|
||||
static void stb__DitherBlock(unsigned char *dest, unsigned char *block)
|
||||
{
|
||||
int err[8],*ep1 = err,*ep2 = err+4, *et;
|
||||
int ch,y;
|
||||
|
||||
// process channels separately
|
||||
for (ch=0; ch<3; ++ch) {
|
||||
unsigned char *bp = block+ch, *dp = dest+ch;
|
||||
unsigned char *quant = (ch == 1) ? stb__QuantGTab+8 : stb__QuantRBTab+8;
|
||||
STBD_MEMSET(err, 0, sizeof(err));
|
||||
for(y=0; y<4; ++y) {
|
||||
dp[ 0] = quant[bp[ 0] + ((3*ep2[1] + 5*ep2[0]) >> 4)];
|
||||
ep1[0] = bp[ 0] - dp[ 0];
|
||||
dp[ 4] = quant[bp[ 4] + ((7*ep1[0] + 3*ep2[2] + 5*ep2[1] + ep2[0]) >> 4)];
|
||||
ep1[1] = bp[ 4] - dp[ 4];
|
||||
dp[ 8] = quant[bp[ 8] + ((7*ep1[1] + 3*ep2[3] + 5*ep2[2] + ep2[1]) >> 4)];
|
||||
ep1[2] = bp[ 8] - dp[ 8];
|
||||
dp[12] = quant[bp[12] + ((7*ep1[2] + 5*ep2[3] + ep2[2]) >> 4)];
|
||||
ep1[3] = bp[12] - dp[12];
|
||||
bp += 16;
|
||||
dp += 16;
|
||||
et = ep1, ep1 = ep2, ep2 = et; // swap
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The color matching function
|
||||
static unsigned int stb__MatchColorsBlock(unsigned char *block, unsigned char *color,int dither)
|
||||
{
|
||||
unsigned int mask = 0;
|
||||
int dirr = color[0*4+0] - color[1*4+0];
|
||||
int dirg = color[0*4+1] - color[1*4+1];
|
||||
int dirb = color[0*4+2] - color[1*4+2];
|
||||
int dots[16];
|
||||
int stops[4];
|
||||
int i;
|
||||
int c0Point, halfPoint, c3Point;
|
||||
|
||||
for(i=0;i<16;i++)
|
||||
dots[i] = block[i*4+0]*dirr + block[i*4+1]*dirg + block[i*4+2]*dirb;
|
||||
|
||||
for(i=0;i<4;i++)
|
||||
stops[i] = color[i*4+0]*dirr + color[i*4+1]*dirg + color[i*4+2]*dirb;
|
||||
|
||||
// think of the colors as arranged on a line; project point onto that line, then choose
|
||||
// next color out of available ones. we compute the crossover points for "best color in top
|
||||
// half"/"best in bottom half" and then the same inside that subinterval.
|
||||
//
|
||||
// relying on this 1d approximation isn't always optimal in terms of euclidean distance,
|
||||
// but it's very close and a lot faster.
|
||||
// http://cbloomrants.blogspot.com/2008/12/12-08-08-dxtc-summary.html
|
||||
|
||||
c0Point = (stops[1] + stops[3]) >> 1;
|
||||
halfPoint = (stops[3] + stops[2]) >> 1;
|
||||
c3Point = (stops[2] + stops[0]) >> 1;
|
||||
|
||||
if(!dither) {
|
||||
// the version without dithering is straightforward
|
||||
for (i=15;i>=0;i--) {
|
||||
int dot = dots[i];
|
||||
mask <<= 2;
|
||||
|
||||
if(dot < halfPoint)
|
||||
mask |= (dot < c0Point) ? 1 : 3;
|
||||
else
|
||||
mask |= (dot < c3Point) ? 2 : 0;
|
||||
}
|
||||
} else {
|
||||
// with floyd-steinberg dithering
|
||||
int err[8],*ep1 = err,*ep2 = err+4;
|
||||
int *dp = dots, y;
|
||||
|
||||
c0Point <<= 4;
|
||||
halfPoint <<= 4;
|
||||
c3Point <<= 4;
|
||||
for(i=0;i<8;i++)
|
||||
err[i] = 0;
|
||||
|
||||
for(y=0;y<4;y++)
|
||||
{
|
||||
int dot,lmask,step;
|
||||
|
||||
dot = (dp[0] << 4) + (3*ep2[1] + 5*ep2[0]);
|
||||
if(dot < halfPoint)
|
||||
step = (dot < c0Point) ? 1 : 3;
|
||||
else
|
||||
step = (dot < c3Point) ? 2 : 0;
|
||||
ep1[0] = dp[0] - stops[step];
|
||||
lmask = step;
|
||||
|
||||
dot = (dp[1] << 4) + (7*ep1[0] + 3*ep2[2] + 5*ep2[1] + ep2[0]);
|
||||
if(dot < halfPoint)
|
||||
step = (dot < c0Point) ? 1 : 3;
|
||||
else
|
||||
step = (dot < c3Point) ? 2 : 0;
|
||||
ep1[1] = dp[1] - stops[step];
|
||||
lmask |= step<<2;
|
||||
|
||||
dot = (dp[2] << 4) + (7*ep1[1] + 3*ep2[3] + 5*ep2[2] + ep2[1]);
|
||||
if(dot < halfPoint)
|
||||
step = (dot < c0Point) ? 1 : 3;
|
||||
else
|
||||
step = (dot < c3Point) ? 2 : 0;
|
||||
ep1[2] = dp[2] - stops[step];
|
||||
lmask |= step<<4;
|
||||
|
||||
dot = (dp[3] << 4) + (7*ep1[2] + 5*ep2[3] + ep2[2]);
|
||||
if(dot < halfPoint)
|
||||
step = (dot < c0Point) ? 1 : 3;
|
||||
else
|
||||
step = (dot < c3Point) ? 2 : 0;
|
||||
ep1[3] = dp[3] - stops[step];
|
||||
lmask |= step<<6;
|
||||
|
||||
dp += 4;
|
||||
mask |= lmask << (y*8);
|
||||
{ int *et = ep1; ep1 = ep2; ep2 = et; } // swap
|
||||
}
|
||||
}
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
// The color optimization function. (Clever code, part 1)
|
||||
static void stb__OptimizeColorsBlock(unsigned char *block, unsigned short *pmax16, unsigned short *pmin16)
|
||||
{
|
||||
int mind = 0x7fffffff,maxd = -0x7fffffff;
|
||||
unsigned char *minp, *maxp;
|
||||
double magn;
|
||||
int v_r,v_g,v_b;
|
||||
static const int nIterPower = 4;
|
||||
float covf[6],vfr,vfg,vfb;
|
||||
|
||||
// determine color distribution
|
||||
int cov[6];
|
||||
int mu[3],min[3],max[3];
|
||||
int ch,i,iter;
|
||||
|
||||
for(ch=0;ch<3;ch++)
|
||||
{
|
||||
const unsigned char *bp = ((const unsigned char *) block) + ch;
|
||||
int muv,minv,maxv;
|
||||
|
||||
muv = minv = maxv = bp[0];
|
||||
for(i=4;i<64;i+=4)
|
||||
{
|
||||
muv += bp[i];
|
||||
if (bp[i] < minv) minv = bp[i];
|
||||
else if (bp[i] > maxv) maxv = bp[i];
|
||||
}
|
||||
|
||||
mu[ch] = (muv + 8) >> 4;
|
||||
min[ch] = minv;
|
||||
max[ch] = maxv;
|
||||
}
|
||||
|
||||
// determine covariance matrix
|
||||
for (i=0;i<6;i++)
|
||||
cov[i] = 0;
|
||||
|
||||
for (i=0;i<16;i++)
|
||||
{
|
||||
int r = block[i*4+0] - mu[0];
|
||||
int g = block[i*4+1] - mu[1];
|
||||
int b = block[i*4+2] - mu[2];
|
||||
|
||||
cov[0] += r*r;
|
||||
cov[1] += r*g;
|
||||
cov[2] += r*b;
|
||||
cov[3] += g*g;
|
||||
cov[4] += g*b;
|
||||
cov[5] += b*b;
|
||||
}
|
||||
|
||||
// convert covariance matrix to float, find principal axis via power iter
|
||||
for(i=0;i<6;i++)
|
||||
covf[i] = cov[i] / 255.0f;
|
||||
|
||||
vfr = (float) (max[0] - min[0]);
|
||||
vfg = (float) (max[1] - min[1]);
|
||||
vfb = (float) (max[2] - min[2]);
|
||||
|
||||
for(iter=0;iter<nIterPower;iter++)
|
||||
{
|
||||
float r = vfr*covf[0] + vfg*covf[1] + vfb*covf[2];
|
||||
float g = vfr*covf[1] + vfg*covf[3] + vfb*covf[4];
|
||||
float b = vfr*covf[2] + vfg*covf[4] + vfb*covf[5];
|
||||
|
||||
vfr = r;
|
||||
vfg = g;
|
||||
vfb = b;
|
||||
}
|
||||
|
||||
magn = STBD_FABS(vfr);
|
||||
if (STBD_FABS(vfg) > magn) magn = STBD_FABS(vfg);
|
||||
if (STBD_FABS(vfb) > magn) magn = STBD_FABS(vfb);
|
||||
|
||||
if(magn < 4.0f) { // too small, default to luminance
|
||||
v_r = 299; // JPEG YCbCr luma coefs, scaled by 1000.
|
||||
v_g = 587;
|
||||
v_b = 114;
|
||||
} else {
|
||||
magn = 512.0 / magn;
|
||||
v_r = (int) (vfr * magn);
|
||||
v_g = (int) (vfg * magn);
|
||||
v_b = (int) (vfb * magn);
|
||||
}
|
||||
|
||||
// Pick colors at extreme points
|
||||
for(i=0;i<16;i++)
|
||||
{
|
||||
int dot = block[i*4+0]*v_r + block[i*4+1]*v_g + block[i*4+2]*v_b;
|
||||
|
||||
if (dot < mind) {
|
||||
mind = dot;
|
||||
minp = block+i*4;
|
||||
}
|
||||
|
||||
if (dot > maxd) {
|
||||
maxd = dot;
|
||||
maxp = block+i*4;
|
||||
}
|
||||
}
|
||||
|
||||
*pmax16 = stb__As16Bit(maxp[0],maxp[1],maxp[2]);
|
||||
*pmin16 = stb__As16Bit(minp[0],minp[1],minp[2]);
|
||||
}
|
||||
|
||||
static int stb__sclamp(float y, int p0, int p1)
|
||||
{
|
||||
int x = (int) y;
|
||||
if (x < p0) return p0;
|
||||
if (x > p1) return p1;
|
||||
return x;
|
||||
}
|
||||
|
||||
// The refinement function. (Clever code, part 2)
|
||||
// Tries to optimize colors to suit block contents better.
|
||||
// (By solving a least squares system via normal equations+Cramer's rule)
|
||||
static int stb__RefineBlock(unsigned char *block, unsigned short *pmax16, unsigned short *pmin16, unsigned int mask)
|
||||
{
|
||||
static const int w1Tab[4] = { 3,0,2,1 };
|
||||
static const int prods[4] = { 0x090000,0x000900,0x040102,0x010402 };
|
||||
// ^some magic to save a lot of multiplies in the accumulating loop...
|
||||
// (precomputed products of weights for least squares system, accumulated inside one 32-bit register)
|
||||
|
||||
float frb,fg;
|
||||
unsigned short oldMin, oldMax, min16, max16;
|
||||
int i, akku = 0, xx,xy,yy;
|
||||
int At1_r,At1_g,At1_b;
|
||||
int At2_r,At2_g,At2_b;
|
||||
unsigned int cm = mask;
|
||||
|
||||
oldMin = *pmin16;
|
||||
oldMax = *pmax16;
|
||||
|
||||
if((mask ^ (mask<<2)) < 4) // all pixels have the same index?
|
||||
{
|
||||
// yes, linear system would be singular; solve using optimal
|
||||
// single-color match on average color
|
||||
int r = 8, g = 8, b = 8;
|
||||
for (i=0;i<16;++i) {
|
||||
r += block[i*4+0];
|
||||
g += block[i*4+1];
|
||||
b += block[i*4+2];
|
||||
}
|
||||
|
||||
r >>= 4; g >>= 4; b >>= 4;
|
||||
|
||||
max16 = (stb__OMatch5[r][0]<<11) | (stb__OMatch6[g][0]<<5) | stb__OMatch5[b][0];
|
||||
min16 = (stb__OMatch5[r][1]<<11) | (stb__OMatch6[g][1]<<5) | stb__OMatch5[b][1];
|
||||
} else {
|
||||
At1_r = At1_g = At1_b = 0;
|
||||
At2_r = At2_g = At2_b = 0;
|
||||
for (i=0;i<16;++i,cm>>=2) {
|
||||
int step = cm&3;
|
||||
int w1 = w1Tab[step];
|
||||
int r = block[i*4+0];
|
||||
int g = block[i*4+1];
|
||||
int b = block[i*4+2];
|
||||
|
||||
akku += prods[step];
|
||||
At1_r += w1*r;
|
||||
At1_g += w1*g;
|
||||
At1_b += w1*b;
|
||||
At2_r += r;
|
||||
At2_g += g;
|
||||
At2_b += b;
|
||||
}
|
||||
|
||||
At2_r = 3*At2_r - At1_r;
|
||||
At2_g = 3*At2_g - At1_g;
|
||||
At2_b = 3*At2_b - At1_b;
|
||||
|
||||
// extract solutions and decide solvability
|
||||
xx = akku >> 16;
|
||||
yy = (akku >> 8) & 0xff;
|
||||
xy = (akku >> 0) & 0xff;
|
||||
|
||||
frb = 3.0f * 31.0f / 255.0f / (xx*yy - xy*xy);
|
||||
fg = frb * 63.0f / 31.0f;
|
||||
|
||||
// solve.
|
||||
max16 = (unsigned short)(stb__sclamp((At1_r*yy - At2_r*xy)*frb+0.5f,0,31) << 11);
|
||||
max16 |= (unsigned short)(stb__sclamp((At1_g*yy - At2_g*xy)*fg +0.5f,0,63) << 5);
|
||||
max16 |= (unsigned short)(stb__sclamp((At1_b*yy - At2_b*xy)*frb+0.5f,0,31) << 0);
|
||||
|
||||
min16 = (unsigned short)(stb__sclamp((At2_r*xx - At1_r*xy)*frb+0.5f,0,31) << 11);
|
||||
min16 |= (unsigned short)(stb__sclamp((At2_g*xx - At1_g*xy)*fg +0.5f,0,63) << 5);
|
||||
min16 |= (unsigned short)(stb__sclamp((At2_b*xx - At1_b*xy)*frb+0.5f,0,31) << 0);
|
||||
}
|
||||
|
||||
*pmin16 = min16;
|
||||
*pmax16 = max16;
|
||||
return oldMin != min16 || oldMax != max16;
|
||||
}
|
||||
|
||||
// Color block compression
|
||||
static void stb__CompressColorBlock(unsigned char *dest, unsigned char *block, int mode)
|
||||
{
|
||||
unsigned int mask;
|
||||
int i;
|
||||
int dither;
|
||||
int refinecount;
|
||||
unsigned short max16, min16;
|
||||
unsigned char dblock[16*4],color[4*4];
|
||||
|
||||
dither = mode & STB_DXT_DITHER;
|
||||
refinecount = (mode & STB_DXT_HIGHQUAL) ? 2 : 1;
|
||||
|
||||
// check if block is constant
|
||||
for (i=1;i<16;i++)
|
||||
if (((unsigned int *) block)[i] != ((unsigned int *) block)[0])
|
||||
break;
|
||||
|
||||
if(i == 16) { // constant color
|
||||
int r = block[0], g = block[1], b = block[2];
|
||||
mask = 0xaaaaaaaa;
|
||||
max16 = (stb__OMatch5[r][0]<<11) | (stb__OMatch6[g][0]<<5) | stb__OMatch5[b][0];
|
||||
min16 = (stb__OMatch5[r][1]<<11) | (stb__OMatch6[g][1]<<5) | stb__OMatch5[b][1];
|
||||
} else {
|
||||
// first step: compute dithered version for PCA if desired
|
||||
if(dither)
|
||||
stb__DitherBlock(dblock,block);
|
||||
|
||||
// second step: pca+map along principal axis
|
||||
stb__OptimizeColorsBlock(dither ? dblock : block,&max16,&min16);
|
||||
if (max16 != min16) {
|
||||
stb__EvalColors(color,max16,min16);
|
||||
mask = stb__MatchColorsBlock(block,color,dither);
|
||||
} else
|
||||
mask = 0;
|
||||
|
||||
// third step: refine (multiple times if requested)
|
||||
for (i=0;i<refinecount;i++) {
|
||||
unsigned int lastmask = mask;
|
||||
|
||||
if (stb__RefineBlock(dither ? dblock : block,&max16,&min16,mask)) {
|
||||
if (max16 != min16) {
|
||||
stb__EvalColors(color,max16,min16);
|
||||
mask = stb__MatchColorsBlock(block,color,dither);
|
||||
} else {
|
||||
mask = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(mask == lastmask)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// write the color block
|
||||
if(max16 < min16)
|
||||
{
|
||||
unsigned short t = min16;
|
||||
min16 = max16;
|
||||
max16 = t;
|
||||
mask ^= 0x55555555;
|
||||
}
|
||||
|
||||
dest[0] = (unsigned char) (max16);
|
||||
dest[1] = (unsigned char) (max16 >> 8);
|
||||
dest[2] = (unsigned char) (min16);
|
||||
dest[3] = (unsigned char) (min16 >> 8);
|
||||
dest[4] = (unsigned char) (mask);
|
||||
dest[5] = (unsigned char) (mask >> 8);
|
||||
dest[6] = (unsigned char) (mask >> 16);
|
||||
dest[7] = (unsigned char) (mask >> 24);
|
||||
}
|
||||
|
||||
// Alpha block compression (this is easy for a change)
|
||||
static void stb__CompressAlphaBlock(unsigned char *dest,unsigned char *src, int stride)
|
||||
{
|
||||
int i,dist,bias,dist4,dist2,bits,mask;
|
||||
|
||||
// find min/max color
|
||||
int mn,mx;
|
||||
mn = mx = src[0];
|
||||
|
||||
for (i=1;i<16;i++)
|
||||
{
|
||||
if (src[i*stride] < mn) mn = src[i*stride];
|
||||
else if (src[i*stride] > mx) mx = src[i*stride];
|
||||
}
|
||||
|
||||
// encode them
|
||||
dest[0] = (unsigned char)mx;
|
||||
dest[1] = (unsigned char)mn;
|
||||
dest += 2;
|
||||
|
||||
// determine bias and emit color indices
|
||||
// given the choice of mx/mn, these indices are optimal:
|
||||
// http://fgiesen.wordpress.com/2009/12/15/dxt5-alpha-block-index-determination/
|
||||
dist = mx-mn;
|
||||
dist4 = dist*4;
|
||||
dist2 = dist*2;
|
||||
bias = (dist < 8) ? (dist - 1) : (dist/2 + 2);
|
||||
bias -= mn * 7;
|
||||
bits = 0,mask=0;
|
||||
|
||||
for (i=0;i<16;i++) {
|
||||
int a = src[i*stride]*7 + bias;
|
||||
int ind,t;
|
||||
|
||||
// select index. this is a "linear scale" lerp factor between 0 (val=min) and 7 (val=max).
|
||||
t = (a >= dist4) ? -1 : 0; ind = t & 4; a -= dist4 & t;
|
||||
t = (a >= dist2) ? -1 : 0; ind += t & 2; a -= dist2 & t;
|
||||
ind += (a >= dist);
|
||||
|
||||
// turn linear scale into DXT index (0/1 are extremal pts)
|
||||
ind = -ind & 7;
|
||||
ind ^= (2 > ind);
|
||||
|
||||
// write index
|
||||
mask |= ind << bits;
|
||||
if((bits += 3) >= 8) {
|
||||
*dest++ = (unsigned char)mask;
|
||||
mask >>= 8;
|
||||
bits -= 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void stb__InitDXT()
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<32;i++)
|
||||
stb__Expand5[i] = (unsigned char)((i<<3)|(i>>2));
|
||||
|
||||
for(i=0;i<64;i++)
|
||||
stb__Expand6[i] = (unsigned char)((i<<2)|(i>>4));
|
||||
|
||||
for(i=0;i<256+16;i++)
|
||||
{
|
||||
int v = i-8 < 0 ? 0 : i-8 > 255 ? 255 : i-8;
|
||||
stb__QuantRBTab[i] = stb__Expand5[stb__Mul8Bit(v,31)];
|
||||
stb__QuantGTab[i] = stb__Expand6[stb__Mul8Bit(v,63)];
|
||||
}
|
||||
|
||||
stb__PrepareOptTable(&stb__OMatch5[0][0],stb__Expand5,32);
|
||||
stb__PrepareOptTable(&stb__OMatch6[0][0],stb__Expand6,64);
|
||||
}
|
||||
|
||||
void stb_compress_dxt_block(unsigned char *dest, const unsigned char *src, int alpha, int mode)
|
||||
{
|
||||
unsigned char data[16][4];
|
||||
static int init=1;
|
||||
if (init) {
|
||||
stb__InitDXT();
|
||||
init=0;
|
||||
}
|
||||
|
||||
if (alpha) {
|
||||
int i;
|
||||
stb__CompressAlphaBlock(dest,(unsigned char*) src+3, 4);
|
||||
dest += 8;
|
||||
// make a new copy of the data in which alpha is opaque,
|
||||
// because code uses a fast test for color constancy
|
||||
memcpy(data, src, 4*16);
|
||||
for (i=0; i < 16; ++i)
|
||||
data[i][3] = 255;
|
||||
src = &data[0][0];
|
||||
}
|
||||
|
||||
stb__CompressColorBlock(dest,(unsigned char*) src,mode);
|
||||
}
|
||||
|
||||
void stb_compress_bc4_block(unsigned char *dest, const unsigned char *src)
|
||||
{
|
||||
stb__CompressAlphaBlock(dest,(unsigned char*) src, 1);
|
||||
}
|
||||
|
||||
void stb_compress_bc5_block(unsigned char *dest, const unsigned char *src)
|
||||
{
|
||||
stb__CompressAlphaBlock(dest,(unsigned char*) src,2);
|
||||
stb__CompressAlphaBlock(dest + 8,(unsigned char*) src+1,2);
|
||||
}
|
||||
#endif // STB_DXT_IMPLEMENTATION
|
||||
|
||||
/*
|
||||
------------------------------------------------------------------------------
|
||||
This software is available under 2 licenses -- choose whichever you prefer.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE A - MIT License
|
||||
Copyright (c) 2017 Sean Barrett
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
||||
This is free and unencumbered software released into the public domain.
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||
software, either in source code form or as a compiled binary, for any purpose,
|
||||
commercial or non-commercial, and by any means.
|
||||
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||
software dedicate any and all copyright interest in the software to the public
|
||||
domain. We make this dedication for the benefit of the public at large and to
|
||||
the detriment of our heirs and successors. We intend this dedication to be an
|
||||
overt act of relinquishment in perpetuity of all present and future rights to
|
||||
this software under copyright law.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
------------------------------------------------------------------------------
|
||||
*/
|
2106
source/vitaGL.c
Normal file
2106
source/vitaGL.c
Normal file
File diff suppressed because it is too large
Load Diff
415
source/vitaGL.h
Normal file
415
source/vitaGL.h
Normal file
@ -0,0 +1,415 @@
|
||||
/*
|
||||
* This file is part of vitaGL
|
||||
* 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 _VITAGL_H_
|
||||
#define _VITAGL_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <vitasdk.h>
|
||||
|
||||
// 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_PROJECTION_MATRIX 0x0BA7
|
||||
#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_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
|
||||
#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
|
||||
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
|
||||
#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_MIRROR_CLAMP_EXT 0x8742
|
||||
#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
|
||||
|
||||
// Aliases
|
||||
#define GL_CLAMP GL_CLAMP_TO_EDGE
|
||||
|
||||
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 glTexEnvfv(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 vglUseVramForUSSE(GLboolean usage);
|
||||
void vglUseExtraMem(GLboolean usage);
|
||||
void vglWaitVblankStart(GLboolean enable);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user