From ecda6c57d6efa374c2fb85e2b432814e09e8a89e Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 21 May 2025 16:25:46 +0200 Subject: [PATCH] Initialize GPU 3D rendere (#132) * Initialize GPU 3D rendere * Embed compiled shaders in miniwin * miniwin: Refactor D3DRM --------- Co-authored-by: Anonymous Maarten --- CMakeLists.txt | 94 ++++- miniwin/miniwin/include/bitflags.h | 2 + miniwin/miniwin/include/miniwin_d3drm.h | 32 +- miniwin/miniwin/include/miniwin_ddraw.h | 1 + miniwin/miniwin/shaders/gencshadersource.py | 224 +++++++++++ .../shaders/generated/PositionColor.vert.h | 292 +++++++++++++++ .../miniwin/shaders/generated/ShaderIndex.cpp | 146 ++++++++ .../miniwin/shaders/generated/ShaderIndex.h | 22 ++ .../shaders/generated/SolidColor.frag.h | 247 +++++++++++++ .../shaders/src/PositionColor.vert.hlsl | 19 + .../shaders/src/PositionColor.vert.hlsl.json | 6 + .../miniwin/shaders/src/SolidColor.frag.hlsl | 4 + .../shaders/src/SolidColor.frag.hlsl.json | 6 + miniwin/miniwin/src/include/miniwin_d3drm_p.h | 76 ++++ .../src/include/miniwin_d3drmdevice_p.h | 38 ++ .../src/include/miniwin_d3drmobject_p.h | 70 ++++ .../src/include/miniwin_d3drmviewport_p.h | 56 +++ miniwin/miniwin/src/miniwin_d3drm.cpp | 349 +++++++----------- miniwin/miniwin/src/miniwin_d3drmdevice.cpp | 117 ++++++ miniwin/miniwin/src/miniwin_d3drmviewport.cpp | 267 ++++++++++++++ miniwin/miniwin/src/miniwin_ddraw.cpp | 7 +- miniwin/miniwin/src/miniwin_ddsurface.cpp | 13 +- 22 files changed, 1857 insertions(+), 231 deletions(-) create mode 100644 miniwin/miniwin/shaders/gencshadersource.py create mode 100644 miniwin/miniwin/shaders/generated/PositionColor.vert.h create mode 100644 miniwin/miniwin/shaders/generated/ShaderIndex.cpp create mode 100644 miniwin/miniwin/shaders/generated/ShaderIndex.h create mode 100644 miniwin/miniwin/shaders/generated/SolidColor.frag.h create mode 100644 miniwin/miniwin/shaders/src/PositionColor.vert.hlsl create mode 100644 miniwin/miniwin/shaders/src/PositionColor.vert.hlsl.json create mode 100644 miniwin/miniwin/shaders/src/SolidColor.frag.hlsl create mode 100644 miniwin/miniwin/shaders/src/SolidColor.frag.hlsl.json create mode 100644 miniwin/miniwin/src/include/miniwin_d3drm_p.h create mode 100644 miniwin/miniwin/src/include/miniwin_d3drmdevice_p.h create mode 100644 miniwin/miniwin/src/include/miniwin_d3drmobject_p.h create mode 100644 miniwin/miniwin/src/include/miniwin_d3drmviewport_p.h create mode 100644 miniwin/miniwin/src/miniwin_d3drmdevice.cpp create mode 100644 miniwin/miniwin/src/miniwin_d3drmviewport.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index e29cc4db..37e94055 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,9 @@ else() set(NOT_MINGW OFF) endif() +find_program(SDL_SHADERCROSS_BIN NAMES "shadercross") +find_package(Python3 COMPONENTS Interpreter) + option(ISLE_BUILD_APP "Build isle application" ON) option(ISLE_ASAN "Enable Address Sanitizer" OFF) option(ISLE_UBSAN "Enable Undefined Behavior Sanitizer" OFF) @@ -26,6 +29,7 @@ option(ISLE_DEBUG "Enable imgui debug" ON) cmake_dependent_option(ISLE_USE_DX5 "Build with internal DirectX 5 SDK" "${NOT_MINGW}" "WIN32;CMAKE_SIZEOF_VOID_P EQUAL 4" OFF) cmake_dependent_option(ISLE_MINIWIN "Use miniwin and minimfc" ON "NOT ISLE_USE_DX5" OFF) cmake_dependent_option(ISLE_BUILD_CONFIG "Build CONFIG.EXE application" ON "MSVC OR ISLE_MINIWIN" OFF) +cmake_dependent_option(ISLE_COMPILE_SHADERS "Compile shaders" ON "SDL_SHADERCROSS_BIN;TARGET Python3::Interpreter" OFF) option(CMAKE_POSITION_INDEPENDENT_CODE "Build with -fPIC" ON) option(ENABLE_CLANG_TIDY "Enable clang-tidy") option(DOWNLOAD_DEPENDENCIES "Download dependencies" ON) @@ -36,6 +40,7 @@ message(STATUS "Config app: ${ISLE_BUILD_CONFIG}") message(STATUS "Internal DirectX5 SDK: ${ISLE_USE_DX5}") message(STATUS "Internal miniwin: ${ISLE_MINIWIN}") message(STATUS "Isle debugging: ${ISLE_DEBUG}") +message(STATUS "Compile shaders: ${ISLE_COMPILE_SHADERS}") if (DOWNLOAD_DEPENDENCIES) # FetchContent downloads and configures dependencies @@ -92,14 +97,101 @@ add_library(miniwin STATIC EXCLUDE_FROM_ALL miniwin/miniwin/src/miniwin_ddsurface.cpp miniwin/miniwin/src/miniwin_ddraw.cpp miniwin/miniwin/src/miniwin_d3drm.cpp + miniwin/miniwin/src/miniwin_d3drmdevice.cpp + miniwin/miniwin/src/miniwin_d3drmviewport.cpp ) # Force reported render mods from MiniWin -target_compile_definitions(miniwin PRIVATE MINIWIN_PIXELFORMAT=SDL_PIXELFORMAT_INDEX8) +target_compile_definitions(miniwin PRIVATE MINIWIN_PIXELFORMAT=SDL_PIXELFORMAT_RGB565) target_include_directories(miniwin PUBLIC "$") target_include_directories(miniwin PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/miniwin/miniwin/src/include") +target_include_directories(miniwin PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/miniwin/miniwin/shaders/generated") target_compile_definitions(miniwin PUBLIC "MINIWIN") target_link_libraries(miniwin PRIVATE SDL3::SDL3) +set(shader_src_dir "${CMAKE_CURRENT_SOURCE_DIR}/miniwin/miniwin/shaders/src") +set(shader_gen_dir "${CMAKE_CURRENT_SOURCE_DIR}/miniwin/miniwin/shaders/generated") +set(py_gencshadersource "${CMAKE_CURRENT_SOURCE_DIR}/miniwin/miniwin/shaders/gencshadersource.py") +set(miniwin_shaders + "${shader_src_dir}/PositionColor.vert.hlsl" + "${shader_src_dir}/SolidColor.frag.hlsl" +) +target_sources(miniwin PRIVATE ${py_gencshadersource}) +set(shader_variables ) +set(shader_headers ) +set(shader_stages ) +foreach(shader_src IN LISTS miniwin_shaders) + get_filename_component(filename_wle "${shader_src}" NAME_WLE) + get_filename_component(shader_name "${filename_wle}" NAME_WLE) + get_filename_component(src_format_ext "${shader_src}" LAST_EXT) + get_filename_component(src_stage_ext "${filename_wle}" LAST_EXT) + string(MAKE_C_IDENTIFIER "${filename_wle}" shader_variable) + set(shader_json "${shader_src}.json") + if(src_format_ext STREQUAL ".hlsl") + set(src_format "HLSL") + else() + message(FATAL_ERROR "Unknown source format (${src_format_ext})") + endif() + if(src_stage_ext STREQUAL ".vert") + set(shader_stage "vertex") + elseif(src_stage_ext STREQUAL ".frag") + set(shader_stage "fragment") + elseif(src_stage_ext STREQUAL ".comp") + set(shader_stage "compute") + message(FATAL_ERROR "Compute shaders are not (yet) supported") + else() + message(FATAL_ERROR "Unknown stage (${src_stage_ext})") + endif() + set(compiled_bindir "${CMAKE_CURRENT_BINARY_DIR}/shaders/compiled") + set(compiled_srcdir "${CMAKE_CURRENT_SOURCE_DIR}/miniwin/miniwin/shaders/compiled") + set(dxil "${compiled_bindir}/dxil/${filename_wle}.dxil") + set(msl "${compiled_bindir}/msl/${filename_wle}.msl") + set(spirv "${compiled_bindir}/spirv/${filename_wle}.spv") + set(shader_filename "${filename_wle}.h") + set(shader_header "${shader_gen_dir}/${shader_filename}") + if(ISLE_COMPILE_SHADERS) + add_custom_command(OUTPUT "${dxil}" + COMMAND "${SDL_SHADERCROSS_BIN}" "${shader_src}" -o "${dxil}" + -s "${src_format}" -d "DXIL" -t "${shader_stage}" + DEPENDS "${shader_src}") + add_custom_command(OUTPUT "${msl}" + COMMAND "${SDL_SHADERCROSS_BIN}" "${shader_src}" -o "${msl}" + -s "${src_format}" -d "MSL" -t "${shader_stage}" + DEPENDS "${shader_src}") + add_custom_command(OUTPUT "${spirv}" + COMMAND "${SDL_SHADERCROSS_BIN}" "${shader_src}" -o "${spirv}" + -s "${src_format}" -d "SPIRV" -t "${shader_stage}" + DEPENDS "${shader_src}") + add_custom_command(OUTPUT "${shader_header}" + COMMAND Python3::Interpreter "${py_gencshadersource}" "header" "--output" "${shader_header}" + "--stage" "${shader_stage}" "--variable" "${shader_variable}" + "--dxil" "${dxil}" "--msl" "${msl}" "--spirv" "${spirv}" + DEPENDS "${py_gencshadersource}" "${dxil}" "${msl}" "${spirv}") + endif() + target_sources(miniwin PRIVATE "${shader_src}" "${shader_header}") + list(APPEND shader_names "${shader_name}") + list(APPEND shader_variables "${shader_variable}") + list(APPEND shader_headers "${shader_header}") + list(APPEND shader_stages "${shader_stage}") + list(APPEND shader_jsons "${shader_json}") +endforeach() + +set(index_cpp "${shader_gen_dir}/ShaderIndex.cpp") +set(index_h "${shader_gen_dir}/ShaderIndex.h") + +if(ISLE_COMPILE_SHADERS) + add_custom_command(OUTPUT "${index_h}" "${index_cpp}" + COMMAND Python3::Interpreter "${py_gencshadersource}" "index" + "--output" "${index_cpp}" + "--header" "${index_h}" + "--shader-names" ${shader_names} + "--shader-variables" ${shader_variables} + "--shader-headers" ${shader_headers} + "--shader-stages" ${shader_stages} + "--shader-jsons" ${shader_jsons} + DEPENDS "${py_gencshadersource}" ${shader_headers} ${shader_jsons}) +endif() +target_sources(miniwin PRIVATE "${index}" "${index_cpp}") + add_library(minimfc STATIC EXCLUDE_FROM_ALL miniwin/minimfc/src/minimfc.cpp ) diff --git a/miniwin/miniwin/include/bitflags.h b/miniwin/miniwin/include/bitflags.h index 4b497a1d..386f6a19 100644 --- a/miniwin/miniwin/include/bitflags.h +++ b/miniwin/miniwin/include/bitflags.h @@ -1,3 +1,5 @@ +#pragma once + #include // Enable bitwise ops only for enum classes with the ENABLE_BITMASK_OPERATORS trait diff --git a/miniwin/miniwin/include/miniwin_d3drm.h b/miniwin/miniwin/include/miniwin_d3drm.h index dfd8b66f..648edbfe 100644 --- a/miniwin/miniwin/include/miniwin_d3drm.h +++ b/miniwin/miniwin/include/miniwin_d3drm.h @@ -13,7 +13,7 @@ // --- Typedefs --- typedef float D3DVAL; typedef void* LPD3DRM_APPDATA; -typedef unsigned int D3DRMGROUPINDEX; +typedef DWORD D3DRMGROUPINDEX; typedef DWORD D3DCOLOR, *LPD3DCOLOR; typedef float D3DVALUE, *LPD3DVALUE; @@ -116,16 +116,16 @@ typedef struct D3DRMPALETTEENTRY { } D3DRMPALETTEENTRY; typedef struct D3DRMIMAGE { - unsigned int width, height, depth, bytes_per_line; - unsigned int red_mask, green_mask, blue_mask, alpha_mask; - unsigned int palette_size; + DWORD width, height, depth, bytes_per_line; + DWORD red_mask, green_mask, blue_mask, alpha_mask; + DWORD palette_size; D3DRMPALETTEENTRY* palette; void* buffer1; void* buffer2; void* data; int rgb; int aspectx, aspecty; - unsigned int format; + DWORD format; } D3DRMIMAGE; typedef struct D3DRMMATRIX4D { @@ -179,11 +179,11 @@ struct IDirect3DRMMesh : public IDirect3DRMVisual { ) = 0; virtual HRESULT GetGroup( int groupIndex, - unsigned int* vertexCount, - unsigned int* faceCount, - unsigned int* vertexPerFace, + DWORD* vertexCount, + DWORD* faceCount, + DWORD* vertexPerFace, DWORD* dataSize, - unsigned int* data + DWORD* data ) = 0; virtual HRESULT SetGroupColor(int groupIndex, D3DCOLOR color) = 0; virtual HRESULT SetGroupColorRGB(int groupIndex, float r, float g, float b) = 0; @@ -284,8 +284,8 @@ struct IDirect3DRMViewport : public IDirect3DRMObject { virtual D3DVALUE GetBack() = 0; virtual HRESULT SetField(D3DVALUE field) = 0; virtual D3DVALUE GetField() = 0; - virtual int GetWidth() = 0; - virtual int GetHeight() = 0; + virtual DWORD GetWidth() = 0; + virtual DWORD GetHeight() = 0; virtual HRESULT Transform(D3DRMVECTOR4D* screen, D3DVECTOR* world) = 0; virtual HRESULT InverseTransform(D3DVECTOR* world, D3DRMVECTOR4D* screen) = 0; virtual HRESULT Pick(float x, float y, LPDIRECT3DRMPICKEDARRAY* pickedArray) = 0; @@ -305,11 +305,11 @@ struct IDirect3DRMWinDevice : virtual public IDirect3DRMObject { }; struct IDirect3DRMDevice : virtual public IDirect3DRMObject { - virtual unsigned int GetWidth() = 0; - virtual unsigned int GetHeight() = 0; + virtual DWORD GetWidth() = 0; + virtual DWORD GetHeight() = 0; virtual HRESULT SetBufferCount(int count) = 0; virtual HRESULT GetBufferCount() = 0; - virtual HRESULT SetShades(unsigned int shadeCount) = 0; + virtual HRESULT SetShades(DWORD shadeCount) = 0; virtual HRESULT GetShades() = 0; virtual HRESULT SetQuality(D3DRMRENDERQUALITY quality) = 0; virtual D3DRMRENDERQUALITY GetQuality() = 0; @@ -353,8 +353,8 @@ struct IDirect3DRM : virtual public IUnknown { int height, IDirect3DRMViewport** outViewport ) = 0; - virtual HRESULT SetDefaultTextureShades(unsigned int count) = 0; - virtual HRESULT SetDefaultTextureColors(unsigned int count) = 0; + virtual HRESULT SetDefaultTextureShades(DWORD count) = 0; + virtual HRESULT SetDefaultTextureColors(DWORD count) = 0; }; typedef IDirect3DRM *LPDIRECT3DRM, **LPLPDIRECT3DRM; diff --git a/miniwin/miniwin/include/miniwin_ddraw.h b/miniwin/miniwin/include/miniwin_ddraw.h index bc57b33f..a6dd97cc 100644 --- a/miniwin/miniwin/include/miniwin_ddraw.h +++ b/miniwin/miniwin/include/miniwin_ddraw.h @@ -104,6 +104,7 @@ DEFINE_GUID(IID_IDirectDraw2, 0xB3A6F3E0, 0x2B43, 0x11CF, 0xA2, 0xDE, 0x00, 0xAA DEFINE_GUID(IID_IDirectDrawSurface3, 0xDA044E00, 0x69B2, 0x11D0, 0xA1, 0xD5, 0x00, 0xAA, 0x00, 0xB8, 0xDF, 0xBB); extern SDL_Window* DDWindow; +extern SDL_Surface* DDBackBuffer; // --- Enums --- #define DDCKEY_SRCBLT DDColorKeyFlags::SRCBLT diff --git a/miniwin/miniwin/shaders/gencshadersource.py b/miniwin/miniwin/shaders/gencshadersource.py new file mode 100644 index 00000000..99484316 --- /dev/null +++ b/miniwin/miniwin/shaders/gencshadersource.py @@ -0,0 +1,224 @@ +#!/usr/bin/env python3 + +import argparse +import dataclasses +import enum +import itertools +import json +from pathlib import Path + + +@dataclasses.dataclass +class ShaderJsonMetadata: + num_samplers: int + num_storage_textures: int + num_storage_buffers: int + num_uniform_buffers: int + +@dataclasses.dataclass +class ShaderMetadata: + name: str + variable: str + json: ShaderJsonMetadata + +class ShaderFormat(enum.StrEnum): + SPIRV = "SDL_GPU_SHADERFORMAT_SPIRV" + DXIL = "SDL_GPU_SHADERFORMAT_DXIL" + MSL = "SDL_GPU_SHADERFORMAT_MSL" + +class ShaderStage(enum.StrEnum): + VERTEX = "SDL_GPU_SHADERSTAGE_VERTEX" + FRAGMENT = "SDL_GPU_SHADERSTAGE_FRAGMENT" + +STR_TO_SHADERSTAGE = { + "vertex": ShaderStage.VERTEX, + "fragment": ShaderStage.FRAGMENT, +} + + +def write_generated_warning(f: "io") -> None: + f.write("// +==============================================+\n") + f.write("// | This file is auto-generated, do not edit it. |\n") + f.write("// +==============================================+\n") + f.write("\n") + +def write_uint8_array(f: "io", variable: str, data: bytes) -> None: + f.write(f"static const Uint8 {variable}[{len(data)}] = {{\n") + for rowdata in itertools.batched(data, 16): + f.write(" "), + f.write(", ".join(f"0x{d:02x}" for d in rowdata)) + f.write(",\n") + f.write(f"}};\n") + +def write_gpushadercreateinfo(f: "io", shader_metadata: ShaderMetadata, entrypoint: str, suffix: str, format: ShaderFormat, stage: ShaderStage): + f.write(f" {{\n") + f.write(f" /* code_size */ sizeof({shader_metadata.variable}{suffix}),\n") + f.write(f" /* code */ {shader_metadata.variable}{suffix},\n") + f.write(f" /* entrypoint */ \"{entrypoint}\",\n") + f.write(f" /* format */ {format},\n") + f.write(f" /* stage */ {stage},\n") + f.write(f" /* num_samplers */ {shader_metadata.json.num_samplers},\n") + f.write(f" /* num_storage_textures */ {shader_metadata.json.num_storage_textures},\n") + f.write(f" /* num_storage_buffers */ {shader_metadata.json.num_storage_buffers},\n") + f.write(f" /* num_uniform_buffers */ {shader_metadata.json.num_uniform_buffers},\n") + f.write(f" }},\n") + +def write_shader_switch(f: "io", suffix: str, capitalized_stage: str, shader_var_names: list[tuple[str, str]]) -> None: + f.write(f" switch (id) {{\n") + for name, var_name in shader_var_names: + f.write(f" case {capitalized_stage}ShaderId::{name}:\n") + f.write(f" *size = SDL_arraysize({var_name}{suffix});\n") + f.write(f" return {var_name}{suffix};\n") + f.write(f" default:\n") + f.write(f" SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, \"Invalid {capitalized_stage} shader id: %d\", id);\n") + f.write(f" break;\n") + f.write(f" }}\n") + +def main() -> None: + parser = argparse.ArgumentParser(allow_abbrev=False) + parser.set_defaults(subparser=None) + subparsers = parser.add_subparsers() + + header_parser = subparsers.add_parser("header") + header_parser.add_argument("--stage", choices=("vertex", "fragment"), required=True) + header_parser.add_argument("--variable", required=True) + header_parser.add_argument("--dxil", type=Path, required=True) + header_parser.add_argument("--msl", type=Path, required=True) + header_parser.add_argument("--spirv", type=Path, required=True) + header_parser.add_argument("--output", "-o", type=Path, required=True) + header_parser.set_defaults(subparser="header") + + index_parser = subparsers.add_parser("index") + index_parser.add_argument("--output", type=Path, required=True) + index_parser.add_argument("--header", type=Path, required=True) + index_parser.add_argument("--shader-headers", nargs="+", type=Path, required=True) + index_parser.add_argument("--shader-names", nargs="+", type=str, required=True) + index_parser.add_argument("--shader-variables", nargs="+", type=str, required=True) + index_parser.add_argument("--shader-stages", nargs="+", type=str, choices=("vertex", "fragment"), required=True) + index_parser.add_argument("--shader-jsons", nargs="+", type=Path, required=True) + index_parser.set_defaults(subparser="index") + + args = parser.parse_args() + if args.subparser == "header": + variable = args.variable + if not variable.isidentifier(): + parser.error(f"--variable must get an identifier ({variable})") + + with args.output.open("w", newline="\n") as f: + f.write("#pragma once\n") + f.write("\n") + f.write("// clang-format off\n") + f.write("\n") + write_generated_warning(f) + f.write("#include \n") + f.write("\n") + f.write("// DXIL only makes sense on Windows platforms\n") + f.write("#if defined(SDL_PLATFORM_WINDOWS)\n") + write_uint8_array(f=f, data=args.dxil.read_bytes(), variable=variable + "_dxil") + f.write("#endif\n") + f.write("\n") + f.write("// MSL only makes sense on Apple platforms\n") + f.write("#if defined(SDL_PLATFORM_APPLE)\n") + write_uint8_array(f=f, data=args.msl.read_bytes(), variable=variable + "_msl") + f.write("#endif\n") + f.write("\n") + write_uint8_array(f=f, data=args.spirv.read_bytes(), variable=variable + "_spirv") + elif args.subparser == "index": + if len({len(args.shader_headers), len(args.shader_names), len(args.shader_variables), len(args.shader_stages), len(args.shader_jsons)}) != 1: + parser.error("--shader-headers, --shader-names, --shader-variables and --shader-stages must get same number of arguments") + + stage_metadatas: dict[str,ShaderMetadata] = { + "vertex": [], + "fragment": [], + } + for str_stage, name, variable, json_path in zip(args.shader_stages, args.shader_names, args.shader_variables, args.shader_jsons): + try: + json_metadata = ShaderJsonMetadata(**json.loads(json_path.read_text())) + except IOError: + parser.error(f"Failed to open/read {json_path}") + stage_metadatas.get(str_stage).append(ShaderMetadata(name=name, variable=variable, json=json_metadata)) + with args.header.open("w", newline="\n") as f: + f.write("#pragma once\n") + f.write("\n") + f.write("// clang-format off\n") + f.write("\n") + write_generated_warning(f) + f.write("#include \n") + f.write("\n") + for str_stage, shader_metadatas in stage_metadatas.items(): + if not shader_metadatas: + continue + capitalized_stage = str_stage.capitalize() + f.write(f"enum {capitalized_stage}ShaderId {{\n") + for shader_metadata in shader_metadatas: + f.write(f" {shader_metadata.name},\n") + f.write("};\n\n") + for str_stage, shader_metadatas in stage_metadatas.items(): + if not shader_metadatas: + continue + capitalized_stage = str_stage.capitalize() + f.write(f"const SDL_GPUShaderCreateInfo* Get{capitalized_stage}ShaderCode({capitalized_stage}ShaderId id, SDL_GPUShaderFormat formats);\n\n") + with args.output.open("w", newline="\n") as f: + f.write("// clang-format off\n") + f.write("\n") + write_generated_warning(f) + f.write(f"#include \"{args.header.name}\"\n\n") + for shader_header in args.shader_headers: + f.write(f"#include \"{shader_header.name}\"\n") + + for str_stage, shader_metadatas in stage_metadatas.items(): + if not shader_metadatas: + continue + capitalized_stage = str_stage.capitalize() + stage = STR_TO_SHADERSTAGE[str_stage] + f.write("\n") + f.write("#if defined(SDL_PLATFORM_WINDOWS)\n") + f.write(f"static const SDL_GPUShaderCreateInfo {capitalized_stage}ShaderDXILCodes[] = {{\n") + f.write(f" // {capitalized_stage}ShaderId::{shader_metadata.name}\n") + for shader_metadata in shader_metadatas: + write_gpushadercreateinfo(f, shader_metadata, entrypoint="main", suffix="_dxil", format=ShaderFormat.DXIL, stage=stage) + f.write(f"}};\n") + f.write("#endif\n") + f.write("\n") + f.write("#if defined(SDL_PLATFORM_APPLE)\n") + f.write(f"static const SDL_GPUShaderCreateInfo {capitalized_stage}ShaderMSLCodes[] = {{\n") + for shader_metadata in shader_metadatas: + write_gpushadercreateinfo(f, shader_metadata, entrypoint="main0", suffix="_msl", format=ShaderFormat.MSL, stage=stage) + f.write(f"}};\n") + f.write("#endif\n") + f.write("\n") + f.write(f"static const SDL_GPUShaderCreateInfo {capitalized_stage}ShaderSPIRVCodes[] = {{\n") + for shader_metadata in shader_metadatas: + write_gpushadercreateinfo(f, shader_metadata, entrypoint="main", suffix="_spirv", format=ShaderFormat.SPIRV, stage=stage) + f.write(f"}};\n") + for stage, shader_metadatas in stage_metadatas.items(): + if not shader_metadatas: + continue + capitalized_stage = stage.capitalize() + f.write("\n") + f.write(f"const SDL_GPUShaderCreateInfo* Get{capitalized_stage}ShaderCode({capitalized_stage}ShaderId id, SDL_GPUShaderFormat formats) {{\n") + f.write(f"#if defined(SDL_PLATFORM_WINDOWS)\n") + f.write(f" if (formats & SDL_GPU_SHADERFORMAT_DXIL) {{\n") + f.write(f" SDL_assert(id < SDL_arraysize({capitalized_stage}ShaderDXILCodes));\n") + f.write(f" return &{capitalized_stage}ShaderDXILCodes[id];\n") + f.write(f" }}\n") + f.write(f"#endif\n") + f.write(f"#if defined(SDL_PLATFORM_APPLE)\n") + f.write(f" if (formats & SDL_GPU_SHADERFORMAT_MSL) {{\n") + f.write(f" SDL_assert(id < SDL_arraysize({capitalized_stage}ShaderMSLCodes));\n") + f.write(f" return &{capitalized_stage}ShaderMSLCodes[id];\n") + f.write(f" }}\n") + f.write(f"#endif\n") + f.write(f" if (formats & SDL_GPU_SHADERFORMAT_SPIRV) {{\n") + f.write(f" SDL_assert(id < SDL_arraysize({capitalized_stage}ShaderSPIRVCodes));\n") + f.write(f" return &{capitalized_stage}ShaderSPIRVCodes[id];\n") + f.write(f" }}\n") + f.write(f" SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, \"Could not find {stage} shader code for id=%d and formats=0x%x\", id, formats);\n") + f.write(f" return nullptr;\n") + f.write(f"}}\n") + else: + parser.error("Invalid arguments") + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/miniwin/miniwin/shaders/generated/PositionColor.vert.h b/miniwin/miniwin/shaders/generated/PositionColor.vert.h new file mode 100644 index 00000000..c80a1874 --- /dev/null +++ b/miniwin/miniwin/shaders/generated/PositionColor.vert.h @@ -0,0 +1,292 @@ +#pragma once + +// clang-format off + +// +==============================================+ +// | This file is auto-generated, do not edit it. | +// +==============================================+ + +#include + +// DXIL only makes sense on Windows platforms +#if defined(SDL_PLATFORM_WINDOWS) +static const Uint8 PositionColor_vert_dxil[3156] = { + 0x44, 0x58, 0x42, 0x43, 0x53, 0xa3, 0xb7, 0xd9, 0xcb, 0x0b, 0xfc, 0x32, 0x70, 0xb9, 0xa0, 0x7f, + 0x50, 0xe8, 0x3c, 0x29, 0x01, 0x00, 0x00, 0x00, 0x54, 0x0c, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3c, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, + 0xec, 0x01, 0x00, 0x00, 0xd0, 0x06, 0x00, 0x00, 0xec, 0x06, 0x00, 0x00, 0x53, 0x46, 0x49, 0x30, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x53, 0x47, 0x31, + 0x54, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x45, 0x58, 0x43, + 0x4f, 0x4f, 0x52, 0x44, 0x00, 0x00, 0x00, 0x00, 0x4f, 0x53, 0x47, 0x31, 0x60, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, + 0x00, 0x53, 0x56, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x00, + 0x50, 0x53, 0x56, 0x30, 0xd4, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, + 0x44, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, + 0x4f, 0x52, 0x44, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x43, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x44, 0x00, 0x03, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x44, 0x00, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x44, 0x03, 0x03, 0x04, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x53, 0x54, 0x41, 0x54, + 0xdc, 0x04, 0x00, 0x00, 0x60, 0x00, 0x01, 0x00, 0x37, 0x01, 0x00, 0x00, 0x44, 0x58, 0x49, 0x4c, + 0x00, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0xc4, 0x04, 0x00, 0x00, 0x42, 0x43, 0xc0, 0xde, + 0x21, 0x0c, 0x00, 0x00, 0x2e, 0x01, 0x00, 0x00, 0x0b, 0x82, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x07, 0x81, 0x23, 0x91, 0x41, 0xc8, 0x04, 0x49, 0x06, 0x10, 0x32, 0x39, + 0x92, 0x01, 0x84, 0x0c, 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, 0x80, 0x10, 0x45, 0x02, + 0x42, 0x92, 0x0b, 0x42, 0x84, 0x10, 0x32, 0x14, 0x38, 0x08, 0x18, 0x4b, 0x0a, 0x32, 0x42, 0x88, + 0x48, 0x90, 0x14, 0x20, 0x43, 0x46, 0x88, 0xa5, 0x00, 0x19, 0x32, 0x42, 0xe4, 0x48, 0x0e, 0x90, + 0x11, 0x22, 0xc4, 0x50, 0x41, 0x51, 0x81, 0x8c, 0xe1, 0x83, 0xe5, 0x8a, 0x04, 0x21, 0x46, 0x06, + 0x51, 0x18, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1b, 0x8c, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x07, + 0x40, 0x02, 0xa8, 0x0d, 0x84, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x03, 0x20, 0x01, 0x00, 0x00, 0x00, + 0x49, 0x18, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, 0x82, 0x60, 0x42, 0x20, 0x00, 0x00, 0x00, + 0x89, 0x20, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x32, 0x22, 0x08, 0x09, 0x20, 0x64, 0x85, 0x04, + 0x13, 0x22, 0xa4, 0x84, 0x04, 0x13, 0x22, 0xe3, 0x84, 0xa1, 0x90, 0x14, 0x12, 0x4c, 0x88, 0x8c, + 0x0b, 0x84, 0x84, 0x4c, 0x10, 0x30, 0x23, 0x00, 0x25, 0x00, 0x8a, 0x19, 0x80, 0x39, 0x02, 0x30, + 0x98, 0x23, 0x40, 0x8a, 0x31, 0x44, 0x54, 0x44, 0x56, 0x0c, 0x20, 0xa2, 0x1a, 0xc2, 0x81, 0x80, + 0x54, 0x20, 0x00, 0x00, 0x13, 0x14, 0x72, 0xc0, 0x87, 0x74, 0x60, 0x87, 0x36, 0x68, 0x87, 0x79, + 0x68, 0x03, 0x72, 0xc0, 0x87, 0x0d, 0xaf, 0x50, 0x0e, 0x6d, 0xd0, 0x0e, 0x7a, 0x50, 0x0e, 0x6d, + 0x00, 0x0f, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x71, 0xa0, + 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x78, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, + 0x71, 0x60, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xe9, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, + 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x10, + 0x07, 0x76, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0e, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, + 0x72, 0xd0, 0x06, 0xe6, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0xe0, 0x0e, 0x78, + 0xa0, 0x07, 0x71, 0x60, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x43, 0x9e, + 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x3c, 0x06, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x79, 0x10, 0x20, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x02, 0x01, 0x0d, 0x00, 0x00, 0x00, 0x32, 0x1e, 0x98, 0x14, + 0x19, 0x11, 0x4c, 0x90, 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0xa2, 0x12, 0x18, 0x01, 0x28, + 0x86, 0x32, 0x28, 0x87, 0xf2, 0x28, 0x90, 0x82, 0xa0, 0x2a, 0x89, 0x11, 0x80, 0x32, 0x28, 0x84, + 0x22, 0xa0, 0x1d, 0x4b, 0x41, 0x10, 0x08, 0x0c, 0x40, 0x01, 0x08, 0x04, 0x02, 0x01, 0x00, 0x00, + 0x79, 0x18, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x1a, 0x03, 0x4c, 0x90, 0x46, 0x02, 0x13, 0xc4, + 0x31, 0x20, 0xc3, 0x1b, 0x43, 0x81, 0x93, 0x4b, 0xb3, 0x0b, 0xa3, 0x2b, 0x4b, 0x01, 0x89, 0x71, + 0xc1, 0x71, 0x81, 0x71, 0xa1, 0xb9, 0xc1, 0xc9, 0x01, 0x41, 0x11, 0xa3, 0xb9, 0x89, 0x89, 0xc1, + 0x99, 0xc9, 0x29, 0x4b, 0xd9, 0x10, 0x04, 0x13, 0x04, 0x62, 0x98, 0x20, 0x10, 0xc4, 0x06, 0x61, + 0x20, 0x36, 0x08, 0x04, 0x41, 0xc1, 0x6e, 0x6e, 0x82, 0x40, 0x14, 0x1b, 0x86, 0x03, 0x21, 0x26, + 0x08, 0x02, 0xb0, 0x01, 0xd8, 0x30, 0x10, 0xcb, 0xb2, 0x21, 0x60, 0x36, 0x0c, 0x83, 0xd2, 0x4c, + 0x10, 0x16, 0x68, 0x43, 0xf0, 0x90, 0x68, 0x0b, 0x4b, 0x73, 0x23, 0x42, 0x55, 0x84, 0x35, 0xf4, + 0xf4, 0x24, 0x45, 0x34, 0x41, 0x28, 0x96, 0x09, 0x42, 0xc1, 0x6c, 0x08, 0x88, 0x09, 0x42, 0xd1, + 0x4c, 0x10, 0x08, 0x63, 0x82, 0x40, 0x1c, 0x1b, 0x84, 0x0b, 0xdb, 0xb0, 0x10, 0xd2, 0x44, 0x55, + 0xd4, 0x60, 0x11, 0x54, 0xb6, 0x21, 0x18, 0x26, 0x08, 0x85, 0x33, 0x41, 0x20, 0x90, 0x0d, 0xc2, + 0xd5, 0x6d, 0x58, 0x06, 0x69, 0xa2, 0x36, 0x6a, 0xe0, 0x06, 0xca, 0xdb, 0x20, 0x68, 0xdf, 0x04, + 0xa1, 0x78, 0x36, 0x2c, 0x84, 0x34, 0x51, 0x55, 0x18, 0x0c, 0x1c, 0x41, 0x79, 0x5c, 0xa6, 0xac, + 0xbe, 0xa0, 0xde, 0xe6, 0xd2, 0xe8, 0xd2, 0xde, 0xdc, 0x36, 0x2c, 0xc3, 0x18, 0x4c, 0x56, 0xc5, + 0x0d, 0xdc, 0x40, 0x79, 0x1b, 0x04, 0x31, 0x20, 0x83, 0x0d, 0x03, 0x18, 0x94, 0x01, 0xb0, 0xa1, + 0x50, 0x22, 0x33, 0x00, 0x00, 0x16, 0x69, 0x6e, 0x73, 0x74, 0x73, 0x13, 0x04, 0x22, 0xa1, 0x31, + 0x97, 0x76, 0xf6, 0xc5, 0x46, 0x46, 0x63, 0x2e, 0xed, 0xec, 0x6b, 0x8e, 0x6e, 0x82, 0x40, 0x28, + 0x1b, 0x0c, 0x34, 0x48, 0x03, 0x35, 0xc0, 0xd6, 0x80, 0x0d, 0xaa, 0xb0, 0xb1, 0xd9, 0xb5, 0xb9, + 0xa4, 0x91, 0x95, 0xb9, 0xd1, 0x4d, 0x09, 0x82, 0x2a, 0x64, 0x78, 0x2e, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x53, 0x02, 0xa2, 0x09, 0x19, 0x9e, 0x8b, 0x5d, 0x18, 0x9b, 0x5d, 0x99, 0xdc, + 0x94, 0xa0, 0xa8, 0x43, 0x86, 0xe7, 0x32, 0x87, 0x16, 0x46, 0x56, 0x26, 0xd7, 0xf4, 0x46, 0x56, + 0xc6, 0x36, 0x25, 0x40, 0x2a, 0x91, 0xe1, 0xb9, 0xd0, 0xe5, 0xc1, 0x95, 0x05, 0xb9, 0xb9, 0xbd, + 0xd1, 0x85, 0xd1, 0xa5, 0xbd, 0xb9, 0xcd, 0x4d, 0x09, 0x9a, 0x3a, 0x64, 0x78, 0x2e, 0x76, 0x69, + 0x65, 0x77, 0x49, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x82, 0xa7, 0x0e, 0x19, 0x9e, 0x4b, + 0x99, 0x1b, 0x9d, 0x5c, 0x1e, 0xd4, 0x5b, 0x9a, 0x1b, 0xdd, 0xdc, 0x94, 0xc0, 0x0c, 0xba, 0x90, + 0xe1, 0xb9, 0x8c, 0xbd, 0xd5, 0xb9, 0xd1, 0x95, 0xc9, 0xcd, 0x4d, 0x09, 0xd8, 0x00, 0x00, 0x00, + 0x79, 0x18, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x33, 0x08, 0x80, 0x1c, 0xc4, 0xe1, 0x1c, 0x66, + 0x14, 0x01, 0x3d, 0x88, 0x43, 0x38, 0x84, 0xc3, 0x8c, 0x42, 0x80, 0x07, 0x79, 0x78, 0x07, 0x73, + 0x98, 0x71, 0x0c, 0xe6, 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x33, 0x0c, 0x42, 0x1e, + 0xc2, 0xc1, 0x1d, 0xce, 0xa1, 0x1c, 0x66, 0x30, 0x05, 0x3d, 0x88, 0x43, 0x38, 0x84, 0x83, 0x1b, + 0xcc, 0x03, 0x3d, 0xc8, 0x43, 0x3d, 0x8c, 0x03, 0x3d, 0xcc, 0x78, 0x8c, 0x74, 0x70, 0x07, 0x7b, + 0x08, 0x07, 0x79, 0x48, 0x87, 0x70, 0x70, 0x07, 0x7a, 0x70, 0x03, 0x76, 0x78, 0x87, 0x70, 0x20, + 0x87, 0x19, 0xcc, 0x11, 0x0e, 0xec, 0x90, 0x0e, 0xe1, 0x30, 0x0f, 0x6e, 0x30, 0x0f, 0xe3, 0xf0, + 0x0e, 0xf0, 0x50, 0x0e, 0x33, 0x10, 0xc4, 0x1d, 0xde, 0x21, 0x1c, 0xd8, 0x21, 0x1d, 0xc2, 0x61, + 0x1e, 0x66, 0x30, 0x89, 0x3b, 0xbc, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xb4, 0x03, 0x3c, 0xbc, 0x83, + 0x3c, 0x84, 0x03, 0x3b, 0xcc, 0xf0, 0x14, 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x68, 0x87, + 0x72, 0x68, 0x07, 0x37, 0x80, 0x87, 0x70, 0x90, 0x87, 0x70, 0x60, 0x07, 0x76, 0x28, 0x07, 0x76, + 0xf8, 0x05, 0x76, 0x78, 0x87, 0x77, 0x80, 0x87, 0x5f, 0x08, 0x87, 0x71, 0x18, 0x87, 0x72, 0x98, + 0x87, 0x79, 0x98, 0x81, 0x2c, 0xee, 0xf0, 0x0e, 0xee, 0xe0, 0x0e, 0xf5, 0xc0, 0x0e, 0xec, 0x30, + 0x03, 0x62, 0xc8, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xcc, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xdc, 0x61, + 0x1c, 0xca, 0x21, 0x1c, 0xc4, 0x81, 0x1d, 0xca, 0x61, 0x06, 0xd6, 0x90, 0x43, 0x39, 0xc8, 0x43, + 0x39, 0x98, 0x43, 0x39, 0xc8, 0x43, 0x39, 0xb8, 0xc3, 0x38, 0x94, 0x43, 0x38, 0x88, 0x03, 0x3b, + 0x94, 0xc3, 0x2f, 0xbc, 0x83, 0x3c, 0xfc, 0x82, 0x3b, 0xd4, 0x03, 0x3b, 0xb0, 0xc3, 0x8c, 0xc8, + 0x21, 0x07, 0x7c, 0x70, 0x03, 0x72, 0x10, 0x87, 0x73, 0x70, 0x03, 0x7b, 0x08, 0x07, 0x79, 0x60, + 0x87, 0x70, 0xc8, 0x87, 0x77, 0xa8, 0x07, 0x7a, 0x98, 0x81, 0x3c, 0xe4, 0x80, 0x0f, 0x6e, 0x40, + 0x0f, 0xe5, 0xd0, 0x0e, 0xf0, 0x00, 0x00, 0x00, 0x71, 0x20, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x16, 0x30, 0x0d, 0x97, 0xef, 0x3c, 0xfe, 0xe2, 0x00, 0x83, 0xd8, 0x3c, 0xd4, 0xe4, 0x17, 0xb7, + 0x6d, 0x02, 0xd5, 0x70, 0xf9, 0xce, 0xe3, 0x4b, 0x93, 0x13, 0x11, 0x28, 0x35, 0x3d, 0xd4, 0xe4, + 0x17, 0xb7, 0x6d, 0x00, 0x04, 0x03, 0x20, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x48, 0x41, 0x53, 0x48, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5d, 0xbb, 0xba, 0xfe, + 0xcb, 0x0a, 0xd2, 0x7c, 0xaf, 0xc9, 0x76, 0x91, 0x2f, 0xa9, 0x19, 0x24, 0x44, 0x58, 0x49, 0x4c, + 0x60, 0x05, 0x00, 0x00, 0x60, 0x00, 0x01, 0x00, 0x58, 0x01, 0x00, 0x00, 0x44, 0x58, 0x49, 0x4c, + 0x00, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x05, 0x00, 0x00, 0x42, 0x43, 0xc0, 0xde, + 0x21, 0x0c, 0x00, 0x00, 0x4f, 0x01, 0x00, 0x00, 0x0b, 0x82, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x07, 0x81, 0x23, 0x91, 0x41, 0xc8, 0x04, 0x49, 0x06, 0x10, 0x32, 0x39, + 0x92, 0x01, 0x84, 0x0c, 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, 0x80, 0x10, 0x45, 0x02, + 0x42, 0x92, 0x0b, 0x42, 0x84, 0x10, 0x32, 0x14, 0x38, 0x08, 0x18, 0x4b, 0x0a, 0x32, 0x42, 0x88, + 0x48, 0x90, 0x14, 0x20, 0x43, 0x46, 0x88, 0xa5, 0x00, 0x19, 0x32, 0x42, 0xe4, 0x48, 0x0e, 0x90, + 0x11, 0x22, 0xc4, 0x50, 0x41, 0x51, 0x81, 0x8c, 0xe1, 0x83, 0xe5, 0x8a, 0x04, 0x21, 0x46, 0x06, + 0x51, 0x18, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1b, 0x8c, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x07, + 0x40, 0x02, 0xa8, 0x0d, 0x84, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x03, 0x20, 0x01, 0x00, 0x00, 0x00, + 0x49, 0x18, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, 0x82, 0x60, 0x42, 0x20, 0x00, 0x00, 0x00, + 0x89, 0x20, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x32, 0x22, 0x08, 0x09, 0x20, 0x64, 0x85, 0x04, + 0x13, 0x22, 0xa4, 0x84, 0x04, 0x13, 0x22, 0xe3, 0x84, 0xa1, 0x90, 0x14, 0x12, 0x4c, 0x88, 0x8c, + 0x0b, 0x84, 0x84, 0x4c, 0x10, 0x30, 0x23, 0x00, 0x25, 0x00, 0x8a, 0x19, 0x80, 0x39, 0x02, 0x30, + 0x98, 0x23, 0x40, 0x8a, 0x31, 0x44, 0x54, 0x44, 0x56, 0x0c, 0x20, 0xa2, 0x1a, 0xc2, 0x81, 0x80, + 0x54, 0x20, 0x00, 0x00, 0x13, 0x14, 0x72, 0xc0, 0x87, 0x74, 0x60, 0x87, 0x36, 0x68, 0x87, 0x79, + 0x68, 0x03, 0x72, 0xc0, 0x87, 0x0d, 0xaf, 0x50, 0x0e, 0x6d, 0xd0, 0x0e, 0x7a, 0x50, 0x0e, 0x6d, + 0x00, 0x0f, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x71, 0xa0, + 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x78, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, + 0x71, 0x60, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xe9, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, + 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x10, + 0x07, 0x76, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0e, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, + 0x72, 0xd0, 0x06, 0xe6, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0xe0, 0x0e, 0x78, + 0xa0, 0x07, 0x71, 0x60, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x43, 0x9e, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x3c, 0x06, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x79, 0x10, 0x20, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x02, 0x01, 0x0d, 0x00, 0x00, 0x00, 0x32, 0x1e, 0x98, 0x14, + 0x19, 0x11, 0x4c, 0x90, 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0xa2, 0x12, 0x18, 0x01, 0x28, + 0x88, 0x62, 0x28, 0x83, 0x72, 0x28, 0x0f, 0xaa, 0x92, 0x18, 0x01, 0x28, 0x83, 0x42, 0x28, 0x02, + 0xda, 0xb1, 0x14, 0x04, 0x81, 0xc0, 0x00, 0x14, 0x80, 0x40, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, + 0x79, 0x18, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x1a, 0x03, 0x4c, 0x90, 0x46, 0x02, 0x13, 0xc4, + 0x31, 0x20, 0xc3, 0x1b, 0x43, 0x81, 0x93, 0x4b, 0xb3, 0x0b, 0xa3, 0x2b, 0x4b, 0x01, 0x89, 0x71, + 0xc1, 0x71, 0x81, 0x71, 0xa1, 0xb9, 0xc1, 0xc9, 0x01, 0x41, 0x11, 0xa3, 0xb9, 0x89, 0x89, 0xc1, + 0x99, 0xc9, 0x29, 0x4b, 0xd9, 0x10, 0x04, 0x13, 0x04, 0x62, 0x98, 0x20, 0x10, 0xc4, 0x06, 0x61, + 0x20, 0x26, 0x08, 0x44, 0xb1, 0x41, 0x18, 0x0c, 0x0a, 0x76, 0x73, 0x13, 0x04, 0xc2, 0xd8, 0x30, + 0x20, 0x09, 0x31, 0x41, 0x58, 0x9e, 0x0d, 0xc1, 0x32, 0x41, 0x10, 0x00, 0x12, 0x6d, 0x61, 0x69, + 0x6e, 0x44, 0xa8, 0x8a, 0xb0, 0x86, 0x9e, 0x9e, 0xa4, 0x88, 0x26, 0x08, 0x85, 0x32, 0x41, 0x28, + 0x96, 0x0d, 0x01, 0x31, 0x41, 0x28, 0x98, 0x09, 0x02, 0x71, 0x4c, 0x10, 0x08, 0x64, 0x83, 0x40, + 0x55, 0x1b, 0x16, 0xe2, 0x81, 0x22, 0x29, 0x1a, 0x26, 0x22, 0xb2, 0x36, 0x04, 0xc3, 0x04, 0xa1, + 0x68, 0x26, 0x08, 0x44, 0xb2, 0x41, 0xa0, 0xb4, 0x0d, 0xcb, 0xf0, 0x40, 0x11, 0x16, 0x0d, 0xd9, + 0x10, 0x6d, 0x1b, 0x84, 0x8b, 0x9b, 0x20, 0x14, 0xce, 0x86, 0x85, 0x78, 0xa0, 0x48, 0xf2, 0x86, + 0x8c, 0x88, 0x36, 0x2e, 0x53, 0x56, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x1b, + 0x96, 0x01, 0x0c, 0xa0, 0x49, 0xca, 0x86, 0x6c, 0x88, 0xb6, 0x0d, 0xc2, 0x17, 0x06, 0x1b, 0x86, + 0x4e, 0x0c, 0x80, 0x0d, 0x45, 0xe3, 0x8c, 0x01, 0x00, 0x54, 0x61, 0x63, 0xb3, 0x6b, 0x73, 0x49, + 0x23, 0x2b, 0x73, 0xa3, 0x9b, 0x12, 0x04, 0x55, 0xc8, 0xf0, 0x5c, 0xec, 0xca, 0xe4, 0xe6, 0xd2, + 0xde, 0xdc, 0xa6, 0x04, 0x44, 0x13, 0x32, 0x3c, 0x17, 0xbb, 0x30, 0x36, 0xbb, 0x32, 0xb9, 0x29, + 0x81, 0x51, 0x87, 0x0c, 0xcf, 0x65, 0x0e, 0x2d, 0x8c, 0xac, 0x4c, 0xae, 0xe9, 0x8d, 0xac, 0x8c, + 0x6d, 0x4a, 0x90, 0xd4, 0x21, 0xc3, 0x73, 0xb1, 0x4b, 0x2b, 0xbb, 0x4b, 0x22, 0x9b, 0xa2, 0x0b, + 0xa3, 0x2b, 0x9b, 0x12, 0x2c, 0x75, 0xc8, 0xf0, 0x5c, 0xca, 0xdc, 0xe8, 0xe4, 0xf2, 0xa0, 0xde, + 0xd2, 0xdc, 0xe8, 0xe6, 0xa6, 0x04, 0x63, 0x00, 0x79, 0x18, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, + 0x33, 0x08, 0x80, 0x1c, 0xc4, 0xe1, 0x1c, 0x66, 0x14, 0x01, 0x3d, 0x88, 0x43, 0x38, 0x84, 0xc3, + 0x8c, 0x42, 0x80, 0x07, 0x79, 0x78, 0x07, 0x73, 0x98, 0x71, 0x0c, 0xe6, 0x00, 0x0f, 0xed, 0x10, + 0x0e, 0xf4, 0x80, 0x0e, 0x33, 0x0c, 0x42, 0x1e, 0xc2, 0xc1, 0x1d, 0xce, 0xa1, 0x1c, 0x66, 0x30, + 0x05, 0x3d, 0x88, 0x43, 0x38, 0x84, 0x83, 0x1b, 0xcc, 0x03, 0x3d, 0xc8, 0x43, 0x3d, 0x8c, 0x03, + 0x3d, 0xcc, 0x78, 0x8c, 0x74, 0x70, 0x07, 0x7b, 0x08, 0x07, 0x79, 0x48, 0x87, 0x70, 0x70, 0x07, + 0x7a, 0x70, 0x03, 0x76, 0x78, 0x87, 0x70, 0x20, 0x87, 0x19, 0xcc, 0x11, 0x0e, 0xec, 0x90, 0x0e, + 0xe1, 0x30, 0x0f, 0x6e, 0x30, 0x0f, 0xe3, 0xf0, 0x0e, 0xf0, 0x50, 0x0e, 0x33, 0x10, 0xc4, 0x1d, + 0xde, 0x21, 0x1c, 0xd8, 0x21, 0x1d, 0xc2, 0x61, 0x1e, 0x66, 0x30, 0x89, 0x3b, 0xbc, 0x83, 0x3b, + 0xd0, 0x43, 0x39, 0xb4, 0x03, 0x3c, 0xbc, 0x83, 0x3c, 0x84, 0x03, 0x3b, 0xcc, 0xf0, 0x14, 0x76, + 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x68, 0x87, 0x72, 0x68, 0x07, 0x37, 0x80, 0x87, 0x70, 0x90, + 0x87, 0x70, 0x60, 0x07, 0x76, 0x28, 0x07, 0x76, 0xf8, 0x05, 0x76, 0x78, 0x87, 0x77, 0x80, 0x87, + 0x5f, 0x08, 0x87, 0x71, 0x18, 0x87, 0x72, 0x98, 0x87, 0x79, 0x98, 0x81, 0x2c, 0xee, 0xf0, 0x0e, + 0xee, 0xe0, 0x0e, 0xf5, 0xc0, 0x0e, 0xec, 0x30, 0x03, 0x62, 0xc8, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, + 0xcc, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xdc, 0x61, 0x1c, 0xca, 0x21, 0x1c, 0xc4, 0x81, 0x1d, 0xca, + 0x61, 0x06, 0xd6, 0x90, 0x43, 0x39, 0xc8, 0x43, 0x39, 0x98, 0x43, 0x39, 0xc8, 0x43, 0x39, 0xb8, + 0xc3, 0x38, 0x94, 0x43, 0x38, 0x88, 0x03, 0x3b, 0x94, 0xc3, 0x2f, 0xbc, 0x83, 0x3c, 0xfc, 0x82, + 0x3b, 0xd4, 0x03, 0x3b, 0xb0, 0xc3, 0x8c, 0xc8, 0x21, 0x07, 0x7c, 0x70, 0x03, 0x72, 0x10, 0x87, + 0x73, 0x70, 0x03, 0x7b, 0x08, 0x07, 0x79, 0x60, 0x87, 0x70, 0xc8, 0x87, 0x77, 0xa8, 0x07, 0x7a, + 0x98, 0x81, 0x3c, 0xe4, 0x80, 0x0f, 0x6e, 0x40, 0x0f, 0xe5, 0xd0, 0x0e, 0xf0, 0x00, 0x00, 0x00, + 0x71, 0x20, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x16, 0x30, 0x0d, 0x97, 0xef, 0x3c, 0xfe, 0xe2, + 0x00, 0x83, 0xd8, 0x3c, 0xd4, 0xe4, 0x17, 0xb7, 0x6d, 0x02, 0xd5, 0x70, 0xf9, 0xce, 0xe3, 0x4b, + 0x93, 0x13, 0x11, 0x28, 0x35, 0x3d, 0xd4, 0xe4, 0x17, 0xb7, 0x6d, 0x00, 0x04, 0x03, 0x20, 0x0d, + 0x00, 0x00, 0x00, 0x00, 0x61, 0x20, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x13, 0x04, 0x41, 0x2c, + 0x10, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x54, 0x25, 0x40, 0x54, 0x0a, 0x85, 0x30, 0x03, + 0x40, 0x33, 0x46, 0x00, 0x82, 0x20, 0x88, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x23, 0x06, 0x09, 0x00, + 0x82, 0x60, 0x60, 0x50, 0x83, 0x14, 0x29, 0xc2, 0x88, 0x41, 0x02, 0x80, 0x20, 0x18, 0x18, 0x15, + 0x31, 0x49, 0xc6, 0x30, 0x62, 0x90, 0x00, 0x20, 0x08, 0x06, 0x86, 0x55, 0x50, 0x53, 0x42, 0x8c, + 0x18, 0x24, 0x00, 0x08, 0x82, 0x81, 0x71, 0x19, 0x15, 0xc5, 0x14, 0x23, 0x06, 0x09, 0x00, 0x82, + 0x60, 0x60, 0x60, 0x47, 0x55, 0x39, 0xc6, 0x88, 0x41, 0x02, 0x80, 0x20, 0x18, 0x18, 0x19, 0x62, + 0x59, 0xca, 0x31, 0x62, 0x90, 0x00, 0x20, 0x08, 0x06, 0x86, 0x96, 0x5c, 0x57, 0x83, 0x8c, 0x18, + 0x24, 0x00, 0x08, 0x82, 0x01, 0xa2, 0x2d, 0x18, 0x16, 0x1d, 0x23, 0x06, 0x09, 0x00, 0x82, 0x60, + 0x80, 0x68, 0x0b, 0x86, 0x31, 0xc6, 0x88, 0x41, 0x02, 0x80, 0x20, 0x18, 0x20, 0xda, 0x82, 0x61, + 0x4e, 0x31, 0x62, 0x90, 0x00, 0x20, 0x08, 0x06, 0x88, 0xb6, 0x60, 0x18, 0x44, 0x8c, 0x18, 0x24, + 0x00, 0x08, 0x82, 0x01, 0xa2, 0x2d, 0x19, 0x16, 0x0d, 0x23, 0x06, 0x09, 0x00, 0x82, 0x60, 0x80, + 0x68, 0x4b, 0x86, 0x31, 0xc2, 0x88, 0x41, 0x02, 0x80, 0x20, 0x18, 0x20, 0xda, 0x92, 0x61, 0x4e, + 0x30, 0x62, 0x90, 0x00, 0x20, 0x08, 0x06, 0x88, 0xb6, 0x64, 0x18, 0x84, 0x20, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, +}; +#endif + +// MSL only makes sense on Apple platforms +#if defined(SDL_PLATFORM_APPLE) +static const Uint8 PositionColor_vert_msl[491] = { + 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x5f, + 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x3e, 0x0a, 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, + 0x20, 0x3c, 0x73, 0x69, 0x6d, 0x64, 0x2f, 0x73, 0x69, 0x6d, 0x64, 0x2e, 0x68, 0x3e, 0x0a, 0x0a, + 0x75, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, + 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x6d, + 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, + 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, + 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x20, 0x5b, 0x5b, 0x75, 0x73, 0x65, 0x72, 0x28, 0x6c, + 0x6f, 0x63, 0x6e, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, + 0x61, 0x74, 0x34, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, + 0x5b, 0x5b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, + 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x69, + 0x6e, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x69, + 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x20, + 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x30, 0x29, 0x5d, 0x5d, + 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x69, 0x6e, 0x5f, + 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x20, 0x5b, 0x5b, + 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x31, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, + 0x7d, 0x3b, 0x0a, 0x0a, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, + 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x28, 0x6d, 0x61, 0x69, 0x6e, 0x30, + 0x5f, 0x69, 0x6e, 0x20, 0x69, 0x6e, 0x20, 0x5b, 0x5b, 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, + 0x6e, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, + 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x3b, 0x0a, 0x20, + 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, + 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x2e, 0x69, 0x6e, + 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x3b, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x28, 0x69, 0x6e, 0x2e, + 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, + 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, + 0x72, 0x6e, 0x20, 0x6f, 0x75, 0x74, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, +}; +#endif + +static const Uint8 PositionColor_vert_spirv[624] = { + 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x16, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x69, 0x6e, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x03, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x2e, 0x76, + 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x2e, 0x76, 0x61, 0x72, 0x2e, + 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x17, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x03, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0xf8, 0x00, 0x02, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, +}; diff --git a/miniwin/miniwin/shaders/generated/ShaderIndex.cpp b/miniwin/miniwin/shaders/generated/ShaderIndex.cpp new file mode 100644 index 00000000..e03eb204 --- /dev/null +++ b/miniwin/miniwin/shaders/generated/ShaderIndex.cpp @@ -0,0 +1,146 @@ +// clang-format off + +// +==============================================+ +// | This file is auto-generated, do not edit it. | +// +==============================================+ + +#include "ShaderIndex.h" + +#include "PositionColor.vert.h" +#include "SolidColor.frag.h" + +#if defined(SDL_PLATFORM_WINDOWS) +static const SDL_GPUShaderCreateInfo VertexShaderDXILCodes[] = { + // VertexShaderId::SolidColor + { + /* code_size */ sizeof(PositionColor_vert_dxil), + /* code */ PositionColor_vert_dxil, + /* entrypoint */ "main", + /* format */ SDL_GPU_SHADERFORMAT_DXIL, + /* stage */ SDL_GPU_SHADERSTAGE_VERTEX, + /* num_samplers */ 0, + /* num_storage_textures */ 0, + /* num_storage_buffers */ 0, + /* num_uniform_buffers */ 0, + }, +}; +#endif + +#if defined(SDL_PLATFORM_APPLE) +static const SDL_GPUShaderCreateInfo VertexShaderMSLCodes[] = { + { + /* code_size */ sizeof(PositionColor_vert_msl), + /* code */ PositionColor_vert_msl, + /* entrypoint */ "main0", + /* format */ SDL_GPU_SHADERFORMAT_MSL, + /* stage */ SDL_GPU_SHADERSTAGE_VERTEX, + /* num_samplers */ 0, + /* num_storage_textures */ 0, + /* num_storage_buffers */ 0, + /* num_uniform_buffers */ 0, + }, +}; +#endif + +static const SDL_GPUShaderCreateInfo VertexShaderSPIRVCodes[] = { + { + /* code_size */ sizeof(PositionColor_vert_spirv), + /* code */ PositionColor_vert_spirv, + /* entrypoint */ "main", + /* format */ SDL_GPU_SHADERFORMAT_SPIRV, + /* stage */ SDL_GPU_SHADERSTAGE_VERTEX, + /* num_samplers */ 0, + /* num_storage_textures */ 0, + /* num_storage_buffers */ 0, + /* num_uniform_buffers */ 0, + }, +}; + +#if defined(SDL_PLATFORM_WINDOWS) +static const SDL_GPUShaderCreateInfo FragmentShaderDXILCodes[] = { + // FragmentShaderId::PositionColor + { + /* code_size */ sizeof(SolidColor_frag_dxil), + /* code */ SolidColor_frag_dxil, + /* entrypoint */ "main", + /* format */ SDL_GPU_SHADERFORMAT_DXIL, + /* stage */ SDL_GPU_SHADERSTAGE_FRAGMENT, + /* num_samplers */ 0, + /* num_storage_textures */ 0, + /* num_storage_buffers */ 0, + /* num_uniform_buffers */ 0, + }, +}; +#endif + +#if defined(SDL_PLATFORM_APPLE) +static const SDL_GPUShaderCreateInfo FragmentShaderMSLCodes[] = { + { + /* code_size */ sizeof(SolidColor_frag_msl), + /* code */ SolidColor_frag_msl, + /* entrypoint */ "main0", + /* format */ SDL_GPU_SHADERFORMAT_MSL, + /* stage */ SDL_GPU_SHADERSTAGE_FRAGMENT, + /* num_samplers */ 0, + /* num_storage_textures */ 0, + /* num_storage_buffers */ 0, + /* num_uniform_buffers */ 0, + }, +}; +#endif + +static const SDL_GPUShaderCreateInfo FragmentShaderSPIRVCodes[] = { + { + /* code_size */ sizeof(SolidColor_frag_spirv), + /* code */ SolidColor_frag_spirv, + /* entrypoint */ "main", + /* format */ SDL_GPU_SHADERFORMAT_SPIRV, + /* stage */ SDL_GPU_SHADERSTAGE_FRAGMENT, + /* num_samplers */ 0, + /* num_storage_textures */ 0, + /* num_storage_buffers */ 0, + /* num_uniform_buffers */ 0, + }, +}; + +const SDL_GPUShaderCreateInfo* GetVertexShaderCode(VertexShaderId id, SDL_GPUShaderFormat formats) { +#if defined(SDL_PLATFORM_WINDOWS) + if (formats & SDL_GPU_SHADERFORMAT_DXIL) { + SDL_assert(id < SDL_arraysize(VertexShaderDXILCodes)); + return &VertexShaderDXILCodes[id]; + } +#endif +#if defined(SDL_PLATFORM_APPLE) + if (formats & SDL_GPU_SHADERFORMAT_MSL) { + SDL_assert(id < SDL_arraysize(VertexShaderMSLCodes)); + return &VertexShaderMSLCodes[id]; + } +#endif + if (formats & SDL_GPU_SHADERFORMAT_SPIRV) { + SDL_assert(id < SDL_arraysize(VertexShaderSPIRVCodes)); + return &VertexShaderSPIRVCodes[id]; + } + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not find vertex shader code for id=%d and formats=0x%x", id, formats); + return nullptr; +} + +const SDL_GPUShaderCreateInfo* GetFragmentShaderCode(FragmentShaderId id, SDL_GPUShaderFormat formats) { +#if defined(SDL_PLATFORM_WINDOWS) + if (formats & SDL_GPU_SHADERFORMAT_DXIL) { + SDL_assert(id < SDL_arraysize(FragmentShaderDXILCodes)); + return &FragmentShaderDXILCodes[id]; + } +#endif +#if defined(SDL_PLATFORM_APPLE) + if (formats & SDL_GPU_SHADERFORMAT_MSL) { + SDL_assert(id < SDL_arraysize(FragmentShaderMSLCodes)); + return &FragmentShaderMSLCodes[id]; + } +#endif + if (formats & SDL_GPU_SHADERFORMAT_SPIRV) { + SDL_assert(id < SDL_arraysize(FragmentShaderSPIRVCodes)); + return &FragmentShaderSPIRVCodes[id]; + } + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not find fragment shader code for id=%d and formats=0x%x", id, formats); + return nullptr; +} diff --git a/miniwin/miniwin/shaders/generated/ShaderIndex.h b/miniwin/miniwin/shaders/generated/ShaderIndex.h new file mode 100644 index 00000000..63a0788b --- /dev/null +++ b/miniwin/miniwin/shaders/generated/ShaderIndex.h @@ -0,0 +1,22 @@ +#pragma once + +// clang-format off + +// +==============================================+ +// | This file is auto-generated, do not edit it. | +// +==============================================+ + +#include + +enum VertexShaderId { + PositionColor, +}; + +enum FragmentShaderId { + SolidColor, +}; + +const SDL_GPUShaderCreateInfo* GetVertexShaderCode(VertexShaderId id, SDL_GPUShaderFormat formats); + +const SDL_GPUShaderCreateInfo* GetFragmentShaderCode(FragmentShaderId id, SDL_GPUShaderFormat formats); + diff --git a/miniwin/miniwin/shaders/generated/SolidColor.frag.h b/miniwin/miniwin/shaders/generated/SolidColor.frag.h new file mode 100644 index 00000000..098df63f --- /dev/null +++ b/miniwin/miniwin/shaders/generated/SolidColor.frag.h @@ -0,0 +1,247 @@ +#pragma once + +// clang-format off + +// +==============================================+ +// | This file is auto-generated, do not edit it. | +// +==============================================+ + +#include + +// DXIL only makes sense on Windows platforms +#if defined(SDL_PLATFORM_WINDOWS) +static const Uint8 SolidColor_frag_dxil[2828] = { + 0x44, 0x58, 0x42, 0x43, 0xd9, 0xf2, 0xa3, 0x93, 0x8b, 0x37, 0xdb, 0xdf, 0xf2, 0x56, 0x1b, 0x56, + 0x84, 0x00, 0xb4, 0x71, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x0b, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3c, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0xc4, 0x00, 0x00, 0x00, + 0x58, 0x01, 0x00, 0x00, 0x10, 0x06, 0x00, 0x00, 0x2c, 0x06, 0x00, 0x00, 0x53, 0x46, 0x49, 0x30, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x53, 0x47, 0x31, + 0x34, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x45, 0x58, 0x43, + 0x4f, 0x4f, 0x52, 0x44, 0x00, 0x00, 0x00, 0x00, 0x4f, 0x53, 0x47, 0x31, 0x34, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, + 0x74, 0x00, 0x00, 0x00, 0x50, 0x53, 0x56, 0x30, 0x8c, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x54, 0x45, 0x58, + 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x44, 0x00, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x44, 0x10, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x53, 0x54, 0x41, 0x54, 0xb0, 0x04, 0x00, 0x00, + 0x60, 0x00, 0x00, 0x00, 0x2c, 0x01, 0x00, 0x00, 0x44, 0x58, 0x49, 0x4c, 0x00, 0x01, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x98, 0x04, 0x00, 0x00, 0x42, 0x43, 0xc0, 0xde, 0x21, 0x0c, 0x00, 0x00, + 0x23, 0x01, 0x00, 0x00, 0x0b, 0x82, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, + 0x07, 0x81, 0x23, 0x91, 0x41, 0xc8, 0x04, 0x49, 0x06, 0x10, 0x32, 0x39, 0x92, 0x01, 0x84, 0x0c, + 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, 0x80, 0x10, 0x45, 0x02, 0x42, 0x92, 0x0b, 0x42, + 0x84, 0x10, 0x32, 0x14, 0x38, 0x08, 0x18, 0x4b, 0x0a, 0x32, 0x42, 0x88, 0x48, 0x90, 0x14, 0x20, + 0x43, 0x46, 0x88, 0xa5, 0x00, 0x19, 0x32, 0x42, 0xe4, 0x48, 0x0e, 0x90, 0x11, 0x22, 0xc4, 0x50, + 0x41, 0x51, 0x81, 0x8c, 0xe1, 0x83, 0xe5, 0x8a, 0x04, 0x21, 0x46, 0x06, 0x51, 0x18, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x1b, 0x8c, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x07, 0x40, 0x02, 0xa8, 0x0d, + 0x84, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x03, 0x20, 0x01, 0x00, 0x00, 0x00, 0x49, 0x18, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x13, 0x82, 0x60, 0x42, 0x20, 0x00, 0x00, 0x00, 0x89, 0x20, 0x00, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x32, 0x22, 0x08, 0x09, 0x20, 0x64, 0x85, 0x04, 0x13, 0x22, 0xa4, 0x84, + 0x04, 0x13, 0x22, 0xe3, 0x84, 0xa1, 0x90, 0x14, 0x12, 0x4c, 0x88, 0x8c, 0x0b, 0x84, 0x84, 0x4c, + 0x10, 0x30, 0x23, 0x00, 0x25, 0x00, 0x8a, 0x19, 0x80, 0x39, 0x02, 0x30, 0x98, 0x23, 0x40, 0x8a, + 0x31, 0x44, 0x54, 0x44, 0x56, 0x0c, 0x20, 0xa2, 0x1a, 0xc2, 0x81, 0x80, 0x34, 0x20, 0x00, 0x00, + 0x13, 0x14, 0x72, 0xc0, 0x87, 0x74, 0x60, 0x87, 0x36, 0x68, 0x87, 0x79, 0x68, 0x03, 0x72, 0xc0, + 0x87, 0x0d, 0xaf, 0x50, 0x0e, 0x6d, 0xd0, 0x0e, 0x7a, 0x50, 0x0e, 0x6d, 0x00, 0x0f, 0x7a, 0x30, + 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x71, 0xa0, 0x07, 0x73, 0x20, 0x07, + 0x6d, 0x90, 0x0e, 0x78, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x71, 0x60, 0x07, 0x7a, + 0x30, 0x07, 0x72, 0xd0, 0x06, 0xe9, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, + 0x0e, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x10, 0x07, 0x76, 0xa0, 0x07, + 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0e, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xe6, + 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0xe0, 0x0e, 0x78, 0xa0, 0x07, 0x71, 0x60, + 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x43, 0x9e, 0x00, 0x08, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x3c, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0c, 0x79, 0x10, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc8, 0x02, 0x01, 0x0b, 0x00, 0x00, 0x00, 0x32, 0x1e, 0x98, 0x14, 0x19, 0x11, 0x4c, 0x90, + 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0xa2, 0x12, 0x18, 0x01, 0x28, 0x86, 0x32, 0x28, 0x8f, + 0x92, 0x28, 0x04, 0xaa, 0x92, 0x18, 0x01, 0x28, 0x82, 0x42, 0x28, 0x10, 0xda, 0xb1, 0x0c, 0x82, + 0x08, 0x04, 0x02, 0x01, 0x79, 0x18, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x1a, 0x03, 0x4c, 0x90, + 0x46, 0x02, 0x13, 0xc4, 0x31, 0x20, 0xc3, 0x1b, 0x43, 0x81, 0x93, 0x4b, 0xb3, 0x0b, 0xa3, 0x2b, + 0x4b, 0x01, 0x89, 0x71, 0xc1, 0x71, 0x81, 0x71, 0xa1, 0xb9, 0xc1, 0xc9, 0x01, 0x41, 0x11, 0xa3, + 0xb9, 0x89, 0x89, 0xc1, 0x99, 0xc9, 0x29, 0x4b, 0xd9, 0x10, 0x04, 0x13, 0x04, 0x62, 0x98, 0x20, + 0x10, 0xc4, 0x06, 0x61, 0x20, 0x36, 0x08, 0x04, 0x41, 0x01, 0x6e, 0x6e, 0x82, 0x40, 0x14, 0x1b, + 0x86, 0x03, 0x21, 0x26, 0x08, 0x02, 0xb0, 0x01, 0xd8, 0x30, 0x10, 0xcb, 0xb2, 0x21, 0x60, 0x36, + 0x0c, 0x83, 0xd2, 0x4c, 0x10, 0x96, 0x67, 0x43, 0xf0, 0x90, 0x68, 0x0b, 0x4b, 0x73, 0x23, 0x42, + 0x55, 0x84, 0x35, 0xf4, 0xf4, 0x24, 0x45, 0x34, 0x41, 0x28, 0x94, 0x09, 0x42, 0xb1, 0x6c, 0x08, + 0x88, 0x09, 0x42, 0xc1, 0x4c, 0x10, 0x8a, 0x66, 0x82, 0x40, 0x18, 0x13, 0x04, 0xe2, 0xd8, 0x20, + 0x60, 0xd9, 0x86, 0x85, 0x90, 0x26, 0xaa, 0xb2, 0x86, 0x8b, 0xa0, 0xb4, 0x0d, 0xc1, 0xc6, 0x64, + 0xca, 0xea, 0x8b, 0x2a, 0x4c, 0xee, 0xac, 0x8c, 0x6e, 0x82, 0x50, 0x38, 0x1b, 0x16, 0xa2, 0x9b, + 0xbc, 0x8a, 0x1a, 0x2e, 0x82, 0xd2, 0x36, 0x04, 0xdf, 0x86, 0x81, 0x03, 0x03, 0x60, 0x43, 0xa1, + 0x44, 0x61, 0x00, 0x00, 0x2c, 0xd2, 0xdc, 0xe6, 0xe8, 0xe6, 0x26, 0x08, 0x04, 0x42, 0x63, 0x2e, + 0xed, 0xec, 0x8b, 0x8d, 0x6c, 0x82, 0x40, 0x24, 0x34, 0xe6, 0xd2, 0xce, 0xbe, 0xe6, 0xe8, 0x36, + 0x18, 0x63, 0x40, 0x06, 0x65, 0x60, 0x06, 0x67, 0x60, 0x06, 0x55, 0xd8, 0xd8, 0xec, 0xda, 0x5c, + 0xd2, 0xc8, 0xca, 0xdc, 0xe8, 0xa6, 0x04, 0x41, 0x15, 0x32, 0x3c, 0x17, 0xbb, 0x32, 0xb9, 0xb9, + 0xb4, 0x37, 0xb7, 0x29, 0x01, 0xd1, 0x84, 0x0c, 0xcf, 0xc5, 0x2e, 0x8c, 0xcd, 0xae, 0x4c, 0x6e, + 0x4a, 0x50, 0xd4, 0x21, 0xc3, 0x73, 0x99, 0x43, 0x0b, 0x23, 0x2b, 0x93, 0x6b, 0x7a, 0x23, 0x2b, + 0x63, 0x9b, 0x12, 0x20, 0x95, 0xc8, 0xf0, 0x5c, 0xe8, 0xf2, 0xe0, 0xca, 0x82, 0xdc, 0xdc, 0xde, + 0xe8, 0xc2, 0xe8, 0xd2, 0xde, 0xdc, 0xe6, 0xa6, 0x04, 0x4d, 0x1d, 0x32, 0x3c, 0x17, 0xbb, 0xb4, + 0xb2, 0xbb, 0x24, 0xb2, 0x29, 0xba, 0x30, 0xba, 0xb2, 0x29, 0xc1, 0x53, 0x87, 0x0c, 0xcf, 0xa5, + 0xcc, 0x8d, 0x4e, 0x2e, 0x0f, 0xea, 0x2d, 0xcd, 0x8d, 0x6e, 0x6e, 0x4a, 0x10, 0x06, 0x5d, 0xc8, + 0xf0, 0x5c, 0xc6, 0xde, 0xea, 0xdc, 0xe8, 0xca, 0xe4, 0xe6, 0xa6, 0x04, 0x67, 0x00, 0x00, 0x00, + 0x79, 0x18, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x33, 0x08, 0x80, 0x1c, 0xc4, 0xe1, 0x1c, 0x66, + 0x14, 0x01, 0x3d, 0x88, 0x43, 0x38, 0x84, 0xc3, 0x8c, 0x42, 0x80, 0x07, 0x79, 0x78, 0x07, 0x73, + 0x98, 0x71, 0x0c, 0xe6, 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x33, 0x0c, 0x42, 0x1e, + 0xc2, 0xc1, 0x1d, 0xce, 0xa1, 0x1c, 0x66, 0x30, 0x05, 0x3d, 0x88, 0x43, 0x38, 0x84, 0x83, 0x1b, + 0xcc, 0x03, 0x3d, 0xc8, 0x43, 0x3d, 0x8c, 0x03, 0x3d, 0xcc, 0x78, 0x8c, 0x74, 0x70, 0x07, 0x7b, + 0x08, 0x07, 0x79, 0x48, 0x87, 0x70, 0x70, 0x07, 0x7a, 0x70, 0x03, 0x76, 0x78, 0x87, 0x70, 0x20, + 0x87, 0x19, 0xcc, 0x11, 0x0e, 0xec, 0x90, 0x0e, 0xe1, 0x30, 0x0f, 0x6e, 0x30, 0x0f, 0xe3, 0xf0, + 0x0e, 0xf0, 0x50, 0x0e, 0x33, 0x10, 0xc4, 0x1d, 0xde, 0x21, 0x1c, 0xd8, 0x21, 0x1d, 0xc2, 0x61, + 0x1e, 0x66, 0x30, 0x89, 0x3b, 0xbc, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xb4, 0x03, 0x3c, 0xbc, 0x83, + 0x3c, 0x84, 0x03, 0x3b, 0xcc, 0xf0, 0x14, 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x68, 0x87, + 0x72, 0x68, 0x07, 0x37, 0x80, 0x87, 0x70, 0x90, 0x87, 0x70, 0x60, 0x07, 0x76, 0x28, 0x07, 0x76, + 0xf8, 0x05, 0x76, 0x78, 0x87, 0x77, 0x80, 0x87, 0x5f, 0x08, 0x87, 0x71, 0x18, 0x87, 0x72, 0x98, + 0x87, 0x79, 0x98, 0x81, 0x2c, 0xee, 0xf0, 0x0e, 0xee, 0xe0, 0x0e, 0xf5, 0xc0, 0x0e, 0xec, 0x30, + 0x03, 0x62, 0xc8, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xcc, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xdc, 0x61, + 0x1c, 0xca, 0x21, 0x1c, 0xc4, 0x81, 0x1d, 0xca, 0x61, 0x06, 0xd6, 0x90, 0x43, 0x39, 0xc8, 0x43, + 0x39, 0x98, 0x43, 0x39, 0xc8, 0x43, 0x39, 0xb8, 0xc3, 0x38, 0x94, 0x43, 0x38, 0x88, 0x03, 0x3b, + 0x94, 0xc3, 0x2f, 0xbc, 0x83, 0x3c, 0xfc, 0x82, 0x3b, 0xd4, 0x03, 0x3b, 0xb0, 0xc3, 0x8c, 0xc8, + 0x21, 0x07, 0x7c, 0x70, 0x03, 0x72, 0x10, 0x87, 0x73, 0x70, 0x03, 0x7b, 0x08, 0x07, 0x79, 0x60, + 0x87, 0x70, 0xc8, 0x87, 0x77, 0xa8, 0x07, 0x7a, 0x98, 0x81, 0x3c, 0xe4, 0x80, 0x0f, 0x6e, 0x40, + 0x0f, 0xe5, 0xd0, 0x0e, 0xf0, 0x00, 0x00, 0x00, 0x71, 0x20, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x16, 0x30, 0x0d, 0x97, 0xef, 0x3c, 0xfe, 0xe2, 0x00, 0x83, 0xd8, 0x3c, 0xd4, 0xe4, 0x17, 0xb7, + 0x6d, 0x02, 0xd5, 0x70, 0xf9, 0xce, 0xe3, 0x4b, 0x93, 0x13, 0x11, 0x28, 0x35, 0x3d, 0xd4, 0xe4, + 0x17, 0xb7, 0x6d, 0x00, 0x04, 0x03, 0x20, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x48, 0x41, 0x53, 0x48, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdd, 0xaa, 0xe8, 0x4e, + 0x4d, 0x22, 0xc0, 0x8e, 0x28, 0x26, 0xc3, 0x90, 0xc2, 0x72, 0xe0, 0xab, 0x44, 0x58, 0x49, 0x4c, + 0xd8, 0x04, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x36, 0x01, 0x00, 0x00, 0x44, 0x58, 0x49, 0x4c, + 0x00, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0xc0, 0x04, 0x00, 0x00, 0x42, 0x43, 0xc0, 0xde, + 0x21, 0x0c, 0x00, 0x00, 0x2d, 0x01, 0x00, 0x00, 0x0b, 0x82, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x07, 0x81, 0x23, 0x91, 0x41, 0xc8, 0x04, 0x49, 0x06, 0x10, 0x32, 0x39, + 0x92, 0x01, 0x84, 0x0c, 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, 0x80, 0x10, 0x45, 0x02, + 0x42, 0x92, 0x0b, 0x42, 0x84, 0x10, 0x32, 0x14, 0x38, 0x08, 0x18, 0x4b, 0x0a, 0x32, 0x42, 0x88, + 0x48, 0x90, 0x14, 0x20, 0x43, 0x46, 0x88, 0xa5, 0x00, 0x19, 0x32, 0x42, 0xe4, 0x48, 0x0e, 0x90, + 0x11, 0x22, 0xc4, 0x50, 0x41, 0x51, 0x81, 0x8c, 0xe1, 0x83, 0xe5, 0x8a, 0x04, 0x21, 0x46, 0x06, + 0x51, 0x18, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1b, 0x8c, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x07, + 0x40, 0x02, 0xa8, 0x0d, 0x84, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x03, 0x20, 0x01, 0x00, 0x00, 0x00, + 0x49, 0x18, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, 0x82, 0x60, 0x42, 0x20, 0x00, 0x00, 0x00, + 0x89, 0x20, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x32, 0x22, 0x08, 0x09, 0x20, 0x64, 0x85, 0x04, + 0x13, 0x22, 0xa4, 0x84, 0x04, 0x13, 0x22, 0xe3, 0x84, 0xa1, 0x90, 0x14, 0x12, 0x4c, 0x88, 0x8c, + 0x0b, 0x84, 0x84, 0x4c, 0x10, 0x30, 0x23, 0x00, 0x25, 0x00, 0x8a, 0x19, 0x80, 0x39, 0x02, 0x30, + 0x98, 0x23, 0x40, 0x8a, 0x31, 0x44, 0x54, 0x44, 0x56, 0x0c, 0x20, 0xa2, 0x1a, 0xc2, 0x81, 0x80, + 0x34, 0x20, 0x00, 0x00, 0x13, 0x14, 0x72, 0xc0, 0x87, 0x74, 0x60, 0x87, 0x36, 0x68, 0x87, 0x79, + 0x68, 0x03, 0x72, 0xc0, 0x87, 0x0d, 0xaf, 0x50, 0x0e, 0x6d, 0xd0, 0x0e, 0x7a, 0x50, 0x0e, 0x6d, + 0x00, 0x0f, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x71, 0xa0, + 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x78, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, + 0x71, 0x60, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xe9, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, + 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x10, + 0x07, 0x76, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0e, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, + 0x72, 0xd0, 0x06, 0xe6, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0xe0, 0x0e, 0x78, + 0xa0, 0x07, 0x71, 0x60, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x43, 0x9e, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x3c, 0x06, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x79, 0x10, 0x20, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x02, 0x01, 0x0b, 0x00, 0x00, 0x00, 0x32, 0x1e, 0x98, 0x10, + 0x19, 0x11, 0x4c, 0x90, 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0xa2, 0x12, 0x18, 0x01, 0x28, + 0x88, 0x62, 0x28, 0x83, 0xf2, 0xa0, 0x2a, 0x89, 0x11, 0x80, 0x22, 0x28, 0x84, 0x02, 0xa1, 0x1d, + 0xcb, 0x20, 0x88, 0x40, 0x20, 0x10, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, + 0x1a, 0x03, 0x4c, 0x90, 0x46, 0x02, 0x13, 0xc4, 0x31, 0x20, 0xc3, 0x1b, 0x43, 0x81, 0x93, 0x4b, + 0xb3, 0x0b, 0xa3, 0x2b, 0x4b, 0x01, 0x89, 0x71, 0xc1, 0x71, 0x81, 0x71, 0xa1, 0xb9, 0xc1, 0xc9, + 0x01, 0x41, 0x11, 0xa3, 0xb9, 0x89, 0x89, 0xc1, 0x99, 0xc9, 0x29, 0x4b, 0xd9, 0x10, 0x04, 0x13, + 0x04, 0x62, 0x98, 0x20, 0x10, 0xc4, 0x06, 0x61, 0x20, 0x26, 0x08, 0x44, 0xb1, 0x41, 0x18, 0x0c, + 0x0a, 0x70, 0x73, 0x13, 0x04, 0xc2, 0xd8, 0x30, 0x20, 0x09, 0x31, 0x41, 0x58, 0x9c, 0x0d, 0xc1, + 0x32, 0x41, 0x10, 0x00, 0x12, 0x6d, 0x61, 0x69, 0x6e, 0x44, 0xa8, 0x8a, 0xb0, 0x86, 0x9e, 0x9e, + 0xa4, 0x88, 0x26, 0x08, 0x45, 0x32, 0x41, 0x28, 0x94, 0x0d, 0x01, 0x31, 0x41, 0x28, 0x96, 0x09, + 0x42, 0xc1, 0x4c, 0x10, 0x88, 0x63, 0x82, 0x40, 0x20, 0x1b, 0x84, 0xca, 0xda, 0xb0, 0x10, 0x0f, + 0x14, 0x49, 0xd3, 0x40, 0x11, 0xd1, 0xb5, 0x21, 0xc0, 0x98, 0x4c, 0x59, 0x7d, 0x51, 0x85, 0xc9, + 0x9d, 0x95, 0xd1, 0x4d, 0x10, 0x8a, 0x66, 0xc3, 0x42, 0x68, 0xd0, 0x26, 0x45, 0x03, 0x45, 0x44, + 0xd7, 0x86, 0x80, 0xdb, 0x30, 0x64, 0x1d, 0xb0, 0xa1, 0x68, 0x1c, 0x0f, 0x00, 0xaa, 0xb0, 0xb1, + 0xd9, 0xb5, 0xb9, 0xa4, 0x91, 0x95, 0xb9, 0xd1, 0x4d, 0x09, 0x82, 0x2a, 0x64, 0x78, 0x2e, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x02, 0xa2, 0x09, 0x19, 0x9e, 0x8b, 0x5d, 0x18, 0x9b, + 0x5d, 0x99, 0xdc, 0x94, 0xc0, 0xa8, 0x43, 0x86, 0xe7, 0x32, 0x87, 0x16, 0x46, 0x56, 0x26, 0xd7, + 0xf4, 0x46, 0x56, 0xc6, 0x36, 0x25, 0x48, 0xea, 0x90, 0xe1, 0xb9, 0xd8, 0xa5, 0x95, 0xdd, 0x25, + 0x91, 0x4d, 0xd1, 0x85, 0xd1, 0x95, 0x4d, 0x09, 0x96, 0x3a, 0x64, 0x78, 0x2e, 0x65, 0x6e, 0x74, + 0x72, 0x79, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x53, 0x02, 0x0f, 0x00, 0x79, 0x18, 0x00, 0x00, + 0x4c, 0x00, 0x00, 0x00, 0x33, 0x08, 0x80, 0x1c, 0xc4, 0xe1, 0x1c, 0x66, 0x14, 0x01, 0x3d, 0x88, + 0x43, 0x38, 0x84, 0xc3, 0x8c, 0x42, 0x80, 0x07, 0x79, 0x78, 0x07, 0x73, 0x98, 0x71, 0x0c, 0xe6, + 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x33, 0x0c, 0x42, 0x1e, 0xc2, 0xc1, 0x1d, 0xce, + 0xa1, 0x1c, 0x66, 0x30, 0x05, 0x3d, 0x88, 0x43, 0x38, 0x84, 0x83, 0x1b, 0xcc, 0x03, 0x3d, 0xc8, + 0x43, 0x3d, 0x8c, 0x03, 0x3d, 0xcc, 0x78, 0x8c, 0x74, 0x70, 0x07, 0x7b, 0x08, 0x07, 0x79, 0x48, + 0x87, 0x70, 0x70, 0x07, 0x7a, 0x70, 0x03, 0x76, 0x78, 0x87, 0x70, 0x20, 0x87, 0x19, 0xcc, 0x11, + 0x0e, 0xec, 0x90, 0x0e, 0xe1, 0x30, 0x0f, 0x6e, 0x30, 0x0f, 0xe3, 0xf0, 0x0e, 0xf0, 0x50, 0x0e, + 0x33, 0x10, 0xc4, 0x1d, 0xde, 0x21, 0x1c, 0xd8, 0x21, 0x1d, 0xc2, 0x61, 0x1e, 0x66, 0x30, 0x89, + 0x3b, 0xbc, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xb4, 0x03, 0x3c, 0xbc, 0x83, 0x3c, 0x84, 0x03, 0x3b, + 0xcc, 0xf0, 0x14, 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x68, 0x87, 0x72, 0x68, 0x07, 0x37, + 0x80, 0x87, 0x70, 0x90, 0x87, 0x70, 0x60, 0x07, 0x76, 0x28, 0x07, 0x76, 0xf8, 0x05, 0x76, 0x78, + 0x87, 0x77, 0x80, 0x87, 0x5f, 0x08, 0x87, 0x71, 0x18, 0x87, 0x72, 0x98, 0x87, 0x79, 0x98, 0x81, + 0x2c, 0xee, 0xf0, 0x0e, 0xee, 0xe0, 0x0e, 0xf5, 0xc0, 0x0e, 0xec, 0x30, 0x03, 0x62, 0xc8, 0xa1, + 0x1c, 0xe4, 0xa1, 0x1c, 0xcc, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xdc, 0x61, 0x1c, 0xca, 0x21, 0x1c, + 0xc4, 0x81, 0x1d, 0xca, 0x61, 0x06, 0xd6, 0x90, 0x43, 0x39, 0xc8, 0x43, 0x39, 0x98, 0x43, 0x39, + 0xc8, 0x43, 0x39, 0xb8, 0xc3, 0x38, 0x94, 0x43, 0x38, 0x88, 0x03, 0x3b, 0x94, 0xc3, 0x2f, 0xbc, + 0x83, 0x3c, 0xfc, 0x82, 0x3b, 0xd4, 0x03, 0x3b, 0xb0, 0xc3, 0x8c, 0xc8, 0x21, 0x07, 0x7c, 0x70, + 0x03, 0x72, 0x10, 0x87, 0x73, 0x70, 0x03, 0x7b, 0x08, 0x07, 0x79, 0x60, 0x87, 0x70, 0xc8, 0x87, + 0x77, 0xa8, 0x07, 0x7a, 0x98, 0x81, 0x3c, 0xe4, 0x80, 0x0f, 0x6e, 0x40, 0x0f, 0xe5, 0xd0, 0x0e, + 0xf0, 0x00, 0x00, 0x00, 0x71, 0x20, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x16, 0x30, 0x0d, 0x97, + 0xef, 0x3c, 0xfe, 0xe2, 0x00, 0x83, 0xd8, 0x3c, 0xd4, 0xe4, 0x17, 0xb7, 0x6d, 0x02, 0xd5, 0x70, + 0xf9, 0xce, 0xe3, 0x4b, 0x93, 0x13, 0x11, 0x28, 0x35, 0x3d, 0xd4, 0xe4, 0x17, 0xb7, 0x6d, 0x00, + 0x04, 0x03, 0x20, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x61, 0x20, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, + 0x13, 0x04, 0x41, 0x2c, 0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x44, 0x85, 0x30, 0x03, + 0x50, 0x0a, 0x54, 0x25, 0x50, 0x06, 0x00, 0x00, 0x23, 0x06, 0x09, 0x00, 0x82, 0x60, 0x60, 0x4c, + 0x05, 0x04, 0x29, 0xc4, 0x88, 0x41, 0x02, 0x80, 0x20, 0x18, 0x18, 0x94, 0x11, 0x45, 0x43, 0x31, + 0x62, 0x90, 0x00, 0x20, 0x08, 0x06, 0x46, 0x75, 0x48, 0xd2, 0x62, 0x8c, 0x18, 0x24, 0x00, 0x08, + 0x82, 0x81, 0x61, 0x21, 0xd3, 0x44, 0x1c, 0x23, 0x06, 0x09, 0x00, 0x82, 0x60, 0x80, 0x58, 0x07, + 0x45, 0x39, 0xc4, 0x88, 0x41, 0x02, 0x80, 0x20, 0x18, 0x20, 0xd6, 0x41, 0x51, 0xc6, 0x30, 0x62, + 0x90, 0x00, 0x20, 0x08, 0x06, 0x88, 0x75, 0x50, 0x54, 0x23, 0x8c, 0x18, 0x24, 0x00, 0x08, 0x82, + 0x01, 0x62, 0x1d, 0x14, 0x55, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, +}; +#endif + +// MSL only makes sense on Apple platforms +#if defined(SDL_PLATFORM_APPLE) +static const Uint8 SolidColor_frag_msl[352] = { + 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x5f, + 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x3e, 0x0a, 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, + 0x20, 0x3c, 0x73, 0x69, 0x6d, 0x64, 0x2f, 0x73, 0x69, 0x6d, 0x64, 0x2e, 0x68, 0x3e, 0x0a, 0x0a, + 0x75, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, + 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x6d, + 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, + 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x53, 0x56, + 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x30, 0x20, 0x5b, 0x5b, 0x63, 0x6f, 0x6c, 0x6f, 0x72, + 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, + 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x69, 0x6e, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, + 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x20, 0x5b, 0x5b, 0x75, 0x73, 0x65, 0x72, 0x28, + 0x6c, 0x6f, 0x63, 0x6e, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x66, 0x72, + 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, + 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x28, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x69, 0x6e, 0x20, + 0x69, 0x6e, 0x20, 0x5b, 0x5b, 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x29, + 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, + 0x20, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, + 0x75, 0x74, 0x2e, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x53, 0x56, 0x5f, 0x54, 0x61, + 0x72, 0x67, 0x65, 0x74, 0x30, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x2e, 0x69, 0x6e, 0x5f, 0x76, 0x61, + 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x75, 0x74, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, +}; +#endif + +static const Uint8 SolidColor_frag_spirv[372] = { + 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, + 0x4f, 0x52, 0x44, 0x30, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x6f, 0x75, 0x74, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, + 0x74, 0x30, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x17, 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x02, 0x00, 0x08, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, + 0x38, 0x00, 0x01, 0x00, +}; diff --git a/miniwin/miniwin/shaders/src/PositionColor.vert.hlsl b/miniwin/miniwin/shaders/src/PositionColor.vert.hlsl new file mode 100644 index 00000000..8b106f16 --- /dev/null +++ b/miniwin/miniwin/shaders/src/PositionColor.vert.hlsl @@ -0,0 +1,19 @@ +struct Input +{ + float3 Position : TEXCOORD0; + float4 Color : TEXCOORD1; +}; + +struct Output +{ + float4 Color : TEXCOORD0; + float4 Position : SV_Position; +}; + +Output main(Input input) +{ + Output output; + output.Color = input.Color; + output.Position = float4(input.Position, 1.0f); + return output; +} diff --git a/miniwin/miniwin/shaders/src/PositionColor.vert.hlsl.json b/miniwin/miniwin/shaders/src/PositionColor.vert.hlsl.json new file mode 100644 index 00000000..0560c97d --- /dev/null +++ b/miniwin/miniwin/shaders/src/PositionColor.vert.hlsl.json @@ -0,0 +1,6 @@ +{ + "num_samplers": 0, + "num_storage_textures": 0, + "num_storage_buffers": 0, + "num_uniform_buffers": 0 +} diff --git a/miniwin/miniwin/shaders/src/SolidColor.frag.hlsl b/miniwin/miniwin/shaders/src/SolidColor.frag.hlsl new file mode 100644 index 00000000..a8e6d9f9 --- /dev/null +++ b/miniwin/miniwin/shaders/src/SolidColor.frag.hlsl @@ -0,0 +1,4 @@ +float4 main(float4 Color : TEXCOORD0) : SV_Target0 +{ + return Color; +} diff --git a/miniwin/miniwin/shaders/src/SolidColor.frag.hlsl.json b/miniwin/miniwin/shaders/src/SolidColor.frag.hlsl.json new file mode 100644 index 00000000..0560c97d --- /dev/null +++ b/miniwin/miniwin/shaders/src/SolidColor.frag.hlsl.json @@ -0,0 +1,6 @@ +{ + "num_samplers": 0, + "num_storage_textures": 0, + "num_storage_buffers": 0, + "num_uniform_buffers": 0 +} diff --git a/miniwin/miniwin/src/include/miniwin_d3drm_p.h b/miniwin/miniwin/src/include/miniwin_d3drm_p.h new file mode 100644 index 00000000..03eef0c8 --- /dev/null +++ b/miniwin/miniwin/src/include/miniwin_d3drm_p.h @@ -0,0 +1,76 @@ +#pragma once + +#include "miniwin_d3drm.h" + +#include +#include +#include + +typedef struct PositionColorVertex { + float x, y, z; + Uint8 r, g, b, a; +} PositionColorVertex; + +template +class Direct3DRMArrayBase : public ArrayInterface { +public: + ~Direct3DRMArrayBase() override + { + for (auto* item : items) { + if (item) { + item->Release(); + } + } + } + DWORD GetSize() override { return static_cast(items.size()); } + HRESULT AddElement(InterfaceType* in) override + { + if (!in) { + return DDERR_INVALIDPARAMS; + } + in->AddRef(); + items.push_back(in); + return DD_OK; + } + HRESULT GetElement(DWORD index, InterfaceType** out) override + { + if (index >= items.size()) { + return DDERR_INVALIDPARAMS; + } + *out = static_cast(items[index]); + if (*out) { + (*out)->AddRef(); + } + return DD_OK; + } + HRESULT DeleteElement(InterfaceType* element) override + { + auto it = std::find(items.begin(), items.end(), element); + if (it == items.end()) { + return DDERR_INVALIDPARAMS; + } + + (*it)->Release(); + items.erase(it); + return DD_OK; + } + +protected: + std::vector items; +}; + +struct Direct3DRMFrameArrayImpl : public Direct3DRMArrayBase { + using Direct3DRMArrayBase::Direct3DRMArrayBase; +}; + +struct Direct3DRMLightArrayImpl : public Direct3DRMArrayBase { + using Direct3DRMArrayBase::Direct3DRMArrayBase; +}; + +struct Direct3DRMViewportArrayImpl : public Direct3DRMArrayBase { + using Direct3DRMArrayBase::Direct3DRMArrayBase; +}; + +struct Direct3DRMVisualArrayImpl : public Direct3DRMArrayBase { + using Direct3DRMArrayBase::Direct3DRMArrayBase; +}; diff --git a/miniwin/miniwin/src/include/miniwin_d3drmdevice_p.h b/miniwin/miniwin/src/include/miniwin_d3drmdevice_p.h new file mode 100644 index 00000000..7cc18e31 --- /dev/null +++ b/miniwin/miniwin/src/include/miniwin_d3drmdevice_p.h @@ -0,0 +1,38 @@ +#pragma once + +#include "miniwin_d3drm.h" +#include "miniwin_d3drmobject_p.h" + +#include + +struct Direct3DRMDevice2Impl : public Direct3DRMObjectBase { + Direct3DRMDevice2Impl(DWORD width, DWORD height, SDL_GPUDevice* device); + ~Direct3DRMDevice2Impl() override; + DWORD GetWidth() override; + DWORD GetHeight() override; + HRESULT SetBufferCount(int count) override; + HRESULT GetBufferCount() override; + HRESULT SetShades(DWORD shadeCount) override; + HRESULT GetShades() override; + HRESULT SetQuality(D3DRMRENDERQUALITY quality) override; + D3DRMRENDERQUALITY GetQuality() override; + HRESULT SetDither(int dither) override; + HRESULT GetDither() override; + HRESULT SetTextureQuality(D3DRMTEXTUREQUALITY quality) override; + D3DRMTEXTUREQUALITY GetTextureQuality() override; + HRESULT SetRenderMode(D3DRMRENDERMODE mode) override; + D3DRMRENDERMODE GetRenderMode() override; + /** + * @brief Recalculating light positions, animation updates, etc. + */ + HRESULT Update() override; + HRESULT AddViewport(IDirect3DRMViewport* viewport) override; + HRESULT GetViewports(IDirect3DRMViewportArray** ppViewportArray) override; + + SDL_GPUDevice* m_device; + +private: + DWORD m_width; + DWORD m_height; + IDirect3DRMViewportArray* m_viewports; +}; diff --git a/miniwin/miniwin/src/include/miniwin_d3drmobject_p.h b/miniwin/miniwin/src/include/miniwin_d3drmobject_p.h new file mode 100644 index 00000000..a441fbf7 --- /dev/null +++ b/miniwin/miniwin/src/include/miniwin_d3drmobject_p.h @@ -0,0 +1,70 @@ +#pragma once + +#include "miniwin_d3drm.h" + +#include +#include + +template +struct Direct3DRMObjectBase : public T { + ULONG Release() override + { + if (IUnknown::m_refCount == 1) { + for (auto it = m_callbacks.cbegin(); it != m_callbacks.cend(); it++) { + it->first(this, it->second); + } + } + SDL_free(m_name); + return this->T::Release(); + } + HRESULT AddDestroyCallback(D3DRMOBJECTCALLBACK callback, void* arg) override + { + m_callbacks.push_back(std::make_pair(callback, arg)); + return D3DRM_OK; + } + HRESULT DeleteDestroyCallback(D3DRMOBJECTCALLBACK callback, void* arg) override + { + for (auto it = m_callbacks.cbegin(); it != m_callbacks.cend(); it++) { + if (it->first == callback && it->second == arg) { + m_callbacks.erase(it); + return D3DRM_OK; + } + } + return D3DRMERR_NOTFOUND; + } + HRESULT SetAppData(LPD3DRM_APPDATA appData) override + { + m_appData = appData; + return D3DRM_OK; + } + LPVOID GetAppData() override { return m_appData; } + HRESULT SetName(const char* name) override + { + SDL_free(m_name); + m_name = NULL; + if (name) { + m_name = SDL_strdup(name); + } + return D3DRM_OK; + } + HRESULT GetName(DWORD* size, char* name) override + { + if (!size) { + return DDERR_INVALIDPARAMS; + } + const char* s = m_name ? m_name : ""; + size_t l = SDL_strlen(s); + if (name) { + SDL_strlcpy(name, s, *size); + } + else { + *size = l + 1; + } + return D3DRM_OK; + } + +private: + std::vector> m_callbacks; + LPD3DRM_APPDATA m_appData = nullptr; + char* m_name = nullptr; +}; diff --git a/miniwin/miniwin/src/include/miniwin_d3drmviewport_p.h b/miniwin/miniwin/src/include/miniwin_d3drmviewport_p.h new file mode 100644 index 00000000..79ec7b38 --- /dev/null +++ b/miniwin/miniwin/src/include/miniwin_d3drmviewport_p.h @@ -0,0 +1,56 @@ +#pragma once + +#include "miniwin_d3drm.h" +#include "miniwin_d3drmdevice_p.h" +#include "miniwin_d3drmobject_p.h" + +#include + +struct Direct3DRMViewportImpl : public Direct3DRMObjectBase { + Direct3DRMViewportImpl( + DWORD width, + DWORD height, + SDL_GPUDevice* device, + SDL_GPUTexture* transferTexture, + SDL_GPUTransferBuffer* downloadTransferBuffer, + SDL_GPUGraphicsPipeline* pipeline + ); + ~Direct3DRMViewportImpl() override; + HRESULT Render(IDirect3DRMFrame* group) override; + /** + * @brief Blit the render back to our backbuffer + */ + HRESULT ForceUpdate(int x, int y, int w, int h) override; + HRESULT Clear() override; + HRESULT SetCamera(IDirect3DRMFrame* camera) override; + HRESULT GetCamera(IDirect3DRMFrame** camera) override; + HRESULT SetProjection(D3DRMPROJECTIONTYPE type) override; + D3DRMPROJECTIONTYPE GetProjection() override; + HRESULT SetFront(D3DVALUE z) override; + D3DVALUE GetFront() override; + HRESULT SetBack(D3DVALUE z) override; + D3DVALUE GetBack() override; + HRESULT SetField(D3DVALUE field) override; + D3DVALUE GetField() override; + DWORD GetWidth() override; + DWORD GetHeight() override; + HRESULT Transform(D3DRMVECTOR4D* screen, D3DVECTOR* world) override; + HRESULT InverseTransform(D3DVECTOR* world, D3DRMVECTOR4D* screen) override; + HRESULT Pick(float x, float y, LPDIRECT3DRMPICKEDARRAY* pickedArray) override; + void CloseDevice(); + void Update(); + +private: + void FreeDeviceResources(); + int m_vertexCount; + bool m_updated = false; + DWORD m_width; + DWORD m_height; + IDirect3DRMFrame* m_camera = nullptr; + SDL_GPUDevice* m_device; + SDL_GPUGraphicsPipeline* m_pipeline; + SDL_GPUTexture* m_transferTexture; + SDL_GPUTransferBuffer* m_downloadTransferBuffer; + SDL_GPUBuffer* m_vertexBuffer; + SDL_Surface* m_renderedImage = nullptr; +}; diff --git a/miniwin/miniwin/src/miniwin_d3drm.cpp b/miniwin/miniwin/src/miniwin_d3drm.cpp index 6bd62a08..b19c92ee 100644 --- a/miniwin/miniwin/src/miniwin_d3drm.cpp +++ b/miniwin/miniwin/src/miniwin_d3drm.cpp @@ -1,75 +1,12 @@ #include "miniwin_d3drm.h" +#include "ShaderIndex.h" +#include "miniwin_d3drm_p.h" +#include "miniwin_d3drmobject_p.h" +#include "miniwin_d3drmviewport_p.h" #include "miniwin_ddsurface_p.h" #include -#include -#include -#include - -template -class Direct3DRMArrayBase : public ArrayInterface { -public: - ~Direct3DRMArrayBase() override - { - for (auto* item : items) { - if (item) { - item->Release(); - } - } - } - DWORD GetSize() override { return static_cast(items.size()); } - HRESULT AddElement(InterfaceType* in) override - { - if (!in) { - return DDERR_INVALIDPARAMS; - } - in->AddRef(); - items.push_back(in); - return DD_OK; - } - HRESULT GetElement(DWORD index, InterfaceType** out) override - { - if (index >= items.size()) { - return DDERR_INVALIDPARAMS; - } - *out = static_cast(items[index]); - if (*out) { - (*out)->AddRef(); - } - return DD_OK; - } - HRESULT DeleteElement(InterfaceType* element) override - { - auto it = std::find(items.begin(), items.end(), element); - if (it == items.end()) { - return DDERR_INVALIDPARAMS; - } - - (*it)->Release(); - items.erase(it); - return DD_OK; - } - -protected: - std::vector items; -}; - -struct Direct3DRMFrameArrayImpl : public Direct3DRMArrayBase { - using Direct3DRMArrayBase::Direct3DRMArrayBase; -}; - -struct Direct3DRMLightArrayImpl : public Direct3DRMArrayBase { - using Direct3DRMArrayBase::Direct3DRMArrayBase; -}; - -struct Direct3DRMViewportArrayImpl : public Direct3DRMArrayBase { - using Direct3DRMArrayBase::Direct3DRMArrayBase; -}; - -struct Direct3DRMVisualArrayImpl : public Direct3DRMArrayBase { - using Direct3DRMArrayBase::Direct3DRMArrayBase; -}; struct PickRecord { IDirect3DRMVisual* visual; @@ -124,69 +61,6 @@ struct Direct3DRMWinDeviceImpl : public IDirect3DRMWinDevice { void HandlePaint(void* p_dc) override {} }; -template -struct Direct3DRMObjectBase : public T { - ULONG Release() override - { - if (IUnknown::m_refCount == 1) { - for (auto it = m_callbacks.cbegin(); it != m_callbacks.cend(); it++) { - it->first(this, it->second); - } - } - return this->T::Release(); - } - HRESULT AddDestroyCallback(D3DRMOBJECTCALLBACK callback, void* arg) override - { - m_callbacks.push_back(std::make_pair(callback, arg)); - return D3DRM_OK; - } - HRESULT DeleteDestroyCallback(D3DRMOBJECTCALLBACK callback, void* arg) override - { - for (auto it = m_callbacks.cbegin(); it != m_callbacks.cend(); it++) { - if (it->first == callback && it->second == arg) { - m_callbacks.erase(it); - return D3DRM_OK; - } - } - return D3DRMERR_NOTFOUND; - } - HRESULT SetAppData(LPD3DRM_APPDATA appData) override - { - m_appData = appData; - return D3DRM_OK; - } - LPVOID GetAppData() override { return m_appData; } - HRESULT SetName(const char* name) override - { - SDL_free(m_name); - m_name = NULL; - if (name) { - m_name = SDL_strdup(name); - } - return D3DRM_OK; - } - HRESULT GetName(DWORD* size, char* name) override - { - if (!size) { - return DDERR_INVALIDPARAMS; - } - const char* s = m_name ? m_name : ""; - size_t l = SDL_strlen(s); - if (name) { - SDL_strlcpy(name, s, *size); - } - else { - *size = l + 1; - } - return D3DRM_OK; - } - -private: - std::vector> m_callbacks; - LPD3DRM_APPDATA m_appData = nullptr; - char* m_name = nullptr; -}; - struct Direct3DRMMeshImpl : public Direct3DRMObjectBase { HRESULT Clone(int flags, GUID iid, void** object) override { @@ -205,11 +79,11 @@ struct Direct3DRMMeshImpl : public Direct3DRMObjectBase { } HRESULT GetGroup( int groupIndex, - unsigned int* vertexCount, - unsigned int* faceCount, - unsigned int* vertexPerFace, + DWORD* vertexCount, + DWORD* faceCount, + DWORD* vertexPerFace, DWORD* dataSize, - unsigned int* data + DWORD* data ) override { return DD_OK; @@ -257,39 +131,6 @@ struct Direct3DRMTextureImpl : public Direct3DRMObjectBase HRESULT Changed(BOOL pixels, BOOL palette) override { return DD_OK; } }; -struct Direct3DRMDevice2Impl : public Direct3DRMObjectBase { - Direct3DRMDevice2Impl() - { - m_viewports = new Direct3DRMViewportArrayImpl; - m_viewports->AddRef(); - } - ~Direct3DRMDevice2Impl() override { m_viewports->Release(); } - unsigned int GetWidth() override { return 640; } - unsigned int GetHeight() override { return 480; } - HRESULT SetBufferCount(int count) override { return DD_OK; } - HRESULT GetBufferCount() override { return DD_OK; } - HRESULT SetShades(unsigned int shadeCount) override { return DD_OK; } - HRESULT GetShades() override { return DD_OK; } - HRESULT SetQuality(D3DRMRENDERQUALITY quality) override { return DD_OK; } - D3DRMRENDERQUALITY GetQuality() override { return D3DRMRENDERQUALITY::GOURAUD; } - HRESULT SetDither(int dither) override { return DD_OK; } - HRESULT GetDither() override { return DD_OK; } - HRESULT SetTextureQuality(D3DRMTEXTUREQUALITY quality) override { return DD_OK; } - D3DRMTEXTUREQUALITY GetTextureQuality() override { return D3DRMTEXTUREQUALITY::LINEAR; } - HRESULT SetRenderMode(D3DRMRENDERMODE mode) override { return DD_OK; } - D3DRMRENDERMODE GetRenderMode() override { return D3DRMRENDERMODE::BLENDEDTRANSPARENCY; } - HRESULT Update() override { return DD_OK; } - HRESULT AddViewport(IDirect3DRMViewport* viewport) override { return m_viewports->AddElement(viewport); } - HRESULT GetViewports(IDirect3DRMViewportArray** ppViewportArray) override - { - *ppViewportArray = m_viewports; - return DD_OK; - } - -private: - IDirect3DRMViewportArray* m_viewports; -}; - struct Direct3DRMFrameImpl : public Direct3DRMObjectBase { Direct3DRMFrameImpl() { @@ -369,44 +210,76 @@ struct Direct3DRMFrameImpl : public Direct3DRMObjectBase { IDirect3DRMTexture* m_texture = nullptr; }; -struct Direct3DRMViewportImpl : public Direct3DRMObjectBase { - HRESULT Render(IDirect3DRMFrame* group) override { return DD_OK; } - HRESULT ForceUpdate(int x, int y, int w, int h) override { return DD_OK; } - HRESULT Clear() override { return DD_OK; } - HRESULT SetCamera(IDirect3DRMFrame* camera) override - { - m_camera = camera; - return DD_OK; - } - HRESULT GetCamera(IDirect3DRMFrame** camera) override - { - *camera = m_camera; - return DD_OK; - } - HRESULT SetProjection(D3DRMPROJECTIONTYPE type) override { return DD_OK; } - D3DRMPROJECTIONTYPE GetProjection() override { return D3DRMPROJECTIONTYPE::PERSPECTIVE; } - HRESULT SetFront(D3DVALUE z) override { return DD_OK; } - D3DVALUE GetFront() override { return 0; } - HRESULT SetBack(D3DVALUE z) override { return DD_OK; } - D3DVALUE GetBack() override { return 0; } - HRESULT SetField(D3DVALUE field) override { return DD_OK; } - D3DVALUE GetField() override { return 0; } - int GetWidth() override { return 640; } - int GetHeight() override { return 480; } - HRESULT Transform(D3DRMVECTOR4D* screen, D3DVECTOR* world) override { return DD_OK; } - HRESULT InverseTransform(D3DVECTOR* world, D3DRMVECTOR4D* screen) override { return DD_OK; } - HRESULT Pick(float x, float y, LPDIRECT3DRMPICKEDARRAY* pickedArray) override { return DD_OK; } - -private: - IDirect3DRMFrame* m_camera = nullptr; -}; - struct Direct3DRMLightImpl : public Direct3DRMObjectBase { HRESULT SetColorRGB(float r, float g, float b) override { return DD_OK; } }; struct Direct3DRMMaterialImpl : public Direct3DRMObjectBase {}; +SDL_GPUGraphicsPipeline* InitializeGraphicsPipeline(SDL_GPUDevice* device) +{ + const SDL_GPUShaderCreateInfo* vertexCreateInfo = + GetVertexShaderCode(VertexShaderId::PositionColor, SDL_GetGPUShaderFormats(device)); + if (!vertexCreateInfo) { + return nullptr; + } + SDL_GPUShader* vertexShader = SDL_CreateGPUShader(device, vertexCreateInfo); + if (!vertexShader) { + return nullptr; + } + + const SDL_GPUShaderCreateInfo* fragmentCreateInfo = + GetFragmentShaderCode(FragmentShaderId::SolidColor, SDL_GetGPUShaderFormats(device)); + if (!fragmentCreateInfo) { + return nullptr; + } + SDL_GPUShader* fragmentShader = SDL_CreateGPUShader(device, fragmentCreateInfo); + if (!fragmentShader) { + return nullptr; + } + + SDL_GPUVertexBufferDescription vertexBufferDescs[1] = {}; + vertexBufferDescs[0].slot = 0; + vertexBufferDescs[0].pitch = sizeof(PositionColorVertex); + vertexBufferDescs[0].input_rate = SDL_GPU_VERTEXINPUTRATE_VERTEX; + vertexBufferDescs[0].instance_step_rate = 0; + + SDL_GPUVertexAttribute vertexAttrs[2] = {}; + vertexAttrs[0].location = 0; + vertexAttrs[0].buffer_slot = 0; + vertexAttrs[0].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3; + vertexAttrs[0].offset = 0; + + vertexAttrs[1].location = 1; + vertexAttrs[1].buffer_slot = 0; + vertexAttrs[1].format = SDL_GPU_VERTEXELEMENTFORMAT_UBYTE4_NORM; + vertexAttrs[1].offset = sizeof(float) * 3; + + SDL_GPUVertexInputState vertexInputState = {}; + vertexInputState.vertex_buffer_descriptions = vertexBufferDescs; + vertexInputState.num_vertex_buffers = 1; + vertexInputState.vertex_attributes = vertexAttrs; + vertexInputState.num_vertex_attributes = 2; + + SDL_GPUColorTargetDescription colorTargets = {}; + colorTargets.format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB; + + SDL_GPUGraphicsPipelineCreateInfo pipelineCreateInfo = {}; + pipelineCreateInfo.vertex_shader = vertexShader; + pipelineCreateInfo.fragment_shader = fragmentShader; + pipelineCreateInfo.vertex_input_state = vertexInputState; + pipelineCreateInfo.primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST; + pipelineCreateInfo.target_info.color_target_descriptions = &colorTargets; + pipelineCreateInfo.target_info.num_color_targets = 1; + + SDL_GPUGraphicsPipeline* pipeline = SDL_CreateGPUGraphicsPipeline(device, &pipelineCreateInfo); + // Clean up shader resources + SDL_ReleaseGPUShader(device, vertexShader); + SDL_ReleaseGPUShader(device, fragmentShader); + + return pipeline; +} + struct Direct3DRMImpl : virtual public IDirect3DRM2 { // IUnknown interface HRESULT QueryInterface(const GUID& riid, void** ppvObject) override @@ -416,15 +289,34 @@ struct Direct3DRMImpl : virtual public IDirect3DRM2 { *ppvObject = static_cast(this); return DD_OK; } - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "DirectDrawImpl does not implement guid"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Direct3DRMImpl does not implement guid"); return E_NOINTERFACE; } // IDirect3DRM interface + HRESULT CreateDevice(IDirect3DRMDevice2** outDevice, DWORD width, DWORD height) + { + SDL_GPUDevice* device = SDL_CreateGPUDevice( + SDL_GPU_SHADERFORMAT_SPIRV | SDL_GPU_SHADERFORMAT_DXIL | SDL_GPU_SHADERFORMAT_MSL, + true, + NULL + ); + if (device == NULL) { + return DDERR_GENERIC; + } + if (DDWindow == NULL) { + return DDERR_GENERIC; + } + if (!SDL_ClaimWindowForGPUDevice(device, DDWindow)) { + return DDERR_GENERIC; + } + + *outDevice = static_cast(new Direct3DRMDevice2Impl(width, height, device)); + return DD_OK; + } HRESULT CreateDeviceFromD3D(const IDirect3D2* d3d, IDirect3DDevice2* d3dDevice, IDirect3DRMDevice2** outDevice) override { - *outDevice = static_cast(new Direct3DRMDevice2Impl); - return DD_OK; + return CreateDevice(outDevice, 640, 480); } HRESULT CreateDeviceFromSurface( const GUID* guid, @@ -433,8 +325,10 @@ struct Direct3DRMImpl : virtual public IDirect3DRM2 { IDirect3DRMDevice2** outDevice ) override { - *outDevice = static_cast(new Direct3DRMDevice2Impl); - return DD_OK; + DDSURFACEDESC DDSDesc; + DDSDesc.dwSize = sizeof(DDSURFACEDESC); + surface->GetSurfaceDesc(&DDSDesc); + return CreateDevice(outDevice, DDSDesc.dwWidth, DDSDesc.dwHeight); } HRESULT CreateTexture(D3DRMIMAGE* image, IDirect3DRMTexture2** outTexture) override { @@ -449,7 +343,7 @@ struct Direct3DRMImpl : virtual public IDirect3DRM2 { HRESULT CreateMesh(IDirect3DRMMesh** outMesh) override { *outMesh = static_cast(new Direct3DRMMeshImpl); - return DDERR_GENERIC; + return DD_OK; } HRESULT CreateMaterial(D3DVAL power, IDirect3DRMMaterial** outMaterial) override { @@ -467,7 +361,7 @@ struct Direct3DRMImpl : virtual public IDirect3DRM2 { return DD_OK; } HRESULT CreateViewport( - IDirect3DRMDevice2* device, + IDirect3DRMDevice2* iDevice, IDirect3DRMFrame* camera, int x, int y, @@ -476,12 +370,49 @@ struct Direct3DRMImpl : virtual public IDirect3DRM2 { IDirect3DRMViewport** outViewport ) override { - *outViewport = static_cast(new Direct3DRMViewportImpl); + auto device = static_cast(iDevice); + + SDL_GPUGraphicsPipeline* pipeline = InitializeGraphicsPipeline(device->m_device); + if (!pipeline) { + return DDERR_GENERIC; + } + + SDL_GPUTextureCreateInfo textureInfo = {}; + textureInfo.type = SDL_GPU_TEXTURETYPE_2D; + textureInfo.format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB; + textureInfo.width = width; + textureInfo.height = height; + textureInfo.layer_count_or_depth = 1; + textureInfo.num_levels = 1; + textureInfo.usage = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET; + SDL_GPUTexture* transferTexture = SDL_CreateGPUTexture(device->m_device, &textureInfo); + if (transferTexture == NULL) { + return DDERR_GENERIC; + } + + // Setup texture GPU-to-CPU transfer + SDL_GPUTransferBufferCreateInfo downloadTransferInfo = {}; + downloadTransferInfo.usage = SDL_GPU_TRANSFERBUFFERUSAGE_DOWNLOAD; + downloadTransferInfo.size = static_cast(width * height * 4); + SDL_GPUTransferBuffer* downloadTransferBuffer = + SDL_CreateGPUTransferBuffer(device->m_device, &downloadTransferInfo); + if (!downloadTransferBuffer) { + return DDERR_GENERIC; + } + + *outViewport = static_cast(new Direct3DRMViewportImpl( + width, + height, + device->m_device, + transferTexture, + downloadTransferBuffer, + pipeline + )); device->AddViewport(*outViewport); return DD_OK; } - HRESULT SetDefaultTextureShades(unsigned int count) override { return DD_OK; } - HRESULT SetDefaultTextureColors(unsigned int count) override { return DD_OK; } + HRESULT SetDefaultTextureShades(DWORD count) override { return DD_OK; } + HRESULT SetDefaultTextureColors(DWORD count) override { return DD_OK; } }; HRESULT WINAPI Direct3DRMCreate(IDirect3DRM** direct3DRM) diff --git a/miniwin/miniwin/src/miniwin_d3drmdevice.cpp b/miniwin/miniwin/src/miniwin_d3drmdevice.cpp new file mode 100644 index 00000000..f45cec28 --- /dev/null +++ b/miniwin/miniwin/src/miniwin_d3drmdevice.cpp @@ -0,0 +1,117 @@ +#include "miniwin_d3drm.h" +#include "miniwin_d3drm_p.h" +#include "miniwin_d3drmobject_p.h" +#include "miniwin_d3drmviewport_p.h" + +#include + +Direct3DRMDevice2Impl::Direct3DRMDevice2Impl(DWORD width, DWORD height, SDL_GPUDevice* device) + : m_width(width), m_height(height), m_device(device), m_viewports(new Direct3DRMViewportArrayImpl) +{ +} + +Direct3DRMDevice2Impl::~Direct3DRMDevice2Impl() +{ + for (int i = 0; i < m_viewports->GetSize(); i++) { + IDirect3DRMViewport* viewport; + m_viewports->GetElement(i, &viewport); + static_cast(viewport)->CloseDevice(); + viewport->Release(); + } + m_viewports->Release(); + + SDL_ReleaseWindowFromGPUDevice(m_device, DDWindow); + SDL_DestroyGPUDevice(m_device); +} + +DWORD Direct3DRMDevice2Impl::GetWidth() +{ + return m_width; +} + +DWORD Direct3DRMDevice2Impl::GetHeight() +{ + return m_height; +} + +HRESULT Direct3DRMDevice2Impl::SetBufferCount(int count) +{ + return DD_OK; +} + +HRESULT Direct3DRMDevice2Impl::GetBufferCount() +{ + return DD_OK; +} + +HRESULT Direct3DRMDevice2Impl::SetShades(DWORD shadeCount) +{ + return DD_OK; +} + +HRESULT Direct3DRMDevice2Impl::GetShades() +{ + return DD_OK; +} + +HRESULT Direct3DRMDevice2Impl::SetQuality(D3DRMRENDERQUALITY quality) +{ + return DD_OK; +} + +D3DRMRENDERQUALITY Direct3DRMDevice2Impl::GetQuality() +{ + return D3DRMRENDERQUALITY::GOURAUD; +} + +HRESULT Direct3DRMDevice2Impl::SetDither(int dither) +{ + return DD_OK; +} + +HRESULT Direct3DRMDevice2Impl::GetDither() +{ + return DD_OK; +} + +HRESULT Direct3DRMDevice2Impl::SetTextureQuality(D3DRMTEXTUREQUALITY quality) +{ + return DD_OK; +} + +D3DRMTEXTUREQUALITY Direct3DRMDevice2Impl::GetTextureQuality() +{ + return D3DRMTEXTUREQUALITY::LINEAR; +} + +HRESULT Direct3DRMDevice2Impl::SetRenderMode(D3DRMRENDERMODE mode) +{ + return DD_OK; +} + +D3DRMRENDERMODE Direct3DRMDevice2Impl::GetRenderMode() +{ + return D3DRMRENDERMODE::BLENDEDTRANSPARENCY; +} + +HRESULT Direct3DRMDevice2Impl::Update() +{ + for (int i = 0; i < m_viewports->GetSize(); i++) { + IDirect3DRMViewport* viewport; + m_viewports->GetElement(i, &viewport); + static_cast(viewport)->Update(); + } + + return DD_OK; +} + +HRESULT Direct3DRMDevice2Impl::AddViewport(IDirect3DRMViewport* viewport) +{ + return m_viewports->AddElement(viewport); +} + +HRESULT Direct3DRMDevice2Impl::GetViewports(IDirect3DRMViewportArray** ppViewportArray) +{ + *ppViewportArray = m_viewports; + return DD_OK; +} diff --git a/miniwin/miniwin/src/miniwin_d3drmviewport.cpp b/miniwin/miniwin/src/miniwin_d3drmviewport.cpp new file mode 100644 index 00000000..a8b3bbeb --- /dev/null +++ b/miniwin/miniwin/src/miniwin_d3drmviewport.cpp @@ -0,0 +1,267 @@ +#include "miniwin_d3drm_p.h" +#include "miniwin_d3drmviewport_p.h" + +#include + +Direct3DRMViewportImpl::Direct3DRMViewportImpl( + DWORD width, + DWORD height, + SDL_GPUDevice* device, + SDL_GPUTexture* transferTexture, + SDL_GPUTransferBuffer* downloadTransferBuffer, + SDL_GPUGraphicsPipeline* pipeline +) + : m_width(width), m_height(height), m_device(device), m_transferTexture(transferTexture), + m_downloadTransferBuffer(downloadTransferBuffer), m_pipeline(pipeline) +{ +} + +void Direct3DRMViewportImpl::FreeDeviceResources() +{ + SDL_ReleaseGPUBuffer(m_device, m_vertexBuffer); + SDL_ReleaseGPUGraphicsPipeline(m_device, m_pipeline); +} + +Direct3DRMViewportImpl::~Direct3DRMViewportImpl() +{ + FreeDeviceResources(); +} + +void Direct3DRMViewportImpl::Update() +{ + m_vertexCount = 3; + + SDL_GPUBufferCreateInfo bufferCreateInfo = {}; + bufferCreateInfo.usage = SDL_GPU_BUFFERUSAGE_VERTEX; + bufferCreateInfo.size = static_cast(sizeof(PositionColorVertex) * m_vertexCount); + + m_vertexBuffer = SDL_CreateGPUBuffer(m_device, &bufferCreateInfo); + + SDL_GPUTransferBufferCreateInfo transferCreateInfo = {}; + transferCreateInfo.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD; + transferCreateInfo.size = static_cast(sizeof(PositionColorVertex) * m_vertexCount); + + SDL_GPUTransferBuffer* transferBuffer = SDL_CreateGPUTransferBuffer(m_device, &transferCreateInfo); + + PositionColorVertex* transferData = + (PositionColorVertex*) SDL_MapGPUTransferBuffer(m_device, transferBuffer, false); + + transferData[0] = {-1, -1, 0, 255, 0, 0, 255}; + transferData[1] = {1, -1, 0, 0, 0, 255, 255}; + transferData[2] = {0, 1, 0, 0, 255, 0, 128}; + + SDL_UnmapGPUTransferBuffer(m_device, transferBuffer); + + // Upload the transfer data to the vertex buffer + SDL_GPUCommandBuffer* uploadCmdBuf = SDL_AcquireGPUCommandBuffer(m_device); + SDL_GPUCopyPass* copyPass = SDL_BeginGPUCopyPass(uploadCmdBuf); + SDL_GPUTransferBufferLocation transferLocation = {}; + transferLocation.transfer_buffer = transferBuffer; + transferLocation.offset = 0; + + SDL_GPUBufferRegion bufferRegion = {}; + bufferRegion.buffer = m_vertexBuffer; + bufferRegion.offset = 0; + bufferRegion.size = static_cast(sizeof(PositionColorVertex) * m_vertexCount); + + SDL_UploadToGPUBuffer(copyPass, &transferLocation, &bufferRegion, false); + + SDL_EndGPUCopyPass(copyPass); + SDL_SubmitGPUCommandBuffer(uploadCmdBuf); + SDL_ReleaseGPUTransferBuffer(m_device, transferBuffer); + + m_updated = true; +} + +HRESULT Direct3DRMViewportImpl::Render(IDirect3DRMFrame* group) +{ + if (!m_updated) { + return DDERR_GENERIC; + } + + if (!m_device) { + return DDERR_GENERIC; + } + + SDL_GPUCommandBuffer* cmdbuf = SDL_AcquireGPUCommandBuffer(m_device); + if (cmdbuf == NULL) { + return DDERR_GENERIC; + } + + // Render the graphics + SDL_GPUColorTargetInfo colorTargetInfo = {}; + colorTargetInfo.texture = m_transferTexture; + // Make the render target transparent so we can combine it with the back buffer + colorTargetInfo.clear_color = {0, 0, 0, 0}; + colorTargetInfo.load_op = SDL_GPU_LOADOP_CLEAR; + SDL_GPURenderPass* renderPass = SDL_BeginGPURenderPass(cmdbuf, &colorTargetInfo, 1, NULL); + SDL_BindGPUGraphicsPipeline(renderPass, m_pipeline); + SDL_GPUBufferBinding vertexBufferBinding = {}; + vertexBufferBinding.buffer = m_vertexBuffer; + vertexBufferBinding.offset = 0; + SDL_BindGPUVertexBuffers(renderPass, 0, &vertexBufferBinding, 1); + SDL_DrawGPUPrimitives(renderPass, m_vertexCount, 1, 0, 0); + SDL_EndGPURenderPass(renderPass); + + // Download rendered image + SDL_GPUCopyPass* copyPass = SDL_BeginGPUCopyPass(cmdbuf); + SDL_GPUTextureRegion region = {}; + region.texture = m_transferTexture; + region.w = DDBackBuffer->w; + region.h = DDBackBuffer->h; + region.d = 1; + SDL_GPUTextureTransferInfo transferInfo = {}; + transferInfo.transfer_buffer = m_downloadTransferBuffer; + transferInfo.offset = 0; + SDL_DownloadFromGPUTexture(copyPass, ®ion, &transferInfo); + SDL_EndGPUCopyPass(copyPass); + SDL_GPUFence* fence = SDL_SubmitGPUCommandBufferAndAcquireFence(cmdbuf); + if (!cmdbuf || !SDL_WaitForGPUFences(m_device, true, &fence, 1)) { + return DDERR_GENERIC; + } + SDL_ReleaseGPUFence(m_device, fence); + void* downloadedData = SDL_MapGPUTransferBuffer(m_device, m_downloadTransferBuffer, false); + if (!downloadedData) { + return DDERR_GENERIC; + } + + m_updated = false; + + SDL_DestroySurface(m_renderedImage); + m_renderedImage = SDL_CreateSurfaceFrom( + DDBackBuffer->w, + DDBackBuffer->h, + SDL_PIXELFORMAT_ABGR8888, + downloadedData, + DDBackBuffer->w * 4 + ); + + SDL_Surface* convertedRender = SDL_ConvertSurface(m_renderedImage, SDL_PIXELFORMAT_RGBA8888); + SDL_DestroySurface(m_renderedImage); + SDL_UnmapGPUTransferBuffer(m_device, m_downloadTransferBuffer); + m_renderedImage = convertedRender; + + return ForceUpdate(0, 0, DDBackBuffer->w, DDBackBuffer->h); +} + +HRESULT Direct3DRMViewportImpl::ForceUpdate(int x, int y, int w, int h) +{ + if (!m_renderedImage) { + return DDERR_GENERIC; + } + // Blit the render back to our backbuffer + SDL_Rect srcRect{0, 0, DDBackBuffer->w, DDBackBuffer->h}; + + const SDL_PixelFormatDetails* details = SDL_GetPixelFormatDetails(DDBackBuffer->format); + if (details->Amask != 0) { + // Backbuffer supports transparnacy + SDL_Surface* convertedRender = SDL_ConvertSurface(m_renderedImage, DDBackBuffer->format); + SDL_DestroySurface(m_renderedImage); + m_renderedImage = convertedRender; + return DD_OK; + } + + if (m_renderedImage->format == DDBackBuffer->format) { + // No conversion needed + SDL_BlitSurface(m_renderedImage, &srcRect, DDBackBuffer, &srcRect); + return DD_OK; + } + + // Convert backbuffer to a format that supports transparancy + SDL_Surface* tempBackbuffer = SDL_ConvertSurface(DDBackBuffer, m_renderedImage->format); + SDL_BlitSurface(m_renderedImage, &srcRect, tempBackbuffer, &srcRect); + // Then convert the result back to the backbuffer format and write it back + SDL_Surface* newBackBuffer = SDL_ConvertSurface(tempBackbuffer, DDBackBuffer->format); + SDL_DestroySurface(tempBackbuffer); + SDL_BlitSurface(newBackBuffer, &srcRect, DDBackBuffer, &srcRect); + SDL_DestroySurface(newBackBuffer); + return DD_OK; +} + +HRESULT Direct3DRMViewportImpl::Clear() +{ + return DD_OK; +} + +HRESULT Direct3DRMViewportImpl::SetCamera(IDirect3DRMFrame* camera) +{ + m_camera = camera; + return DD_OK; +} + +HRESULT Direct3DRMViewportImpl::GetCamera(IDirect3DRMFrame** camera) +{ + *camera = m_camera; + return DD_OK; +} + +HRESULT Direct3DRMViewportImpl::SetProjection(D3DRMPROJECTIONTYPE type) +{ + return DD_OK; +} + +D3DRMPROJECTIONTYPE Direct3DRMViewportImpl::GetProjection() +{ + return D3DRMPROJECTIONTYPE::PERSPECTIVE; +} + +HRESULT Direct3DRMViewportImpl::SetFront(D3DVALUE z) +{ + return DD_OK; +} + +D3DVALUE Direct3DRMViewportImpl::GetFront() +{ + return 0; +} + +HRESULT Direct3DRMViewportImpl::SetBack(D3DVALUE z) +{ + return DD_OK; +} + +D3DVALUE Direct3DRMViewportImpl::GetBack() +{ + return 0; +} + +HRESULT Direct3DRMViewportImpl::SetField(D3DVALUE field) +{ + return DD_OK; +} + +D3DVALUE Direct3DRMViewportImpl::GetField() +{ + return 0; +} + +DWORD Direct3DRMViewportImpl::GetWidth() +{ + return m_width; +} + +DWORD Direct3DRMViewportImpl::GetHeight() +{ + return m_height; +} + +HRESULT Direct3DRMViewportImpl::Transform(D3DRMVECTOR4D* screen, D3DVECTOR* world) +{ + return DD_OK; +} + +HRESULT Direct3DRMViewportImpl::InverseTransform(D3DVECTOR* world, D3DRMVECTOR4D* screen) +{ + return DD_OK; +} + +HRESULT Direct3DRMViewportImpl::Pick(float x, float y, LPDIRECT3DRMPICKEDARRAY* pickedArray) +{ + return DD_OK; +} + +void Direct3DRMViewportImpl::CloseDevice() +{ + FreeDeviceResources(); + m_device = nullptr; +} diff --git a/miniwin/miniwin/src/miniwin_ddraw.cpp b/miniwin/miniwin/src/miniwin_ddraw.cpp index ad23266f..05a94d13 100644 --- a/miniwin/miniwin/src/miniwin_ddraw.cpp +++ b/miniwin/miniwin/src/miniwin_ddraw.cpp @@ -12,6 +12,7 @@ #include SDL_Window* DDWindow; +SDL_Surface* DDBackBuffer; HRESULT DirectDrawImpl::QueryInterface(const GUID& riid, void** ppvObject) { @@ -89,10 +90,14 @@ HRESULT DirectDrawImpl::CreateSurface( if ((lpDDSurfaceDesc->dwFlags & DDSD_BACKBUFFERCOUNT) == DDSD_BACKBUFFERCOUNT) { SDL_Log("Todo: Switch to %d buffering", lpDDSurfaceDesc->dwBackBufferCount); } + SDL_Surface* windowSurface = SDL_GetWindowSurface(DDWindow); + if (!windowSurface) { + return DDERR_GENERIC; + } int width, height; SDL_GetWindowSize(DDWindow, &width, &height); bool implicitFlip = (lpDDSurfaceDesc->ddsCaps.dwCaps & DDSCAPS_FLIP) != DDSCAPS_FLIP; - auto frontBuffer = new DirectDrawSurfaceImpl(width, height, format); + auto frontBuffer = new DirectDrawSurfaceImpl(width, height, windowSurface->format); frontBuffer->SetAutoFlip(implicitFlip); *lplpDDSurface = static_cast(frontBuffer); return DD_OK; diff --git a/miniwin/miniwin/src/miniwin_ddsurface.cpp b/miniwin/miniwin/src/miniwin_ddsurface.cpp index c0cb5f5f..1c8f5a78 100644 --- a/miniwin/miniwin/src/miniwin_ddsurface.cpp +++ b/miniwin/miniwin/src/miniwin_ddsurface.cpp @@ -35,7 +35,7 @@ HRESULT DirectDrawSurfaceImpl::QueryInterface(const GUID& riid, void** ppvObject *ppvObject = static_cast(this); return S_OK; } - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "DirectDrawImpl does not implement guid"); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "DirectDrawSurfaceImpl does not implement guid"); return E_NOINTERFACE; } @@ -62,6 +62,10 @@ HRESULT DirectDrawSurfaceImpl::Blt( if (!srcSurface || !srcSurface->m_surface) { return DDERR_GENERIC; } + if (m_autoFlip) { + DDBackBuffer = srcSurface->m_surface; + return Flip(nullptr, DDFLIP_WAIT); + } SDL_Rect srcRect; if (lpSrcRect) { @@ -120,15 +124,15 @@ HRESULT DirectDrawSurfaceImpl::BltFast( HRESULT DirectDrawSurfaceImpl::Flip(LPDIRECTDRAWSURFACE lpDDSurfaceTargetOverride, DDFlipFlags dwFlags) { - if (!m_surface) { + if (!DDBackBuffer) { return DDERR_GENERIC; } SDL_Surface* windowSurface = SDL_GetWindowSurface(DDWindow); if (!windowSurface) { return DDERR_GENERIC; } - SDL_Rect srcRect{0, 0, m_surface->w, m_surface->h}; - SDL_Surface* copy = SDL_ConvertSurface(m_surface, windowSurface->format); + SDL_Rect srcRect{0, 0, DDBackBuffer->w, DDBackBuffer->h}; + SDL_Surface* copy = SDL_ConvertSurface(DDBackBuffer, windowSurface->format); SDL_BlitSurface(copy, &srcRect, windowSurface, &srcRect); SDL_DestroySurface(copy); SDL_UpdateWindowSurface(DDWindow); @@ -140,6 +144,7 @@ HRESULT DirectDrawSurfaceImpl::GetAttachedSurface(LPDDSCAPS lpDDSCaps, LPDIRECTD if ((lpDDSCaps->dwCaps & DDSCAPS_BACKBUFFER) != DDSCAPS_BACKBUFFER) { return DDERR_INVALIDPARAMS; } + DDBackBuffer = m_surface; *lplpDDAttachedSurface = static_cast(this); return DD_OK; }