Skip to content

Commit

Permalink
Implement preview of OpenGL 3.3
Browse files Browse the repository at this point in the history
* default version bumped up to 3.3, functions up to 3.3 added

* added extensions, count brought up from 8 to 167

* fixed pb_memcpy(), which was incorrectly advancing position

* fixed color pointer in glimpl_push_client_pointers()

* added is_value_likely_an_offset()

* replace "commit" with "submit" for REGISTER_COMMIT and glimpl_commit()

* push glVertexAttribPointer to FIFO regardless of client managed state

* make glMapBufferRange return calloc instead of NULL

* implement glDrawElementsInstanced

* fix SGL_CMD_DELETEFRAMEBUFFERS in processor.c

* remove unused variable in GLX backend

* omit unnecessary glFinish call in server

* add note in packet.h regarding packet sizes

* move note regarding glx symlink up in README

* added extra GLX extensions
  • Loading branch information
dmaivel committed Jun 7, 2024
1 parent 78c5a12 commit ab2081d
Show file tree
Hide file tree
Showing 9 changed files with 746 additions and 188 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5.0)
project(sharedgl VERSION 0.5.0 LANGUAGES C CXX)
project(sharedgl VERSION 0.6.0 LANGUAGES C CXX)

include_directories(${CMAKE_SOURCE_DIR}/inc)

Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ cmake --build . --target sharedgl-core --config Release

For detailed build instructions for Windows, visit the [Windows section](#windows-in-a-vm).

If on linux, some applications may require an explicit `libGLX`, so run `ln -s libGL.so.1 libGLX.so.0` in `build` to make a symlink.

# Usage
The server must be started on the host before running any clients. Note that the server can only be ran on Linux.

Expand Down Expand Up @@ -228,11 +230,11 @@ This list describes the amount of functions left from each standard to implement
- [x] OpenGL 2
- [x] 2.0 (~93 total)
- [x] 2.1 (~6 total)
- [ ] OpenGL 3
- [x] OpenGL 3
- [x] 3.0 (~84 total)
- [x] 3.1 (~15 total)
- [ ] 3.2 (~14 remaining) (~19 total)
- [ ] 3.3 (~29 remaining) (~58 total)
- [x] 3.2 (~14 remaining)
- [x] 3.3 (~29 remaining)
- [ ] OpenGL 4
- [ ] 4.0 (~24 remaining) (~46 total)
- [ ] 4.1 (~36 remaining) (~89 total)
Expand All @@ -249,7 +251,6 @@ This list describes the amount of functions left from each standard to implement
- Resizing is possible, no proper implementation
- Some GLFW applications cant request OpenGL profiles
- New GLX FB configs may cause applications using `freeglut` or `glad` to no longer run
- Some applications may require an explicit `libGLX`, so run `ln -s libGL.so.1 libGLX.so.0` in `build` to make a symlink.
# Troubleshooting
You may encounter weird crashes/faults/errors such as `IOT instruction` or `No provider of glXXX found.`. Although the code base is buggy, these are some tips to try to further attempts to get an application to work:
Expand Down
2 changes: 1 addition & 1 deletion inc/client/glimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <commongl.h>

void glimpl_init();
void glimpl_commit();
void glimpl_submit();
void glimpl_goodbye();
void glimpl_report(int width, int height);
void glimpl_swap_buffers(int width, int height, int vflip, int format);
Expand Down
5 changes: 4 additions & 1 deletion inc/network/packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
#include <inttypes.h>

/*
* 1024 * 63
* 256: safe, keeps packet size under 1400 bytes
* 512: medium
* 15360: largest, not to be used over networks due to fragmentation
*/
#define SGL_FIFO_UPLOAD_COMMAND_BLOCK_COUNT 512
#define SGL_FIFO_UPLOAD_COMMAND_BLOCK_SIZE (SGL_FIFO_UPLOAD_COMMAND_BLOCK_COUNT * sizeof(uint32_t))

#define SGL_SWAPBUFFERS_RESULT_SIZE 60000

#ifndef _WIN32
Expand Down
14 changes: 11 additions & 3 deletions inc/sharedgl.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@

#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <time.h>

#define PRINT_LOG(...) \
{ \
Expand All @@ -26,7 +28,7 @@
fprintf(stderr, __VA_ARGS__); \
}

#define SGL_OFFSET_REGISTER_COMMIT (sizeof(int) * 0)
#define SGL_OFFSET_REGISTER_SUBMIT (sizeof(int) * 0)
#define SGL_OFFSET_REGISTER_RETVAL (sizeof(int) * 1)
#define SGL_OFFSET_REGISTER_READY_HINT (sizeof(int) * 2)
#define SGL_OFFSET_REGISTER_LOCK (sizeof(int) * 3)
Expand All @@ -40,10 +42,16 @@
#define SGL_OFFSET_COMMAND_START 0x1000

#define SGL_DEFAULT_MAJOR 3
#define SGL_DEFAULT_MINOR 1
#define SGL_DEFAULT_MINOR 3

#define SGL_SHARED_MEMORY_NAME "sharedgl_shared_memory"

inline bool is_value_likely_an_offset(const void *p)
{
uintptr_t v = (uintptr_t)p;
return v < 0x100000;
}

/*
* commands, pretty much 1:1 mapping for opengl
*/
Expand Down
Loading

0 comments on commit ab2081d

Please sign in to comment.