Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
f3757f6
Global toggle sounds
bladekt Aug 8, 2024
65751e3
Tickshift improvements
bladekt Aug 10, 2024
a35ffa0
Merge branch 'master' into feature/renderer
emyfops Aug 20, 2024
81a0c63
various performance tweaks (3x faster load time)
emyfops Aug 21, 2024
ea972be
todo: pixel buffer object
emyfops Aug 22, 2024
c6328ca
pixel n-buffer object
emyfops Aug 22, 2024
7f35a62
handle empty pbos
emyfops Aug 22, 2024
1bba654
test: streaming to pbo
emyfops Aug 23, 2024
06aba2d
added upload record time
emyfops Aug 24, 2024
68b24da
added debug gremedy labels
emyfops Aug 24, 2024
12e2045
better pbo
emyfops Aug 24, 2024
7cbfd14
better handling
emyfops Aug 24, 2024
a130c8c
removed videos
emyfops Aug 24, 2024
bbd705f
added documentation for pbo
emyfops Aug 24, 2024
4b96556
moved the fbo down one level
emyfops Aug 24, 2024
895a069
removed loader phase time measure
emyfops Aug 24, 2024
ca72b9a
Merge branch 'master' into feature/renderer
emyfops Aug 24, 2024
0644c69
Update build.gradle.kts
emyfops Aug 24, 2024
de3bb6e
TickEvent KDocs
Avanatiker Aug 25, 2024
b40b1ae
Smol refac
Avanatiker Aug 25, 2024
dcf244d
Better logging and remove texture settings
Avanatiker Aug 25, 2024
c97a29c
Introduce constants for texture options
Avanatiker Aug 25, 2024
009f5c1
Merge branch 'master' into feature/renderer
emyfops Sep 22, 2024
47dbf6c
test: video rendering
emyfops Sep 26, 2024
8014bd0
feature: pbo synchronization
emyfops Sep 26, 2024
a8152e9
ref: use 24 bytes for pixel data
emyfops Sep 27, 2024
fac7070
added renderdoc task
emyfops Sep 27, 2024
9da7aac
open bind function
emyfops Sep 27, 2024
d21cc87
added error checks and handling
emyfops Sep 27, 2024
4ed152f
fix: texture buffer binding
emyfops Sep 29, 2024
68fe8e4
refactor: dedicated decoding class
emyfops Oct 1, 2024
a3e0802
refactor: vertex pipeline
emyfops Oct 13, 2024
e3c8a8a
ref: buffer check and ebo fix
emyfops Oct 14, 2024
b471b39
renamed vpipeline variables names
emyfops Oct 14, 2024
b06eba0
fix: minecraft buffer overwrite
emyfops Oct 14, 2024
593fffb
fix: glMapBufferRange returns null
emyfops Oct 18, 2024
8084071
Merge branch 'master' into feature/video
emyfops Oct 19, 2024
2f80a53
unused
emyfops Oct 19, 2024
3ff6bc6
ref: memory utils
emyfops Oct 19, 2024
fface98
fix: byte conversion
emyfops Oct 19, 2024
807b5d2
ref: buffer growth
emyfops Oct 19, 2024
916e0a8
Merge branch 'master' into feature/video
emyfops Oct 23, 2024
97c43cf
Merge branch 'master' into feature/video
emyfops Oct 23, 2024
ff8d28e
copyright notices
emyfops Oct 23, 2024
04f091e
Merge branch 'master' into feature/video
emyfops Oct 23, 2024
7b37548
ignore unchecked cast
emyfops Oct 23, 2024
beddf73
ref: buffer orphaning over mapping
emyfops Oct 27, 2024
33b291d
fix: wrong vertex attributes
emyfops Oct 31, 2024
aa9c7ce
added glBufferStorage option
emyfops Oct 31, 2024
ec2e9d8
check for buffer access flags
emyfops Oct 31, 2024
892b0cd
fix: chunk update in render thread
emyfops Oct 31, 2024
b4f4367
removed unused library
emyfops Oct 31, 2024
7c7449a
Merge branch 'master' into feature/video
emyfops Nov 1, 2024
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
Prev Previous commit
Next Next commit
added documentation for pbo
  • Loading branch information
emyfops committed Aug 24, 2024
commit bbd705f4a4d68bf97a4800e2e72fbef8cdb2d7b2
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ import org.lwjgl.opengl.GL
import org.lwjgl.opengl.GL45C.*
import java.nio.ByteBuffer

/**
* Represents a Pixel Buffer Object (PBO) that facilitates asynchronous data transfer to the GPU.
* This class manages the creation, usage, and cleanup of PBOs and provides methods to map textures and upload data efficiently.
*
* @property width The width of the texture in pixels.
* @property height The height of the texture in pixels.
* @property buffers The number of PBOs to be used. Default is 2, which allows double buffering.
* @property bufferUsage The usage pattern of the buffer, indicating how the buffer will be used (static, dynamic, etc.).
*/
class PixelBuffer(
private val width: Int,
private val height: Int,
Expand All @@ -24,6 +33,12 @@ class PixelBuffer(

private var initialDataSent: Boolean = false

/**
* Maps the given texture ID to the buffer and performs the necessary operations to upload the texture data.
*
* @param id The texture ID to which the buffer will be mapped.
* @param buffer The [ByteBuffer] containing the pixel data to be uploaded to the texture.
*/
fun mapTexture(id: Int, buffer: ByteBuffer) {
if (!initialDataSent) {
glBindTexture(GL_TEXTURE_2D, id)
Expand Down Expand Up @@ -59,6 +74,12 @@ class PixelBuffer(
}
}

/**
* Uploads the given pixel data to the PBO and executes the provided processing function to manage the PBO's data transfer.
*
* @param data The [ByteBuffer] containing the pixel data to be uploaded.
* @param process A lambda function to execute after uploading the data to manage the PBO's data transfer.
*/
fun upload(data: ByteBuffer, process: () -> Unit) =
recordTransfer {
if (buffers >= 2)
Expand Down Expand Up @@ -95,6 +116,11 @@ class PixelBuffer(
writeIdx = uploadIdx
}

/**
* Measures and records the time taken to transfer data to the PBO, calculating the transfer rate in bytes per second.
*
* @param block A lambda function representing the block of code where the transfer occurs.
*/
private fun recordTransfer(block: () -> Unit) {
// Start the timer
glBeginQuery(GL_TIME_ELAPSED, queryId)
Expand All @@ -110,12 +136,19 @@ class PixelBuffer(
if (time > 0) transferRate = (width * height * 4L * 1_000_000_000) / time
}

// Called when no references to the object exist
/**
* Cleans up resources by deleting the PBOs when the object is no longer in use.
*/
fun finalize() {
// Delete the PBOs
glDeleteBuffers(pboIds)
}

/**
* Initializes the PBOs, allocates memory for them, and handles unsupported PBO scenarios.
*
* @throws IllegalArgumentException If the number of buffers is less than 0.
*/
init {
if (buffers < 0) throw IllegalArgumentException("Buffers must be greater than or equal to 0")

Expand Down