Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bindless #1508

Open
2 tasks
nem0 opened this issue Aug 21, 2024 · 1 comment
Open
2 tasks

Bindless #1508

nem0 opened this issue Aug 21, 2024 · 1 comment
Assignees
Labels

Comments

@nem0
Copy link
Owner

nem0 commented Aug 21, 2024

  • dx needs sm6.6, which needs dxc, which is huge.
  • gl
@nem0 nem0 added the trivial label Aug 21, 2024
@nem0 nem0 self-assigned this Aug 21, 2024
@nem0
Copy link
Owner Author

nem0 commented Aug 22, 2024

trying to use spirv_to_dxil from mesa3D, following script extracts neccessary source code from mesa3d repo

@echo off

REM this script copy parts of mesa we use, so users don't have to clone whole mesa

REM clone mesa repository next to LumixEngine directory
REM needs python3
REM need pyyaml and mako module installed 
REM pip install pyyaml
REM pip install mako

REM call :gen
call :copySources
goto :eof

REM copy only necessary stuff from mesa repository
:copySources
	if not exist external\mesa\include mkdir external\mesa\include
	if not exist external\mesa\include\gl mkdir external\mesa\include\gl
	if not exist external\mesa\include\gles mkdir external\mesa\include\gles
	if not exist external\mesa\include\gles2 mkdir external\mesa\include\gles2
	if not exist external\mesa\include\gles3 mkdir external\mesa\include\gles3
	if not exist external\mesa\include\khr mkdir external\mesa\include\khr
	if not exist external\mesa\include\vk_video mkdir external\mesa\include\vk_video
	if not exist external\mesa\include\vulkan mkdir external\mesa\include\vulkan
	if not exist external\mesa\src\ mkdir external\mesa\src\
	if not exist external\mesa\src\c11 mkdir external\mesa\src\c11
	if not exist external\mesa\src\c11\impl mkdir external\mesa\src\c11\impl
	if not exist external\mesa\src\compiler mkdir external\mesa\src\compiler
	if not exist external\mesa\src\compiler\spirv mkdir external\mesa\src\compiler\spirv
	if not exist external\mesa\src\compiler\glsl mkdir external\mesa\src\compiler\glsl
	if not exist external\mesa\src\compiler\nir mkdir external\mesa\src\compiler\nir
	if not exist external\mesa\src\microsoft\compiler mkdir external\mes\src\microsoft\compiler
	if not exist external\mesa\src\microsoft\compiler\spirv mkdir external\mesa\src\microsoft\compiler\spirv
	if not exist external\mesa\src\microsoft\spirv_to_dxil mkdir external\mesa\src\microsoft\spirv_to_dxil
	if not exist external\mesa\src\util mkdir external\mesa\src\util
	if not exist external\mesa\src\util\blake3 mkdir external\mesa\src\util\blake3
	if not exist external\mesa\src\util\format mkdir external\mesa\src\util\format
	if not exist external\mesa\src\util\sha1 mkdir external\mesa\src\util\sha1

	copy ..\..\..\mesa\include\no_extern_c.h external\mesa\include
	copy ..\..\..\mesa\include\c99_alloca.h external\mesa\include
	copy ..\..\..\mesa\include\c99_compat.h external\mesa\include
	
	xcopy /y ..\..\..\mesa\include\gl external\mesa\include\gl
	xcopy /y ..\..\..\mesa\include\gles external\mesa\include\gles
	xcopy /y ..\..\..\mesa\include\gles2 external\mesa\include\gles2
	xcopy /y ..\..\..\mesa\include\gles3 external\mesa\include\gles3

	xcopy /y ..\..\..\mesa\include\khr external\mesa\include\khr
	
	copy ..\..\..\mesa\include\vk_video\vulkan_video_codec_av1std.h external\mesa\include\vk_video
	copy ..\..\..\mesa\include\vk_video\vulkan_video_codec_av1std_decode.h external\mesa\include\vk_video
	copy ..\..\..\mesa\include\vk_video\vulkan_video_codec_h264std.h external\mesa\include\vk_video
	copy ..\..\..\mesa\include\vk_video\vulkan_video_codec_h264std_decode.h external\mesa\include\vk_video
	copy ..\..\..\mesa\include\vk_video\vulkan_video_codec_h264std_encode.h external\mesa\include\vk_video
	copy ..\..\..\mesa\include\vk_video\vulkan_video_codec_h265std.h external\mesa\include\vk_video
	copy ..\..\..\mesa\include\vk_video\vulkan_video_codec_h265std_decode.h external\mesa\include\vk_video
	copy ..\..\..\mesa\include\vk_video\vulkan_video_codec_h265std_encode.h external\mesa\include\vk_video
	copy ..\..\..\mesa\include\vk_video\vulkan_video_codecs_common.h external\mesa\include\vk_video

	copy ..\..\..\mesa\include\vulkan\vk_platform.h external\mesa\include\vulkan
	copy ..\..\..\mesa\include\vulkan\vulkan_core.h external\mesa\include\vulkan
	copy ..\..\..\mesa\include\vulkan\vulkan.h external\mesa\include\vulkan

	copy ..\..\..\mesa\src\git_sha1.h external\mesa\src

	copy ..\..\..\mesa\src\c11\time.h external\mesa\src\c11
	copy ..\..\..\mesa\src\c11\threads.h external\mesa\src\c11

	copy ..\..\..\mesa\src\c11\impl\time.c external\mesa\src\c11\impl

	xcopy /y ..\..\..\mesa\src\microsoft\compiler\*.c external\mesa\src\microsoft\compiler
	xcopy /y ..\..\..\mesa\src\microsoft\compiler\*.h external\mesa\src\microsoft\compiler
	
	copy ..\..\..\mesa\src\compiler\builtin_types.c external\mesa\src\compiler
	copy ..\..\..\mesa\src\compiler\builtin_types.h external\mesa\src\compiler
	copy ..\..\..\mesa\src\compiler\glsl_types.c external\mesa\src\compiler
	copy ..\..\..\mesa\src\compiler\glsl_types.h external\mesa\src\compiler
	copy ..\..\..\mesa\src\compiler\shader_enums.c external\mesa\src\compiler
	copy ..\..\..\mesa\src\compiler\shader_enums.h external\mesa\src\compiler
	copy ..\..\..\mesa\src\compiler\shader_info.h external\mesa\src\compiler

	copy ..\..\..\mesa\src\compiler\glsl\list.h external\mesa\src\compiler\glsl
	
	xcopy /y ..\..\..\mesa\src\compiler\spirv\*.h external\mesa\src\compiler\spirv
	xcopy /y ..\..\..\mesa\src\compiler\spirv\*.c external\mesa\src\compiler\spirv
	
	xcopy /y ..\..\..\mesa\src\compiler\nir\*.c external\mesa\src\compiler\nir
	xcopy /y ..\..\..\mesa\src\compiler\nir\*.h external\mesa\src\compiler\nir

	xcopy /y ..\..\..\mesa\src\util\*.cpp external\mesa\src\util
	xcopy /y ..\..\..\mesa\src\util\*.c external\mesa\src\util
	xcopy /y ..\..\..\mesa\src\util\*.h external\mesa\src\util
	
	xcopy /y ..\..\..\mesa\src\util\blake3\*.c external\mesa\src\util\blake3
	xcopy /y ..\..\..\mesa\src\util\blake3\*.h external\mesa\src\util\blake3

	copy ..\..\..\mesa\src\util\sha1\sha1.c external\mesa\src\util\sha1
	copy ..\..\..\mesa\src\util\sha1\sha1.h external\mesa\src\util\sha1

	xcopy /y ..\..\..\mesa\src\util\format\*.c external\mesa\src\util\format
	xcopy /y ..\..\..\mesa\src\util\format\*.h external\mesa\src\util\format
	
	copy ..\..\..\mesa\src\microsoft\spirv_to_dxil\dxil_spirv_nir.c external\mesa\src\microsoft\spirv_to_dxil
	copy ..\..\..\mesa\src\microsoft\spirv_to_dxil\dxil_spirv_nir.h external\mesa\src\microsoft\spirv_to_dxil
	copy ..\..\..\mesa\src\microsoft\spirv_to_dxil\dxil_spirv_nir_lower_bindless.c external\mesa\src\microsoft\spirv_to_dxil
	copy ..\..\..\mesa\src\microsoft\spirv_to_dxil\spirv_to_dxil.c external\mesa\src\microsoft\spirv_to_dxil
	copy ..\..\..\mesa\src\microsoft\spirv_to_dxil\spirv_to_dxil.h external\mesa\src\microsoft\spirv_to_dxil
goto :eof

REM do necessary part of what meson does in mesa repository
REM we don't want to depend on meson, therefore this function
:gen
	pushd ..\..\..\mesa\src\
	python3 ..\bin\git_sha1_gen.py --output git_sha1.h
	popd

	pushd ..\..\..\mesa\src\util
	python3 driconf_static.py 00-mesa-defaults.conf driconf_static.h
	python3 format_srgb.py > format_srgb.c
	popd
	
	pushd ..\..\..\mesa\src\util\format
	python3 u_format_table.py u_format.yaml > u_format_table.c
	python3 u_format_table.py u_format.yaml --enums > u_format_gen.h
	python3 u_format_table.py u_format.yaml --header > u_format_pack.h
	popd

	pushd ..\..\..\mesa\src\compiler
	python3 builtin_types_c.py builtin_types.c
	python3 builtin_types_h.py builtin_types.h
	popd

	pushd ..\..\..\mesa\src\compiler\spirv
	python3 vtn_generator_ids_h.py spir-v.xml vtn_generator_ids.h
	python3 vtn_gather_types_c.py spirv.core.grammar.json vtn_gather_types.c
	popd

	pushd ..\..\..\mesa\src\compiler\nir
	python3 nir_constant_expressions.py > nir_constant_expressions.c
	python3 nir_opcodes_c.py > nir_opcodes.c
	python3 nir_opcodes_h.py > nir_opcodes.h
	python3 nir_opt_algebraic.py --out nir_opt_algebraic.c
	python3 nir_intrinsics_c.py --outdir .
	python3 nir_intrinsics_h.py --outdir .
	python3 nir_intrinsics_indices_h.py --outdir .
	python3 nir_builder_opcodes_h.py > nir_builder_opcodes.h
	popd

	pushd ..\..\..\mesa\src\compiler\spirv
	python3 spirv_info_gen.py --json spirv.core.grammar.json --out-h spirv_info.h --out-c spirv_info.c
	popd

	pushd ..\..\..\mesa\src\microsoft\compiler
	python3 dxil_nir_algebraic.py -p ..\..\compiler\nir > dxil_nir_algebraic.c
	popd

	echo generators done

goto :eof

add to genie.lua

project "spirv2dxil_cpp"
	kind "StaticLib"
	files {
		"external/mesa/src/**.cpp",
	}
	
	includedirs {
		"external/mesa/include/",
		"external/mesa/src/",
		"external/mesa/src/compiler/",
		"external/mesa/src/compiler/nir",
		"external/mesa/src/compiler/spirv",
		"external/mesa/src/microsoft/compiler",
		"external/include",
	}

	defaultConfigurations()
	removeflags { "FatalWarnings" }
	flags { "MinimumWarnings" }

project "spirv2dxil"
	kind "StaticLib"

	buildoptions { "/std:c11" }
	files {
		"mesa.bat",
		"external/mesa/src/**.c",
		"external/mesa/src/**.h",
	}

	includedirs {
		"external/mesa/include/",
		"external/mesa/src/",
		"external/mesa/src/compiler/",
		"external/mesa/src/compiler/nir",
		"external/mesa/src/compiler/spirv",
		"external/mesa/src/microsoft/compiler",
		"external/include",
	}

	removefiles {
		"external/mesa/src/compiler/spirv/spirv2nir.c",
		"external/mesa/src/util/blake3/blake3_neon.c"
	}

	links { "spirv2dxil_cpp" }

	defaultConfigurations()
	removeflags { "FatalWarnings" }
	flags { "MinimumWarnings" }
	defines {
		"HAVE_STRUCT_TIMESPEC",
		"PACKAGE_VERSION=\"0\"",
		"_CRT_SECURE_NO_WARNINGS",
		"WIN32_LEAN_AND_MEAN",
		"NO_REGEX",
		"_WINDOWS",
		"_WIN32_WINNT=0x0A00",
		"_WINVER=0x0A00",
		"PIPE_SUBSYSTEM_WINDOWS_USER",
		"_USE_MATH_DEFINES",
		"VC_EXTRALEAN",
		"_CRT_SECURE_NO_WARNINGS",
		"_CRT_SECURE_NO_DEPRECATE",
		"_SCL_SECURE_NO_WARNINGS",
		"_SCL_SECURE_NO_DEPRECATE",
		"_ALLOW_KEYWORD_MACROS",
		"_HAS_EXCEPTIONS=0",
		"NOMINMAX",
		"WINDOWS_NO_FUTEX",
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant