Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
f576c59
Fumbling toward a transformation on CoronaTotalTime, so far the comma…
ggcrunchy Feb 7, 2019
6626191
Moved some of the time transform stuff into ShaderResource with link …
ggcrunchy Feb 8, 2019
e59f04a
Better argument checking for time transforms
ggcrunchy Feb 9, 2019
e05f972
Whoops, wasn't always linking Program back to ShaderResource
ggcrunchy Feb 10, 2019
c7af750
Removed notes to self about changes
ggcrunchy Feb 11, 2019
9058c1f
timeTransform ignored if no time dependency
ggcrunchy Feb 11, 2019
c01d916
Minor changes
ggcrunchy May 29, 2020
08dc3b6
Maintenance Revert Test
scottrules44 Sep 20, 2021
05b91fb
Simulator: Adding Samsung Galaxy 21 as a skin
scottrules44 Sep 22, 2021
f44be24
Maintenance
scottrules44 Sep 22, 2021
581d844
Android: adding rest of media intents for Android 11
scottrules44 Sep 22, 2021
265be3c
Merge
ggcrunchy Sep 23, 2021
e217c80
Merge
ggcrunchy Oct 4, 2021
ca300c1
Merge branch 'master' of https://github.com/coronalabs/corona
ggcrunchy Oct 19, 2021
0b5e1e9
First go at graphics.undefineEffect()
ggcrunchy Nov 9, 2021
b41e624
Revert "First go at graphics.undefineEffect()"
ggcrunchy Nov 10, 2021
5be6193
Merging upstream
ggcrunchy Aug 18, 2022
f38ecec
Merge branch 'master' of https://github.com/ggcrunchy/corona
ggcrunchy Aug 18, 2022
bb395b8
Merge branch 'master' of https://github.com/coronalabs/corona
ggcrunchy Dec 16, 2022
0bf47a5
Merge remote-tracking branch 'upstream/master'
ggcrunchy Jun 12, 2025
27ad840
Merge branch 'master' of https://github.com/coronalabs/corona
ggcrunchy May 4, 2026
6b59610
Merge branch 'master' of https://github.com/coronalabs/corona into GP…
ggcrunchy May 4, 2026
5b1a4c7
Disabled some seemingly dead code (offscreen GPU surfaces)
ggcrunchy May 5, 2026
8c2ea26
glActiveTexture() and glClientActiveTexture() were still getting drag…
ggcrunchy May 6, 2026
027abd1
First go at updating Texture and PlatformBitmap's Format types as bit…
ggcrunchy May 11, 2026
14f0423
No need to have Texture and PlatformBitmap agree for each FormatValue…
ggcrunchy May 12, 2026
bb9559e
Whoops, compressed dimension was a U8 but should be at least a U16
ggcrunchy May 15, 2026
33eab45
A couple missed Format::GetValue() uses
ggcrunchy Jun 4, 2026
7934397
A couple more format issues
ggcrunchy Jun 4, 2026
4f9e553
Added a context argument to GPUResource's Create() and Update() metho…
ggcrunchy May 22, 2026
0c59188
Some APIs in CoronaGraphics.h tightened up
ggcrunchy May 28, 2026
1035743
Bind texture when doing compressed format probe
ggcrunchy May 30, 2026
d8ff131
Overhauled the format-definition interface in CoronaGraphics.h
ggcrunchy May 31, 2026
54d2f04
Using some little factories and TextureFormatDescription's getters as…
ggcrunchy Jun 1, 2026
24bedca
Flaky loop fix
ggcrunchy Jun 3, 2026
ac4b4bf
Added context argument where Vulkan GPU resource called Update() from…
ggcrunchy Jun 4, 2026
bf98b44
Added TextureList type that will normally hold two Texture pointers, …
ggcrunchy Jun 8, 2026
7bc8b4f
Minor typo fix for link in Rtt_String
ggcrunchy Jun 23, 2026
7b8680a
Made the builtin sampler check a little tighter
ggcrunchy Jun 24, 2026
6abc617
Removed silly dependence on SamplerTypeDetails being a U8 and just st…
ggcrunchy Jun 24, 2026
14a449b
Minor comment cosmetics
ggcrunchy Jun 24, 2026
693f7dc
Some further refinements on shader-paint consistency
ggcrunchy Jun 25, 2026
f384768
Further tightening of names
ggcrunchy Jun 28, 2026
70977b9
Further shuffling around
ggcrunchy Jun 29, 2026
b342329
Further refinement, really... importantly, trying to inspect the shad…
ggcrunchy Jun 30, 2026
6c7bdac
Cleaned up some notes
ggcrunchy Jul 1, 2026
1aed214
Fixed some buffer offset bloopers and wonk in the check-consistency l…
ggcrunchy Jul 1, 2026
a31a86a
Whoops, two conditions were backward:
ggcrunchy Jul 1, 2026
43a7f03
Some silly fixes for might-have-texture stuff
ggcrunchy Jul 2, 2026
0f76265
Dumb accounting blunder in NamesEncoder and LengthAccumulator (obviou…
ggcrunchy Jul 2, 2026
e270217
Earlier default shader substitution had to be reworked since it had w…
ggcrunchy Jul 3, 2026
641aa9f
Minor tidying, like having IsPaintConsistent() use a TextureList (and…
ggcrunchy Jul 3, 2026
e9d3d98
LengthAccumulator has own code and was duplicating numUnits tracking
ggcrunchy Jul 3, 2026
40276c9
Some notes after finding Slang's GL types reference and seeing there …
ggcrunchy Jul 4, 2026
003e454
Fix for detail indexing when paints have more textures than shader ha…
ggcrunchy Jul 4, 2026
b5a512a
Yet another flaw in Array's PadToSize()
ggcrunchy Jul 4, 2026
1ac931a
AreTexturesConsistent() now takes TextureList to consolidate parameters
ggcrunchy Jul 4, 2026
4303560
Removed some dead std vectors
ggcrunchy Jul 4, 2026
8acc445
A couple dumb typos
ggcrunchy Jul 23, 2026
095e9a9
Rebuilt image / sampler type constants table to include stragglers fo…
ggcrunchy Aug 1, 2026
5ea0fd0
A couple missed format.GetValue() cases, found when testing with Android
ggcrunchy Aug 17, 2026
62c126d
Initial go at shellTweaks (some tinkering to follow, and then need to…
ggcrunchy Aug 17, 2026
688234e
Tightened up tweak options
ggcrunchy Aug 17, 2026
4b9c38d
Added guard against shell tweaks and transforms coexisting
ggcrunchy Aug 17, 2026
4dbef4f
Pointless memset() in setting up effect data type extra space, after …
ggcrunchy Aug 18, 2026
e207aad
Deprecation notes for some stuff in CoronaGraphics.h... no move to do…
ggcrunchy Aug 18, 2026
c0b533f
Some notes about extension list plans
ggcrunchy Aug 20, 2026
a288aef
Added an explicit cap of 32 to max extra vertex attributes (on a Sili…
ggcrunchy Aug 31, 2026
b94f642
Removed most of the commented-out bits from the previous commit (some…
ggcrunchy Aug 31, 2026
a97aaf9
Some notes for classifying miscellaneous uniform types
ggcrunchy Sep 4, 2026
764927f
Updated to newest sampler and image types LUT (only one, huzzah) and …
ggcrunchy Sep 4, 2026
2983d6b
Some minor comment fixes and notes for later
ggcrunchy Sep 5, 2026
7e956d0
Still need to (re-)add a query for available texture units, in partic…
ggcrunchy Sep 5, 2026
e3b2377
Whoops, wasn't handling non-return case in switch for that last logic
ggcrunchy Sep 5, 2026
93315ae
Streamlining some of the queries that go between Display and CommandB…
ggcrunchy Sep 16, 2026
8c5f069
Add new functions to Main.cpp
ggcrunchy Sep 26, 2026
4c29d51
Coddling MSVC macro misbehavior
ggcrunchy Sep 26, 2026
4095c55
MakeSuffix() no longer used
ggcrunchy Sep 27, 2026
fd7fe91
Corresponding LUT and classifier for non-sampler and -image uniform t…
ggcrunchy Sep 30, 2026
1f6dc7d
Tightening up the uniform types commentary
ggcrunchy Oct 1, 2026
8dd70d3
A few paint name / texture occupancy fixes
ggcrunchy Oct 3, 2026
81702b0
A couple fixups suggested by last audit, still on extra texture bits
ggcrunchy Oct 3, 2026
8651a90
Stupid typos in Windows Main.cpp stuff (adding before local testing)
ggcrunchy Oct 3, 2026
a395841
A little tidying up of the RED probe; needs testing against the gamut…
ggcrunchy Oct 3, 2026
3dbcd93
Merge branch 'master' into SamplerAndShape
ggcrunchy Oct 4, 2026
817b0d6
Fix a couple merge gaffes
ggcrunchy Oct 4, 2026
c026835
Added an is-ES2? check to RenderContext
ggcrunchy Oct 4, 2026
ff663a7
Minor rename of CoronaGraphics texture extension structure to use Hea…
ggcrunchy Oct 24, 2026
77f3444
Wasn't using the color-renderability discovered by the probes... brou…
ggcrunchy Oct 26, 2026
e250610
Rough system.getInfo() stuff
ggcrunchy Oct 27, 2026
dd7f8c4
Test for compressed format descriptions was broken
ggcrunchy Oct 27, 2026
1c3fdf1
Some cleanup... and a helper for common custom texture format descrip…
ggcrunchy Oct 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions librtt/Core/Rtt_Math.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,43 @@ template < > Rtt_TYPES_INLINE long double Abs< long double >( long double a ) {

// ----------------------------------------------------------------------------

#if defined( Rtt_WIN_ENV )
Rtt_INLINE unsigned int Rtt_Pop16( U16 v )
{
v -= ( ( v >> 1 ) & 0x5555 );

v = ( ( v >> 2 ) & 0x3333 ) + ( v & 0x3333 );
v = ( ( v >> 4 ) + v ) & 0x0F0F;

return ( ( v >> 8 ) + v ) & 0x00FF;
}

Rtt_INLINE unsigned int Rtt_Pop32( U32 v )
{
v -= ( v >> 1 ) & 0x55555555;

v = ( v & 0x33333333 ) + ( ( v >> 2 ) & 0x33333333 );

return ( ( v + ( v >> 4 ) & 0x0F0F0F0F ) * 0x01010101 ) >> 24;
}

Rtt_INLINE unsigned int Rtt_Pop64( U64 v )
{
v -= ( v >> 1 ) & 0x5555555555555555ULL;

v = ( v & 0x3333333333333333ULL ) + ( ( v >> 2 ) & 0x3333333333333333ULL );
v = ( v + ( v >> 4 ) ) & 0x0F0F0F0F0F0F0F0FULL;

return ( v * 0x0101010101010101ULL ) >> 56;
}
#else
#define Rtt_Pop16 __builtin_popcount
#define Rtt_Pop32 __builtin_popcount
#define Rtt_Pop64 __builtin_popcountll
#endif

// ----------------------------------------------------------------------------

} // Rtt

#endif // __cplusplus
Expand Down
127 changes: 126 additions & 1 deletion librtt/Core/Rtt_String.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "Core/Rtt_New.h"

#include <string.h>
#include <ctype.h>

// ----------------------------------------------------------------------------

Expand Down Expand Up @@ -213,7 +214,7 @@ template<typename T, T kPrime, T kOffsetBasis>
T
GetHash( const char* buffer )
{
// https://en.wikipedia.org/wiki/Fowler�Noll�Vo_hash_function
// https://en.wikipedia.org/wiki/Fowler�Noll�Vo_hash_function
T hash = kOffsetBasis;

if ( NULL != buffer ) // if absent, interpret as empty string
Expand Down Expand Up @@ -322,6 +323,130 @@ String::RTrim(const char *trimChars)
}
}

// Encoding bit layout, for bytes 0-3:
// 0 0 0 0 0 0 1 1 | 1 1 1 1 2 2 2 2 | 2 2 3 3 3 3 3 3

enum {

#define COUNT_AND_OFFSET( NAME, COUNT, OFFSET ) kCount##NAME = COUNT, kOffset##NAME = OFFSET
#define AFTER_PREV( PREV ) kOffset##PREV + kCount##PREV
#define NEXT_COUNT_AND_OFFSET( NAME, OFFSET ) COUNT_AND_OFFSET( NAME, kMax##NAME - kMin##NAME + 1, OFFSET )

kMinUpper = 'A', kMaxUpper = 'Z',
kMinLower = 'a', kMaxLower = 'z',
kMinDigit = '0', kMaxDigit = '9',

NEXT_COUNT_AND_OFFSET( Upper, 0 ),
NEXT_COUNT_AND_OFFSET( Lower, AFTER_PREV( Upper ) ),
NEXT_COUNT_AND_OFFSET( Digit, AFTER_PREV( Lower ) ),
kOffsetUnderscore = AFTER_PREV( Digit ),
kOffsetNUL = kOffsetUnderscore + 1

#undef COUNT_AND_OFFSET
#undef AFTER_PREV
#undef NEXT_COUNT_AND_OFFSET

};

Rtt_STATIC_ASSERT( kOffsetNUL + 1 == 64 );

int
String::EncodeIdentifier( U8* buf, const char* ident, int maxTriples )
{
if ( !isalpha( *ident ) && *ident != '_' )
{
Rtt_LogException( "ERROR: Identifier must begin with a letter or underscore, got '%c'", *ident );

return -1;
}

// TODO? empty string; maxTriples == 0

#define PLUS_1_PRED( COND, RESULT ) ( ( COND ) ? 1 + ( RESULT ) : 0 )
#define OFFSET_PLUS_1( CHAR, NAME ) PLUS_1_PRED( ( (U32)( CHAR - kMin##NAME ) ) <= ( (U32)( kMax##NAME - kMin##NAME ) ), kOffset##NAME + CHAR - kMin##NAME )

int k = 0, bufSize = maxTriples * 3, bad = 0;

do {
U8 work[4] = { kOffsetNUL, kOffsetNUL, kOffsetNUL, kOffsetNUL };

for (int j = 0; *ident && j < 4; ++ident, ++j)
{
int c = *ident;
U8 code = PLUS_1_PRED( 0 == c, kOffsetNUL ) | PLUS_1_PRED( '_' == c, kOffsetUnderscore ) |
OFFSET_PLUS_1( c, Upper ) | OFFSET_PLUS_1( c, Lower ) | OFFSET_PLUS_1( c, Digit );

bad = ( 0 == code ) ? c : bad;
work[j] = code - 1;
}

// This check prevents overflow, but will lead to bogus results. This is mainly
// intended to detect encodability, in which case the results are thrown away.
k = Min( k + 3, bufSize );

buf[k - 3] = ( work[0] << 2 ) | ( work[1] >> 4 );
buf[k - 2] = ( work[1] << 4 ) | ( work[2] >> 2 );
buf[k - 1] = ( work[2] << 6 ) | ( work[3] >> 0 );
} while ( *ident );

#undef PLUS_1_PRED
#undef OFFSET_PLUS_1

if ( bad )
{
Rtt_LogException( "ERROR: Non-identifier character(s) found, including %c", bad );

return -1;
}

return k;
}

bool
String::IsIdentifier( const char* name )
{
U8 junk[3];

return EncodeIdentifier( junk, name, 1 ) > 0;
}

U32
String::DecodeIdentifier( char* name, const U8* buf, int numTriples )
{
const char* start = name;
for ( int i = 0; i < numTriples; i++, buf += 3 )
{
U32 b1 = buf[0], b2 = buf[1], b3 = buf[2];
U32 work[] = {
b1 >> 2,
( ( b1 & 0x3 ) << 4 ) | ( b2 >> 4 ),
( ( b2 & 0xF ) << 2 ) | ( b3 >> 6 ),
b3 & 0x3F,
kOffsetNUL
};

for ( int k = 0; work[k] < kOffsetNUL; ++k )
{
static const char kSymbols[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789_";

*name++ = kSymbols[work[k]];
}
}

*name = 0;

return (U32)( name - start );
}

int
String::IdentifierLengthToTriples( int length )
{
return ( length + 3 ) / 4;
}

void
String::AppendPathComponent(const char *pathComponent)
{
Expand Down
10 changes: 9 additions & 1 deletion librtt/Core/Rtt_String.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,18 @@ class String
void LTrim(const char *trimChars);
void RTrim(const char *trimChars);

// Identifier operations

static int EncodeIdentifier( U8* buf, const char* ident, int maxTriples );
static bool IsIdentifier( const char* name );
static U32 DecodeIdentifier( char* name, const U8* buf, int numTriples );

static int IdentifierLengthToTriples( int length );

// Path operations

// Append the given string to the end of the path including one path separator
void AppendPathComponent(const char *);
void AppendPathComponent(const char *);
// Remove the last path component from the string (noop if no path separators in string)
void RemovePathComponent();
// Ensure string ends with one path separator
Expand Down
123 changes: 116 additions & 7 deletions librtt/Corona/CoronaGraphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
CORONA_API
int CoronaExternalPushTexture( lua_State *L, const CoronaExternalTextureCallbacks *callbacks, void* context)
{
if ( callbacks->size != sizeof(CoronaExternalTextureCallbacks) )
// scoop up extensions, validate, etc.
if ( callbacks->size != sizeof(CoronaExternalTextureCallbacks) && callbacks->size != sizeof(CoronaExternalTextureCallbacks2) )
{
CoronaLuaError(L, "TextureResourceExternal - invalid binary version for callback structure; size value isn't valid");
return 0;
Expand All @@ -55,6 +56,30 @@ int CoronaExternalPushTexture( lua_State *L, const CoronaExternalTextureCallback
return 0;
}

if ( sizeof(CoronaExternalTextureCallbacks2) == callbacks->size )
{
CoronaExternalTextureCallbacks2* callbacks2 = (CoronaExternalTextureCallbacks2*)callbacks;
if ( NULL == callbacks2->firstExtension )
{
CoronaLuaError(L, "TextureResourceExternal - no extensions provided to version 2 callbacks");
return 0;
}

U64 used = 0;
for ( const CoronaExternalTextureExtensionHeader* ext = callbacks2->firstExtension; NULL != ext; ext = ext->next )
{
U64 mask = 1U << ext->type;
if ( used & mask )
{
CoronaLuaError(L, "TextureResourceExternal - extension %i seen more than once", ext->type);
return 0;
}
used |= mask;
}
// TODO: at some point might want to validate certain combinations
// TODO: validate legal setups...
}

static unsigned int sNextExternalTextureId = 1;
char filename[30];
snprintf(filename, 30, "corona://exTex_%u", sNextExternalTextureId++);
Expand Down Expand Up @@ -97,6 +122,87 @@ int CoronaExternalFormatBPP(CoronaExternalBitmapFormat format)
}
}


// ----------------------------------------------------------------------------

static Rtt::Renderer &
GetRenderer( lua_State * L )
{
return Rtt::LuaContext::GetRuntime( L )->GetDisplay().GetRenderer();
}

static int
TryToCommitDescription( lua_State* L, Rtt::Renderer& renderer, const Rtt::TextureFormatDescription& desc )
{
Rtt::TextureFactory& factory = Rtt::LuaContext::GetRuntime( L )->GetDisplay().GetTextureFactory();

if ( factory.AddCustomFormat( desc ) )
{
U32 count = factory.GetCurrentFormatCount();
Rtt_ASSERT( count > 0 );

renderer.UpdateCustomFormats( factory.GetCurrentFormatList(), count );

return count;
}
else
{
Rtt_TRACE_SIM(( "Too many texture formats defined" ));

return 0;
}
}

CORONA_API
int CoronaDefineStandardTextureFormat( lua_State * L, const CoronaTextureFormatDetails * details, unsigned int componentCount, unsigned int bytesPerComponent )
{
Rtt::Renderer& renderer = GetRenderer( L );
Rtt::TextureFormatDescription desc = Rtt::TextureFormatDescription::MakeStandard();

desc.fNumComponents = componentCount;
desc.fBytesPerComponent = bytesPerComponent;

if ( renderer.MatchToFormatDescription( &desc, details ) )
{
return TryToCommitDescription( L, renderer, desc );
}
return 0;
}

CORONA_API
int CoronaDefineWordPackedTextureFormat( lua_State * L, const CoronaTextureFormatDetails * details, unsigned int bitCounts[4] )
{
Rtt::Renderer& renderer = GetRenderer( L );
Rtt::TextureFormatDescription desc = Rtt::TextureFormatDescription::MakeWordPacked();

for ( int i = 0; i < 4; i++ )
{
desc.fSizes[i] = bitCounts[i];
}
desc.fFlags |= Rtt::TextureFormatDescription::kIsWordPacked;

if ( renderer.MatchToFormatDescription( &desc, details ) )
{
return TryToCommitDescription( L, renderer, desc );
}
return 0;
}

CORONA_API
int CoronaDefineCompressedTextureFormat( lua_State * L, const CoronaCompressedTextureFormatDetails * details, unsigned int componentCount )
{
Rtt::Renderer& renderer = GetRenderer( L );
Rtt::TextureFormatDescription desc = Rtt::TextureFormatDescription::MakeCompressed();

desc.fNumComponents = componentCount;

if ( renderer.MatchToFormatDescription( &desc, details ) )
{
return TryToCommitDescription( L, renderer, desc );
}
return 0;
}

// ----------------------------------------------------------------------------

OBJECT_HANDLE_DEFINE_TYPE( Renderer );
Expand All @@ -107,12 +213,6 @@ OBJECT_HANDLE_DEFINE_TYPE( CommandBuffer );

// ----------------------------------------------------------------------------

static Rtt::Renderer &
GetRenderer( lua_State * L )
{
return Rtt::LuaContext::GetRuntime( L )->GetDisplay().GetRenderer();
}

CORONA_API
void CoronaRendererInvalidate( lua_State * L )
{
Expand Down Expand Up @@ -462,6 +562,15 @@ int CoronaGeometryUnregisterVertexExtension( lua_State * L, const char * name )
CORONA_API
int CoronaShaderGetEffectDetail( const CoronaShader * shader, int index, CoronaEffectDetail * detail )
{
static bool sHasWarned;

if ( !sHasWarned )
{
Rtt_LogException( "WARNING: effect details likely to be deprecated" );

sHasWarned = true; // n.b. a bit flaky; won't refire on relaunch
}

const Rtt::Shader * shaderObject = OBJECT_HANDLE_LOAD( Shader, shader );

if (shaderObject)
Expand Down
Loading