diff --git a/internal/graphicsdriver/playstation5/graphics_playstation5.cpp b/internal/graphicsdriver/playstation5/graphics_playstation5.cpp index ad87d98ee550..38f1e8241fc3 100644 --- a/internal/graphicsdriver/playstation5/graphics_playstation5.cpp +++ b/internal/graphicsdriver/playstation5/graphics_playstation5.cpp @@ -61,8 +61,8 @@ ebitengine_DrawTriangles(int dst, const int *srcs, int src_count, int shader, return {}; } -extern "C" ebitengine_Error ebitengine_NewShader(int *shader, - const char *source) { +extern "C" ebitengine_Error +ebitengine_NewShader(int *shader, const ebitengine_ShaderSource *source) { return {}; } diff --git a/internal/graphicsdriver/playstation5/graphics_playstation5.go b/internal/graphicsdriver/playstation5/graphics_playstation5.go index 5fc31684cbae..333f2b68dd41 100644 --- a/internal/graphicsdriver/playstation5/graphics_playstation5.go +++ b/internal/graphicsdriver/playstation5/graphics_playstation5.go @@ -119,9 +119,20 @@ func (g *Graphics) MaxImageSize() int { } func (g *Graphics) NewShader(program *shaderir.Program) (graphicsdriver.Shader, error) { + s := precompiledShaders[program.SourceHash] + ps := C.ebitengine_PrecompiledShader{ + vertex_header: (*C.char)(unsafe.Pointer(unsafe.SliceData(s.vertexHeader))), + vertex_header_size: C.int(len(s.vertexHeader)), + vertex_text: (*C.char)(unsafe.Pointer(unsafe.SliceData(s.vertexText))), + vertex_text_size: C.int(len(s.vertexText)), + pixel_header: (*C.char)(unsafe.Pointer(unsafe.SliceData(s.pixelHeader))), + pixel_header_size: C.int(len(s.pixelHeader)), + pixel_text: (*C.char)(unsafe.Pointer(unsafe.SliceData(s.pixelText))), + pixel_text_size: C.int(len(s.pixelText)), + } + var id C.int - // TODO: Give a source code. - if err := C.ebitengine_NewShader(&id, nil); !C.ebitengine_IsErrorNil(&err) { + if err := C.ebitengine_NewShader(&id, &ps); !C.ebitengine_IsErrorNil(&err) { return nil, newPlaystation5Error("(*playstation5.Graphics).NewShader", err) } return &Shader{ diff --git a/internal/graphicsdriver/playstation5/graphics_playstation5.h b/internal/graphicsdriver/playstation5/graphics_playstation5.h index 0cc675bff072..d518f87b960e 100644 --- a/internal/graphicsdriver/playstation5/graphics_playstation5.h +++ b/internal/graphicsdriver/playstation5/graphics_playstation5.h @@ -103,7 +103,20 @@ ebitengine_DrawTriangles(int dst, const int *srcs, int src_count, int shader, ebitengine_Blend blend, const uint32_t *uniforms, int uniform_count, int fill_rule); -ebitengine_Error ebitengine_NewShader(int *shader, const char *source); +typedef struct ebitengine_PrecompiledShader { + char *vertex_header; + int vertex_header_size; + char *vertex_text; + int vertex_text_size; + char *pixel_header; + int pixel_header_size; + char *pixel_text; + int pixel_text_size; +} ebitengine_PrecompiledShader; + +ebitengine_Error +ebitengine_NewShader(int *shader, + const ebitengine_PrecompiledShader *precompiled_shader); void ebitengine_DisposeShader(int id); #ifdef __cplusplus