Commit Graph

383 Commits

Author SHA1 Message Date
Luke Benstead
2178d2f6d7 Improve lighting performance
This is (another) first pass at improving the performance of the lighting code.
As part of this refactor *we have lost glColorMaterial*. I need to figure out a
nice way of implementing it without slowing the common code path.
2020-02-16 20:36:49 +00:00
Luke Benstead
dafc56c396 Add new file 2020-01-01 14:30:03 +00:00
Luke Benstead
eeb95193ac Fix overflow 2019-12-27 19:35:18 +00:00
Luke Benstead
b2a2e71795 Much faster lighting implementation 2019-12-27 10:36:30 +00:00
Luke Benstead
a280dac778 Performance improvements 2019-11-30 10:07:41 +00:00
Luke Benstead
62b53f0fb1 Simplify swapVertex 2019-11-30 10:07:23 +00:00
Luke Benstead
e61369674c Change where txr.alpha is set 2019-11-30 10:07:04 +00:00
Luke Benstead
e97dd466aa Fix depth test functions 2019-11-30 10:06:46 +00:00
Luke Benstead
cdfb805dd9 Implement a fast path for glDrawElements 2019-11-27 20:08:29 +00:00
Luke Benstead
140eec3d92 glNormalPointer should accept GL_INT_2_10_10_10_REV, not GL_UNSIGNED_INT_2_... 2019-11-27 09:10:10 +00:00
Luke Benstead
11cd54bc0b Add partial support for GL_ARB_vertex_type_2_10_10_10_rev and also GL_NORMALIZE 2019-11-18 17:39:09 +00:00
Luke Benstead
fd3e7cde6c Improve the light sample + tweaks 2019-11-14 21:12:27 +00:00
Luke Benstead
8654ff24a2 Add light sample and fix lighting bug 2019-11-14 10:04:15 +00:00
Luke Benstead
9f3adc099a Fix a bad reference 2019-11-12 17:28:39 +00:00
Hayden Kowalchuk
805c68e973 remove single minus sign 2019-10-04 10:29:54 -04:00
Luke Benstead
f59e9bf56e Implement GL_ARB_vertex_array_bgra 2019-09-30 21:59:11 +01:00
Luke Benstead
d7e424a766 Initial implementation of a fast-path (currently some corruption) 2019-09-30 09:14:43 +01:00
Luke Benstead
2c5b71b2b0 Implement mipmap generation for paletted textures 2019-09-26 09:17:07 +01:00
Luke Benstead
08ba39f6d1 Fix twiddled mipmap generation 2019-09-25 13:45:08 +01:00
Luke Benstead
2e1e28ce51 More mipmap generation fixes 2019-09-25 13:32:13 +01:00
Luke Benstead
36a3f7082f Implement mipmap generation for twiddled textures 2019-09-25 13:10:34 +01:00
Luke Benstead
e14db20a41 Fix a bunch of mipmap issues 2019-09-24 21:26:17 +01:00
Luke Benstead
2b53f50c46 Add some copy safety and remove some print statements 2019-09-24 19:39:23 +01:00
Luke Benstead
150c95bd33 Huge refactor of mipmap handling. All textures are now stored twiddled on the PVR 2019-09-24 15:47:23 +01:00
Luke Benstead
888a48562f Generate version.h and print version on boot. Fixes #46 2019-09-22 21:48:43 +01:00
Luke Benstead
8f84cbb142 Various cleanups from @mrneo 2019-09-22 20:52:58 +01:00
Ben Baron
b192bfc451 Fixed comment 2019-09-17 08:28:43 -05:00
Ben Baron
cb675434c7 Fixed GL_ALPHA support (convert to argb format) 2019-09-16 20:48:06 -05:00
Luke Benstead
e39632bcc4 Refactor matrix management and clipping 2019-09-14 20:51:47 +01:00
Luke Benstead
e7f2ad7dcc Optimise multitexture submission 2019-09-09 09:36:06 +01:00
Luke Benstead
3af18cb514 Refactor the perspective divide to work with glDepthRange 2019-09-08 17:27:56 +01:00
Luke Benstead
1d32834b52 Simplify texture and blending context updates 2019-09-06 09:35:57 +01:00
Luke Benstead
22690600d0 Don't include kos headers from gl.h 2019-09-06 09:35:33 +01:00
Luke Benstead
4170655a88 If someone attempts to use lines, just log an error and render nothing (for now) 2019-09-06 09:34:55 +01:00
Luke Benstead
8e59b9adb5 Make sure we clamp floating point colours to avoid overflows 2019-09-04 17:59:57 +01:00
Luke Benstead
57f4f62f86 Implement glColor3ubv 2019-08-20 20:42:29 +01:00
Luke Benstead
b6fccd3148 Use PVR_TXRENV_MODULATE instead of MODULATEALPHA. Fixes #48 2019-08-08 09:36:38 +01:00
Luke Benstead
b82d28130d Rewrite the lighting code 2019-08-01 20:21:13 +01:00
Luke Benstead
3395f17687 Throw GL_INVALID_OPERATION if mipmaps are specified for non-square textures 2019-04-17 16:19:03 +01:00
Luke Benstead
62743d42cb Only allocate space for mipmaps when necessary 2019-04-17 14:55:30 +01:00
Luke Benstead
a8d420299c Correctly throw GL_INVALID_VALUE for invalid sizes 2019-04-14 08:51:37 +01:00
Luke Benstead
6cfb4e437c Handle GL_DOUBLE like GL_FLOAT everywhere 2019-04-14 07:17:27 +01:00
Luke Benstead
cb692f59b4 Remove unnecessary conditional check 2019-04-01 09:57:33 +01:00
Luke Benstead
d912680ef0 Update version string 2019-03-30 07:15:50 +00:00
Luke Benstead
e876dcb14f Massively optimise GL_POLYGON/GL_TRIANGLE_FAN 2019-03-29 11:26:19 +00:00
Luke Benstead
9fafe31a37 Disable profiler 2019-03-29 11:26:19 +00:00
Luke Benstead
a75ced3fef Speed up immediate mode submission 2019-03-29 11:26:19 +00:00
Luke Benstead
1e18fbc527 Fix twiddling code. Fixes #37 2019-03-29 11:26:19 +00:00
Luke Benstead
2e33dc0718 Add missing profiler_pop(). Fixes #36 2019-03-29 11:26:19 +00:00
Luke Benstead
41ee67cbf1 Code cleanup 2019-03-28 13:10:53 +00:00
Luke Benstead
e15a47b6fb Use the list stored on the SubmissionTarget 2019-03-28 13:09:36 +00:00
Luke Benstead
3cd15de332 Add additional traces 2019-03-28 13:09:04 +00:00
Luke Benstead
8982444406 Consistently allow > 16384 verts 2019-03-28 13:07:53 +00:00
Luke Benstead
cd04784c33 Fix memory corruption 2019-03-28 13:05:13 +00:00
Luke Benstead
30f8564298 Fix glDrawElements 2019-03-27 09:39:06 +00:00
Luke Benstead
434f316526 Switch pointer comparisons for counters 2019-03-26 09:09:07 +00:00
Luke Benstead
d44a24d339 Add assertions 2019-03-25 19:43:03 +00:00
Luke Benstead
9e12e15a13 Make use of swapVertex 2019-03-25 19:30:45 +00:00
Luke Benstead
bdeb9cd45a Restore clipping case that apparently can happen after all 2019-03-25 19:04:50 +00:00
Luke Benstead
493592ea30 Tweaks 2019-03-25 16:07:27 +00:00
Luke Benstead
ba04f62f6d Minor optimisation 2019-03-25 16:07:12 +00:00
Luke Benstead
f712f00602 Don't do anything if there are no vertices submitted 2019-03-25 16:06:41 +00:00
Luke Benstead
4355d0f224 Add additional profiler checkpoints 2019-03-25 16:06:28 +00:00
Luke Benstead
70feea6c6f Minor optimisations 2019-03-25 16:05:36 +00:00
Luke Benstead
b771a5339b Send colours as bytes in immediate mode 2019-03-25 12:56:48 +00:00
Luke Benstead
8fd90bd040 Switch back to normal swapping 2019-03-25 12:38:34 +00:00
Luke Benstead
0e71588e6c Try to optimise the quad generation 2019-03-25 10:33:05 +00:00
Luke Benstead
671881eafd Optimise GL_POLYGON rendering 2019-03-25 09:48:58 +00:00
Luke Benstead
291e82d18a Rename ClipVertex -> Vertex 2019-03-25 09:44:59 +00:00
Luke Benstead
bd0ef4cba3 Demo multitexturing in zclip, default to GL_MODULATE on multitexture 2019-03-24 14:09:52 +00:00
Luke Benstead
5e6927d9a1 Huge refactor of the drawing code 2019-03-24 08:09:02 +00:00
Luke Benstead
3cb24c4fb4 Rename some functions 2019-03-14 13:16:55 +00:00
Luke Benstead
e9c8836181 Huge cleanup of glDrawElements handling 2019-03-14 13:15:56 +00:00
Luke Benstead
1ee16d8ee1 Slight optimisation 2019-03-13 17:38:42 +00:00
Luke Benstead
7c33f13438 Allow configuring initial capacities 2019-03-13 15:43:50 +00:00
Luke Benstead
d9539da841 Optimisations 2019-03-13 15:35:42 +00:00
Luke Benstead
8101e43e90 Fix winding issue 2019-03-13 15:19:28 +00:00
Luke Benstead
724ff628aa Fix some signedness issues 2019-03-13 15:14:09 +00:00
Luke Benstead
8b206f012e Make sure we correctly initalize the used banks 2019-03-13 12:05:06 +00:00
Luke Benstead
5bf58ec1a8 Refactor array submission to be (hopefully) faster 2019-03-13 11:24:35 +00:00
Luke Benstead
5da1ed732a Bump the default vbuf capacity 2019-03-13 08:53:35 +00:00
Luke Benstead
3d8fa7027b Properly forward the internal_palette_format 2019-03-13 08:51:05 +00:00
Luke Benstead
2ad23b1e16 Update version string 2019-03-11 19:54:55 +00:00
Luke Benstead
8b13e3adaf Reserve 0 in the framebuffer thing (WIP) 2019-03-11 19:24:08 +00:00
Luke Benstead
957ebfa662 Fix texture twiddling 2019-03-11 19:14:30 +00:00
Luke Benstead
588c082ec8 Allow specifying palette, autosort, memory options via glKosInitEx 2019-03-11 19:07:59 +00:00
Luke Benstead
8f26e9c364 Fix a bug in the morton_index function 2019-03-11 09:12:48 +00:00
Luke Benstead
a561fd469f Protect against invalid read 2019-03-10 20:18:11 +00:00
Luke Benstead
834599dc4b Add glDrawBuffer stub 2019-03-10 20:05:40 +00:00
Luke Benstead
7512c1e767 Fix GL_ALPHA_TEST sample 2019-03-10 19:59:34 +00:00
Luke Benstead
e4186a05bf Start working on a test for GL_ALPHA_TEST 2019-03-10 19:38:47 +00:00
Luke Benstead
04dab8da9a Implement glAlphaFunc and glEnable(GL_ALPHA_TEST) 2019-03-10 17:53:58 +00:00
Luke Benstead
25bd3aedc8 Increase the max polygon size to 32 2019-03-10 16:10:59 +00:00
Luke Benstead
91c3b66d73 Add GL_MODELVIEW_MATRIX as an option to glGetFloatv 2019-03-10 12:30:39 +00:00
Luke Benstead
b00b65af54 Fix issues with triangle fans / polygons 2019-03-10 12:24:27 +00:00
Luke Benstead
1807a0119c Add some missing function stubs 2019-03-10 12:19:45 +00:00
Luke Benstead
259a82e69f Add support for multiple shared palettes 2019-03-10 11:18:56 +00:00
Luke Benstead
864dc45d10 Allocate palette slots on a FIFO basis 2019-03-09 14:32:50 +00:00
Luke Benstead
4d6cea59b7 Increase the max texture count 2019-03-08 21:38:39 +00:00
Luke Benstead
516cae7893 Store palettes in RAM not VRAM 2019-03-08 21:36:53 +00:00
Luke Benstead
ac3ffb9ce0 Make the binary symbols more compatible 2019-03-08 21:36:53 +00:00
Luke Benstead
df3cdf0ebb Fix drawing polygons. Fixes #35 2019-03-07 21:41:25 +00:00
Luke Benstead
d7342fa0c0 Automatically twiddle non-twiddled palette data 2019-03-07 21:21:30 +00:00
Luke Benstead
3e1ed8a5f7 Don't reserve more space than we need 2019-03-06 08:31:06 +00:00
Luke Benstead
d89997a277 Simplify the element drawing 2019-03-04 20:41:33 +00:00
Luke Benstead
7c0a123aac Correctly initialize the shared palette. Fixes #34 2019-03-04 08:44:19 +00:00
Luke Benstead
efa63ebff2 Don't apply the shared palette if it hasn't been specified yet. Fixes #34 2019-03-04 08:42:24 +00:00
Luke Benstead
11bb588279 Make sure we reupload the palette if it's changed by glColorTableEXT 2019-03-03 20:21:42 +00:00
Luke Benstead
526b1f0d16 Add some assertions 2019-03-03 19:49:28 +00:00
Luke Benstead
ba4fde3975 Fix depth funcs 2019-03-03 19:41:19 +00:00
Luke Benstead
44ca14bcbd Add assertions 2019-03-03 19:11:53 +00:00
Luke Benstead
5f7fef2cf9 Prefix non-static private functions with '_gl' 2019-03-03 19:06:01 +00:00
Luke Benstead
926214bd82 Prefix some non-static private functions with '_gl' 2019-03-03 19:02:25 +00:00
Luke Benstead
2382126603 Make palette binding lazy 2019-03-03 18:56:18 +00:00
Luke Benstead
ef06af793a Don't apply the color table unless a texture is bound 2019-03-03 18:54:25 +00:00
Luke Benstead
3c3018450f Support twiddled and non-twiddled paletted textures 2019-03-03 18:49:33 +00:00
Luke Benstead
d12032c961 Store palette data in PVR ram 2019-03-03 18:49:06 +00:00
Luke Benstead
f349cd1b49 Fix packing order issue (thanks @mrneo240!) 2019-03-03 18:48:50 +00:00
Luke Benstead
cf273eab42 Add glTexParameterf (thanks @mrneo240) 2019-02-28 19:21:16 +00:00
Luke Benstead
b0c9ac7207 Remove zero special casing from named array 2019-02-28 18:33:37 +00:00
Luke Benstead
31ed419dfa Don't allow zero as a valid texture ID 2019-02-28 18:28:55 +00:00
Luke Benstead
02937ccd2c Add stub with just GL_PROJECTION_MATRIX supported 2019-02-28 08:46:13 +00:00
Luke Benstead
111d4ca83e Handle calling glBindTexture on an unknown name 2019-02-27 20:45:53 +00:00
Luke Benstead
f6af3ab3fb Implement new conversion 2019-02-27 20:11:14 +00:00
Luke Benstead
920fc2b782 Increase the max number of textures to 512. Add config.h for settings like this. Fixes #29 2019-02-25 08:30:02 +00:00
Luke Benstead
7368f5c290 Add GL_SHARED_TEXTURE_PALETTE_EXT as a valid target to glColorTableEXT. Fixes #27 2019-02-25 08:26:04 +00:00
Luke Benstead
6d2c47bda1 Implement GL_EXT_shared_texture_palette 2019-02-21 21:58:31 +00:00
Luke Benstead
50f1e277d8 Merge branch 'master' into ext-paletted-texture 2019-02-21 21:26:23 +00:00
Luke Benstead
571438ef4e Implement glColorTableEXT 2019-02-21 20:35:18 +00:00
Luke Benstead
df44c0ea73 More performance work and fix bugs introduced in last commit 2018-10-09 09:27:53 +01:00
Luke Benstead
18759422ea Optimise non-indexed rendering paths 2018-10-08 22:03:50 +01:00
Luke Benstead
c84f211ad0 More work towards paletted textures 2018-09-22 20:45:17 +01:00
Luke Benstead
e4f8cb8c9b Add a width limit 2018-09-20 16:48:26 +01:00
Luke Benstead
9645b10ed6 Add paletted texture to the supported extensions 2018-09-20 15:11:01 +01:00
Luke Benstead
8670fd459c More conversions 2018-09-20 15:10:08 +01:00
Luke Benstead
741707ac85 Implement conversions to RGBA8 2018-09-20 15:08:06 +01:00
Luke Benstead
21ad46ad94 Make it clear that some things aren't yet implemented 2018-09-20 15:02:22 +01:00
Luke Benstead
baf7cf5bdd Stub out glColorTableEXT 2018-09-20 15:01:13 +01:00
Luke Benstead
52e1be498e Keep header pointer updated. Fixes #25 (hopefully...) 2018-09-19 17:11:56 +01:00
Luke Benstead
e36f561ec0 Improve check 2018-09-15 17:41:58 +01:00
Luke Benstead
6aadc1124f Fix another zclipping bug 2018-09-15 17:38:42 +01:00
Luke Benstead
bc2fb6b658 Fix a clipping bug 2018-09-15 16:03:21 +01:00
Luke Benstead
7100ebe5a9 Prefix some non-static private methods 2018-09-15 11:45:38 +01:00
Luke Benstead
6cfccbd20d Inline + Static some lighting functions 2018-09-15 11:42:56 +01:00
Luke Benstead
e68c051991 Add missing glColorMaterial definition 2018-09-15 11:42:42 +01:00
Luke Benstead
17c9699966 More clipping fixes 2018-09-08 20:53:28 +01:00
Luke Benstead
06b065dc7e Return the correct count from clip 2018-09-06 20:08:55 +01:00
Luke Benstead
93af697092 Don't include the header in startOffset 2018-09-06 20:00:18 +01:00
Luke Benstead
d9fa69c288 Fix invalid memory access bug 2018-09-06 19:46:04 +01:00
Luke Benstead
b4539443f5 Allow toggling debug logging 2018-09-06 19:45:52 +01:00
Luke Benstead
e82646faff Remove old clipping code 2018-09-06 19:22:25 +01:00
Luke Benstead
af54c96ff4 Implement new culling algorithm, still some issues when GL_CULL_FACE is enabled 2018-09-06 19:19:00 +01:00
Luke Benstead
517d21b487 Begin implementing a new clipping algorithm 2018-09-03 21:48:42 +01:00
Luke Benstead
19491173e5 Set registers correctly before using store queues.
Fixes #23
2018-09-03 20:47:24 +01:00
Luke Benstead
55b3aa4ddd Fix up twiddled formats with alpha 2018-08-28 17:51:33 +01:00
Luke Benstead
963eeb54da Start work on spotlights 2018-08-28 15:55:50 +01:00
Luke Benstead
c191ced3f9 Fix issues with directional lights 2018-08-28 09:24:51 +01:00
Luke Benstead
acaecf49bc Add a missing header 2018-08-27 21:35:15 +01:00
Luke Benstead
8b3bf5a579 Fix lighting wrapping 2018-08-27 21:35:07 +01:00
Luke Benstead
8ef04be966 Try to fix directional lights 2018-08-27 20:54:20 +01:00
Luke Benstead
b29303fb6c Implement glColorMaterial 2018-08-22 09:24:49 +01:00
Luke Benstead
21f8f9d855 Properly restore state after glEnd 2018-08-21 16:15:43 +01:00
Luke Benstead
9b0322ce8a Properly restore enabled client state when using immediate mode 2018-08-21 16:08:06 +01:00
Luke Benstead
edae8a9166 Properly pop active client texture in immediate mode 2018-08-21 15:50:59 +01:00
Luke Benstead
25de48b3f6 Fix a bug where only one texture would bind 2018-08-21 15:50:41 +01:00
Luke Benstead
8b834ac3f1 Avoid an additional copy of every vertex. Fixes #22 2018-08-21 09:37:19 +01:00
Luke Benstead
bccd1aa788 Start refactoring the submission process 2018-08-20 21:19:12 +01:00
Luke Benstead
80c65d4aff Remove conditional header sending, it's slightly slower 2018-08-20 20:34:11 +01:00
Luke Benstead
da97483eee Switch to using 4-byte colours internally rather than floats
These are stored in BGRA format so they can be directly cast to a uint32_t to get the
correct format for the argb param in pvr_vertex_t (yay endianess)

This results in a performance improvement as it reduces the data requirements.
2018-08-20 09:28:30 +01:00
Luke Benstead
26bd8df37c Fix some bugs with mipmaps + compressed textures 2018-08-20 08:34:54 +01:00
Luke Benstead
25e4518501 Performance optimisations 2018-08-19 21:10:42 +01:00
Luke Benstead
348e09b4aa Further optimisations 2018-08-17 21:40:27 +01:00
Luke Benstead
37ba9bf3c3 Mark mipmap levels as complete when generated 2018-08-16 17:53:39 +01:00
Luke Benstead
ba66608a96 Add a basic profiler and optimise some code 2018-08-16 17:51:15 +01:00
Luke Benstead
7d1b57fb12 Handle GL_RED -> GL_RED 2018-08-14 15:55:03 +01:00
Luke Benstead
021237f258 Fix a number of issues with texture loading 2018-08-14 09:49:31 +01:00
Luke Benstead
dca991ffe3 Fix a number of minor issues with textures 2018-08-13 09:19:16 +01:00
Luke Benstead
e7cd91a91f Try to match GL filtering with PVR filtering 2018-08-09 09:32:29 +01:00
Luke Benstead
5c190c1095 Implement glGenerateMipmapEXT 2018-08-09 08:56:43 +01:00
Luke Benstead
c6ba127bc9 Always allocate room for mipmaps 2018-08-08 16:50:09 +01:00
Luke Benstead
4c99dd740a Add support for mipmapped compressed textures 2018-08-08 09:50:57 +01:00
Luke Benstead
b06f6116c8 Detect multiple mipmap levels being uploaded to glCompressedTexImage2D 2018-08-08 08:45:25 +01:00
Luke Benstead
86dd5dd2b2 glCompressedTexImage2D is an ARB extension in OpenGL 1.2.1 2018-08-07 20:49:10 +01:00
Luke Benstead
c40d3a007d Implement support for GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB and GL_COMPRESSED_TEXTURE_FORMATS_ARB 2018-08-07 20:46:26 +01:00
Luke Benstead
16d949bfbc Clean up compressed texture constants and code 2018-08-07 20:22:44 +01:00
Luke Benstead
0b91c20bbd Add support for getting the max texture size 2018-08-07 08:45:24 +01:00
Luke Benstead
85d4bb5ec3 Fix directional lighting bug 2018-08-05 14:38:04 +01:00
Luke Benstead
582a29d267 Add glMultiTexCoord2fARB 2018-08-05 09:09:38 +01:00
Luke Benstead
6942e597f4 Untested multitexture implementation 2018-08-04 21:00:26 +01:00
Luke Benstead
db0d39d487 Cleanup lighting code a bit 2018-08-04 19:34:07 +01:00
Luke Benstead
59002546e6 Fix lighting 2018-08-03 14:08:01 +01:00
Luke Benstead
0bf023b8df Fix a bug where headers weren't sent to a list 2018-08-02 19:56:50 +01:00
Luke Benstead
9371a8164f Don't send headers unnecessarily 2018-08-01 20:41:59 +01:00
Luke Benstead
4716a6a0c0 Cleanups and optimisations 2018-08-01 17:57:31 +01:00
Luke Benstead
39ac10af00 Simplify colour handling 2018-08-01 12:00:56 +01:00
Luke Benstead
bebca59796 Allow toggling z clipping 2018-08-01 11:32:07 +01:00
Luke Benstead
31e666c77a Implement support for GL_UNSIGNED_INT indices 2018-08-01 11:08:51 +01:00
Luke Benstead
47d3c0f478 Minor optimisations 2018-08-01 09:57:44 +01:00
Luke Benstead
02b4b2d438 Fix clipping errors when multiple strips submitted 2018-07-31 09:32:55 +01:00
Luke Benstead
720206810d Use a smaller near plane value (for now) 2018-07-16 09:01:11 +01:00