mirror of
https://github.com/simple64/simple64.git
synced 2026-11-05 20:53:32 +01:00
update parallel rdp
This commit is contained in:
1 parent
578c7bf0f2
commit
877624573d
4 files changed
+44
-12
No files matched your search
@@ -302,6 +302,7 @@ EXPORT void CALL ResizeVideoOutput(int width, int height)
|
||||
{
|
||||
window_width = width;
|
||||
window_height = height;
|
||||
window_changed = true;
|
||||
}
|
||||
|
||||
EXPORT void CALL FBWrite(unsigned int addr, unsigned int size)
|
||||
|
||||
@@ -38,8 +38,15 @@ static PFNGLDELETEPROGRAMPROC glDeleteProgram;
|
||||
static PFNGLUSEPROGRAMPROC glUseProgram;
|
||||
static PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
|
||||
static PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
|
||||
static PFNGLBINDBUFFERPROC glBindBuffer;
|
||||
static PFNGLGENBUFFERSPROC glGenBuffers;
|
||||
static PFNGLDELETEBUFFERSPROC glDeleteBuffers;
|
||||
static PFNGLBUFFERSTORAGEPROC glBufferStorage;
|
||||
static PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
|
||||
static PFNGLUNMAPBUFFERPROC glUnmapBuffer;
|
||||
|
||||
static bool toggle_fs;
|
||||
bool window_changed;
|
||||
|
||||
// framebuffer texture states
|
||||
int32_t window_width;
|
||||
@@ -52,7 +59,9 @@ int32_t window_fullscreen;
|
||||
|
||||
static GLuint program;
|
||||
static GLuint vao;
|
||||
static GLuint buffer;
|
||||
static GLuint texture;
|
||||
static uint8_t *buffer_data;
|
||||
|
||||
int32_t tex_width;
|
||||
int32_t tex_height;
|
||||
@@ -165,13 +174,13 @@ bool screen_write(struct frame_buffer *fb)
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, fb->pitch);
|
||||
// reallocate texture buffer on GPU
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, tex_width,
|
||||
tex_height, 0, TEX_FORMAT, TEX_TYPE, fb->pixels);
|
||||
tex_height, 0, TEX_FORMAT, TEX_TYPE, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// copy local buffer to GPU texture buffer
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, tex_width, tex_height,
|
||||
TEX_FORMAT, TEX_TYPE, fb->pixels);
|
||||
TEX_FORMAT, TEX_TYPE, 0);
|
||||
}
|
||||
|
||||
return buffer_size_changed;
|
||||
@@ -232,13 +241,22 @@ void gl_screen_close(void)
|
||||
tex_width = 0;
|
||||
tex_height = 0;
|
||||
|
||||
glUnmapBuffer(buffer);
|
||||
glDeleteTextures(1, &texture);
|
||||
glDeleteVertexArrays(1, &vao);
|
||||
glDeleteBuffers(1, &buffer);
|
||||
glDeleteProgram(program);
|
||||
}
|
||||
|
||||
uint8_t* screen_get_texture_data()
|
||||
{
|
||||
return buffer_data;
|
||||
}
|
||||
|
||||
void screen_init()
|
||||
{
|
||||
toggle_fs = false;
|
||||
window_changed = false;
|
||||
/* Get the core Video Extension function pointers from the library handle */
|
||||
CoreVideo_Init = (ptr_VidExt_Init)DLSYM(CoreLibHandle, "VidExt_Init");
|
||||
CoreVideo_Quit = (ptr_VidExt_Quit)DLSYM(CoreLibHandle, "VidExt_Quit");
|
||||
@@ -278,6 +296,12 @@ void screen_init()
|
||||
glUseProgram = (PFNGLUSEPROGRAMPROC) CoreVideo_GL_GetProcAddress("glUseProgram");
|
||||
glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC) CoreVideo_GL_GetProcAddress("glGenVertexArrays");
|
||||
glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC) CoreVideo_GL_GetProcAddress("glBindVertexArray");
|
||||
glBindBuffer = (PFNGLBINDBUFFERPROC) CoreVideo_GL_GetProcAddress("glBindBuffer");
|
||||
glGenBuffers = (PFNGLGENBUFFERSPROC) CoreVideo_GL_GetProcAddress("glGenBuffers");
|
||||
glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) CoreVideo_GL_GetProcAddress("glDeleteBuffers");
|
||||
glBufferStorage = (PFNGLBUFFERSTORAGEPROC) CoreVideo_GL_GetProcAddress("glBufferStorage");
|
||||
glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC) CoreVideo_GL_GetProcAddress("glMapBufferRange");
|
||||
glUnmapBuffer = (PFNGLUNMAPBUFFERPROC) CoreVideo_GL_GetProcAddress("glUnmapBuffer");
|
||||
|
||||
// shader sources for drawing a clipped full-screen triangle. the geometry
|
||||
// is defined by the vertex ID, so a VBO is not required.
|
||||
@@ -314,6 +338,11 @@ void screen_init()
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
glGenBuffers(1, &buffer);
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer);
|
||||
glBufferStorage(GL_PIXEL_UNPACK_BUFFER, 640 * 640 * sizeof(uint32_t), 0, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
|
||||
buffer_data = glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, 640 * 640 * sizeof(uint32_t), GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
|
||||
|
||||
// check if there was an error when using any of the commands above
|
||||
gl_check_errors();
|
||||
}
|
||||
@@ -326,8 +355,11 @@ void screen_swap(bool blank)
|
||||
toggle_fs = false;
|
||||
}
|
||||
|
||||
// clear current buffer, indicating the start of a new frame
|
||||
gl_screen_clear();
|
||||
if (window_changed || blank)
|
||||
{
|
||||
gl_screen_clear();
|
||||
window_changed = false;
|
||||
}
|
||||
|
||||
if (!blank)
|
||||
{
|
||||
|
||||
@@ -33,11 +33,12 @@ extern "C"
|
||||
void screen_toggle_fullscreen(void);
|
||||
void screen_close(void);
|
||||
void screen_swap(bool blank);
|
||||
uint8_t* screen_get_texture_data();
|
||||
|
||||
extern int32_t window_width;
|
||||
extern int32_t window_height;
|
||||
extern int32_t window_fullscreen;
|
||||
extern bool window_vsync;
|
||||
extern bool window_changed;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ static const unsigned cmd_len_lut[64] = {
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
};
|
||||
|
||||
void vk_blit(std::vector<RDP::RGBA> &colors, unsigned &width, unsigned &height)
|
||||
void vk_blit(unsigned &width, unsigned &height)
|
||||
{
|
||||
if (running)
|
||||
{
|
||||
@@ -56,20 +56,20 @@ void vk_blit(std::vector<RDP::RGBA> &colors, unsigned &width, unsigned &height)
|
||||
RDP::VIScanoutBuffer scanout;
|
||||
frontend->scanout_async_buffer(scanout, opts);
|
||||
|
||||
uint8_t* color_data = screen_get_texture_data();
|
||||
if (!scanout.width || !scanout.height)
|
||||
{
|
||||
width = 0;
|
||||
height = 0;
|
||||
colors.clear();
|
||||
memset(color_data, 0, width * height * sizeof(uint32_t));
|
||||
return;
|
||||
}
|
||||
|
||||
width = scanout.width;
|
||||
height = scanout.height;
|
||||
colors.resize(width * height);
|
||||
|
||||
scanout.fence->wait();
|
||||
memcpy(colors.data(), device->map_host_buffer(*scanout.buffer, Vulkan::MEMORY_ACCESS_READ_BIT),
|
||||
memcpy(color_data, device->map_host_buffer(*scanout.buffer, Vulkan::MEMORY_ACCESS_READ_BIT),
|
||||
width * height * sizeof(uint32_t));
|
||||
device->unmap_host_buffer(*scanout.buffer, Vulkan::MEMORY_ACCESS_READ_BIT);
|
||||
}
|
||||
@@ -104,8 +104,7 @@ void vk_rasterize()
|
||||
|
||||
unsigned width = 0;
|
||||
unsigned height = 0;
|
||||
std::vector<RDP::RGBA> cols;
|
||||
vk_blit(cols, width, height);
|
||||
vk_blit(width, height);
|
||||
|
||||
if (width == 0 || height == 0)
|
||||
{
|
||||
@@ -114,7 +113,6 @@ void vk_rasterize()
|
||||
}
|
||||
|
||||
struct frame_buffer buf = {0};
|
||||
buf.pixels = (video_pixel *)cols.data();
|
||||
buf.valid = true;
|
||||
buf.height = height;
|
||||
buf.width = width;
|
||||
|
||||
Reference in new issue
Block a user