diff --git a/CMakeLists.txt b/CMakeLists.txt index d22f60f..d356984 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,5 @@ cmake_minimum_required(VERSION 3.12) -if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gbenchmark) - option(OMM_ENABLE_BENCHMARK "Enable benchmark" ON) -endif() - if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gtest) option(OMM_ENABLE_TESTS "Enable unit test" ON) endif() @@ -40,10 +36,6 @@ add_subdirectory(shared) add_subdirectory(omm-sdk) add_subdirectory(integration) -if (OMM_ENABLE_BENCHMARK) - add_subdirectory(benchmark) -endif() - if (OMM_ENABLE_TESTS) add_subdirectory(tests) endif() diff --git a/integration/omm-sdk-nvrhi/omm-sdk-nvrhi.cpp b/integration/omm-sdk-nvrhi/omm-sdk-nvrhi.cpp index 96df04d..1233cb4 100644 --- a/integration/omm-sdk-nvrhi/omm-sdk-nvrhi.cpp +++ b/integration/omm-sdk-nvrhi/omm-sdk-nvrhi.cpp @@ -60,6 +60,28 @@ namespace } } + static omm::TexCoordFormat GetTexCoordFormat(nvrhi::Format format) + { + switch (format) + { + case nvrhi::Format::R16_UNORM: + { + return omm::TexCoordFormat::UV16_UNORM; + } + case nvrhi::Format::R16_FLOAT: + { + return omm::TexCoordFormat::UV16_FLOAT; + } + case nvrhi::Format::R32_FLOAT: + { + return omm::TexCoordFormat::UV32_FLOAT; + } + default: + assert(false); + return omm::TexCoordFormat::UV32_FLOAT; + } + } + /// -- BINDING CACHE FROM DONUT -- /* @@ -191,6 +213,7 @@ class GpuBakeNvrhiImpl const std::vector& ommIndexHistogramBuffer, const void* indexBuffer, const uint32_t indexCount, + nvrhi::Format ommTexCoordBufferFormat, const void* texCoords, const float* imageData, const uint32_t width, @@ -346,7 +369,6 @@ void GpuBakeNvrhiImpl::InitBaker(GpuBakeNvrhi::ShaderProvider* shaderProvider) { omm::BakerCreationDesc desc; desc.type = omm::BakerType::GPU; - desc.enableValidation = true; omm::Result res = omm::CreateBaker(desc, &m_baker); assert(res == omm::Result::SUCCESS); @@ -355,7 +377,6 @@ void GpuBakeNvrhiImpl::InitBaker(GpuBakeNvrhi::ShaderProvider* shaderProvider) { omm::BakerCreationDesc desc; desc.type = omm::BakerType::CPU; - desc.enableValidation = true; omm::Result res = omm::CreateBaker(desc, &m_cpuBaker); assert(res == omm::Result::SUCCESS); @@ -644,10 +665,10 @@ omm::Gpu::DispatchConfigDesc GpuBakeNvrhiImpl::GetConfig(const GpuBakeNvrhi::Inp config.alphaTextureChannel = params.alphaTextureChannel; config.alphaMode = AlphaMode::Test; config.alphaCutoff = params.alphaCutoff; - config.texCoordFormat = TexCoordFormat::UV32_FLOAT; + config.texCoordFormat = GetTexCoordFormat(params.texCoordFormat); config.texCoordOffsetInBytes = params.texCoordBufferOffsetInBytes; config.texCoordStrideInBytes = params.texCoordStrideInBytes; - config.indexFormat = IndexFormat::I32_UINT; + config.indexFormat = IndexFormat::UINT_32; config.indexCount = (uint32_t)params.numIndices; config.globalFormat = params.format == nvrhi::rt::OpacityMicromapFormat::OC1_2_State ? Format::OC1_2_State : Format::OC1_4_State; config.maxScratchMemorySize = params.minimalMemoryMode ? Gpu::ScratchMemoryBudget::MB_4 : Gpu::ScratchMemoryBudget::MB_256; @@ -692,7 +713,7 @@ void GpuBakeNvrhiImpl::GetPreDispatchInfo(const GpuBakeNvrhi::Input& params, Gpu omm::Result res = Gpu::GetPreDispatchInfo(m_pipeline, config, &preBuildInfo); assert(res == omm::Result::SUCCESS); - info.ommIndexFormat = preBuildInfo.outOmmIndexBufferFormat == omm::IndexFormat::I16_UINT ? nvrhi::Format::R16_UINT : nvrhi::Format::R32_UINT; + info.ommIndexFormat = preBuildInfo.outOmmIndexBufferFormat == omm::IndexFormat::UINT_16 ? nvrhi::Format::R16_UINT : nvrhi::Format::R32_UINT; info.ommIndexBufferSize = preBuildInfo.outOmmIndexBufferSizeInBytes; info.ommIndexHistogramSize = preBuildInfo.outOmmIndexHistogramSizeInBytes; info.ommIndexCount = preBuildInfo.outOmmIndexCount; @@ -1101,13 +1122,14 @@ void GpuBakeNvrhiImpl::DumpDebug( const std::vector& ommIndexHistogramBuffer, const void* indexBuffer, const uint32_t indexCount, + nvrhi::Format ommTexCoordBufferFormat, const void* texCoords, const float* imageData, const uint32_t width, const uint32_t height ) { - const omm::IndexFormat ommIndexBufferFormat = indexBufferFormat == nvrhi::Format::R32_UINT ? omm::IndexFormat::I32_UINT : omm::IndexFormat::I16_UINT; + const omm::IndexFormat ommIndexBufferFormat = indexBufferFormat == nvrhi::Format::R32_UINT ? omm::IndexFormat::UINT_32 : omm::IndexFormat::UINT_16; omm::Cpu::BakeResultDesc result; result.arrayData = ommArrayBuffer.data(); @@ -1139,10 +1161,10 @@ void GpuBakeNvrhiImpl::DumpDebug( config.alphaMode = /*task.geometry->material->domain == MaterialDomain::AlphaBlended ? omm::AlphaMode::Blend : */omm::AlphaMode::Test; config.indexBuffer = indexBuffer; config.indexCount = indexCount; - config.indexFormat = omm::IndexFormat::I32_UINT; + config.indexFormat = omm::IndexFormat::UINT_32; config.texture = texHandle; config.texCoords = texCoords; - config.texCoordFormat = omm::TexCoordFormat::UV32_FLOAT; + config.texCoordFormat = GetTexCoordFormat(ommTexCoordBufferFormat); config.alphaCutoff = params.alphaCutoff; config.runtimeSamplerDesc.addressingMode = GetTextureAddressMode(params.sampleMode); config.runtimeSamplerDesc.filter = params.bilinearFilter ? omm::TextureFilterMode::Linear : omm::TextureFilterMode::Nearest; @@ -1237,6 +1259,7 @@ void GpuBakeNvrhi::DumpDebug( const std::vector& ommIndexHistogramBuffer, const void* indexBuffer, const uint32_t indexCount, + nvrhi::Format ommTexCoordBufferFormat, const void* texCoords, const float* imageData, const uint32_t width, @@ -1255,6 +1278,7 @@ void GpuBakeNvrhi::DumpDebug( ommIndexHistogramBuffer, indexBuffer, indexCount, + ommTexCoordBufferFormat, texCoords, imageData, width, diff --git a/integration/omm-sdk-nvrhi/omm-sdk-nvrhi.h b/integration/omm-sdk-nvrhi/omm-sdk-nvrhi.h index c21eaec..d6d5cde 100644 --- a/integration/omm-sdk-nvrhi/omm-sdk-nvrhi.h +++ b/integration/omm-sdk-nvrhi/omm-sdk-nvrhi.h @@ -52,6 +52,7 @@ namespace omm bool enableLevelLineIntersection = true; nvrhi::SamplerAddressMode sampleMode = nvrhi::SamplerAddressMode::Clamp; + nvrhi::Format texCoordFormat = nvrhi::Format::R32_FLOAT; nvrhi::BufferHandle texCoordBuffer; uint32_t texCoordBufferOffsetInBytes = 0; uint32_t texCoordStrideInBytes = 0; @@ -154,6 +155,7 @@ namespace omm const std::vector& ommIndexHistogramBuffer, const void* indexBuffer, const uint32_t indexCount, + nvrhi::Format ommTexCoordBufferFormat, const void* texCoords, const float* imageData, const uint32_t width, diff --git a/omm-sdk/CMakeLists.txt b/omm-sdk/CMakeLists.txt index 2ad98ba..d508c81 100644 --- a/omm-sdk/CMakeLists.txt +++ b/omm-sdk/CMakeLists.txt @@ -22,7 +22,6 @@ option(OMM_CROSSCOMPILE_AARCH64 "cross compilation for aarch64" OFF) option(OMM_CROSSCOMPILE_X86_64 "cross compilation for x86_64" OFF) option(OMM_SHADER_DEBUG_INFO "enable embedded shader debug info" OFF) option(OMM_INSTALL "Generate install rules for OMM" ON) -option(OMM_ENABLE_INTERFACE_GEN "Enable interface generation script. Only required for SDK development." OFF) if (OMM_ENABLE_OPENMP) find_package(OpenMP) @@ -109,35 +108,6 @@ if (OMM_ENABLE_PRECOMPILED_SHADERS_SPIRV) add_dependencies(${TARGET_NAME} omm-shaders-spirv) endif() -if (OMM_ENABLE_INTERFACE_GEN) - find_package(Python COMPONENTS Interpreter) - - if (Python_Interpreter_FOUND) - - add_custom_target( - GenInterfaceH ALL - COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/_interface_gen_c.py ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/omm.json - COMMENT "Generating Interface H" - ) - - add_custom_target( - GenInterfaceHPP ALL - COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/_interface_gen_cpp.py ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/omm.json - COMMENT "Generating Interface HPP" - ) - - set_property(TARGET GenInterfaceH PROPERTY FOLDER "${OMM_PROJECT_FOLDER}/CustomScripts") - set_property(TARGET GenInterfaceHPP PROPERTY FOLDER "${OMM_PROJECT_FOLDER}/CustomScripts") - - add_dependencies(${TARGET_NAME} GenInterfaceH GenInterfaceHPP) - - else() - message(WARNING "Python not found. Interface generator will be disabled.") - endif() -endif() - if (OMM_ENABLE_PRECOMPILED_SHADERS_DXIL OR OMM_ENABLE_PRECOMPILED_SHADERS_SPIRV) target_include_directories(${TARGET_NAME} PRIVATE "${OMM_SHADER_OUTPUT_PATH}") endif() diff --git a/omm-sdk/include/omm.h b/omm-sdk/include/omm.h index de8b205..95acb3c 100644 --- a/omm-sdk/include/omm.h +++ b/omm-sdk/include/omm.h @@ -15,8 +15,8 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include #define OMM_VERSION_MAJOR 1 -#define OMM_VERSION_MINOR 1 -#define OMM_VERSION_BUILD 1 +#define OMM_VERSION_MINOR 2 +#define OMM_VERSION_BUILD 0 #define OMM_MAX_TRANSIENT_POOL_BUFFERS 8 @@ -39,16 +39,34 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #endif #ifdef DEFINE_ENUM_FLAG_OPERATORS -#define OMM_DEFINE_ENUM_FLAG_OPERATORS(x) DEFINE_ENUM_FLAG_OPERATORS(x) + #define OMM_DEFINE_ENUM_FLAG_OPERATORS(x) DEFINE_ENUM_FLAG_OPERATORS(x) #else -#define OMM_DEFINE_ENUM_FLAG_OPERATORS(x) + #define OMM_DEFINE_ENUM_FLAG_OPERATORS(x) #endif +#ifndef OMM_DEPRECATED_MSG + #if defined(__has_cpp_attribute) && __has_cpp_attribute(deprecated) && !defined(__GNUC__) + #define OMM_DEPRECATED_MSG(msg) [[deprecated( msg )]] + #else + #define OMM_DEPRECATED_MSG(msg) + #endif +#endif + +typedef uint8_t ommBool; + +typedef uintptr_t ommHandle; + +typedef ommHandle ommBaker; + +typedef ommHandle ommCpuBakeResult; + +typedef ommHandle ommCpuTexture; + typedef void* (*ommAllocate)(void* userArg, size_t size, size_t alignment); + typedef void* (*ommReallocate)(void* userArg, void* memory, size_t size, size_t alignment); -typedef void (*ommFree)(void* userArg, void* memory); -typedef uint8_t ommBool; +typedef void (*ommFree)(void* userArg, void* memory); typedef enum ommResult { @@ -57,16 +75,17 @@ typedef enum ommResult ommResult_INVALID_ARGUMENT, ommResult_INSUFFICIENT_SCRATCH_MEMORY, ommResult_NOT_IMPLEMENTED, - ommResult_WORKLOAD_TOO_BIG, + ommResult_WORKLOAD_TOO_BIG OMM_DEPRECATED_MSG("ommResult_WORKLOAD_TOO_BIG has been deprecated and will no longer be returned. Enable logging to look for perf warnings instead."), ommResult_MAX_NUM, } ommResult; -typedef struct ommLibraryDesc +typedef enum ommMessageSeverity { - uint8_t versionMajor; - uint8_t versionMinor; - uint8_t versionBuild; -} ommLibraryDesc; + ommMessageSeverity_Info, + ommMessageSeverity_PerfWarning, + ommMessageSeverity_Fatal, + ommMessageSeverity_MAX_NUM, +} ommMessageSeverity; typedef enum ommOpacityState { @@ -123,8 +142,10 @@ typedef enum ommTexCoordFormat typedef enum ommIndexFormat { - ommIndexFormat_I16_UINT, - ommIndexFormat_I32_UINT, + ommIndexFormat_UINT_16, + ommIndexFormat_UINT_32, + ommIndexFormat_I16_UINT OMM_DEPRECATED_MSG("ommIndexFormat_I16_UINT is deprecated, please use ommIndexFormat_UINT_16 instead") = ommIndexFormat_UINT_16, + ommIndexFormat_I32_UINT OMM_DEPRECATED_MSG("ommIndexFormat_I32_UINT is deprecated, please use ommIndexFormat_UINT_32 instead") = ommIndexFormat_UINT_32, ommIndexFormat_MAX_NUM, } ommIndexFormat; @@ -152,6 +173,13 @@ typedef enum ommAlphaMode ommAlphaMode_MAX_NUM, } ommAlphaMode; +typedef struct ommLibraryDesc +{ + uint8_t versionMajor; + uint8_t versionMinor; + uint8_t versionBuild; +} ommLibraryDesc; + typedef struct ommSamplerDesc { ommTextureAddressMode addressingMode; @@ -170,52 +198,72 @@ inline ommSamplerDesc ommSamplerDescDefault() typedef struct ommMemoryAllocatorInterface { - ommAllocate Allocate; - ommReallocate Reallocate; - ommFree Free; - void* UserArg; + union { + ommAllocate allocate; + ommAllocate OMM_DEPRECATED_MSG("Allocate is deprecated, use allocate instead") Allocate; + }; + union { + ommReallocate reallocate; + ommReallocate OMM_DEPRECATED_MSG("Reallocate is deprecated, use reallocate instead") Reallocate; + }; + union { + ommFree free; + ommFree OMM_DEPRECATED_MSG("Free is deprecated, use free instead") Free; + }; + union { + void* userArg; + void* OMM_DEPRECATED_MSG("UserArg is deprecated, use userArg instead") UserArg; + }; } ommMemoryAllocatorInterface; inline ommMemoryAllocatorInterface ommMemoryAllocatorInterfaceDefault() { ommMemoryAllocatorInterface v; - v.Allocate = NULL; - v.Reallocate = NULL; - v.Free = NULL; - v.UserArg = NULL; + v.allocate = NULL; + v.reallocate = NULL; + v.free = NULL; + v.userArg = NULL; return v; } +typedef void(*ommMessageCallback)(ommMessageSeverity severity, const char* message, void* userArg); + +typedef struct ommMessageInterface +{ + ommMessageCallback messageCallback; + void* userArg; +} ommMessageInterface; + +inline ommMessageInterface ommMessageInterfaceDefault() +{ + ommMessageInterface v; + v.messageCallback = NULL; + v.userArg = NULL; + return v; +} + typedef struct ommBakerCreationDesc { ommBakerType type; - ommBool enableValidation; ommMemoryAllocatorInterface memoryAllocatorInterface; + ommMessageInterface messageInterface; } ommBakerCreationDesc; inline ommBakerCreationDesc ommBakerCreationDescDefault() { ommBakerCreationDesc v; v.type = ommBakerType_MAX_NUM; - v.enableValidation = 0; v.memoryAllocatorInterface = ommMemoryAllocatorInterfaceDefault(); + v.messageInterface = ommMessageInterfaceDefault(); return v; } -typedef uintptr_t ommHandle; - -typedef ommHandle ommBaker; - OMM_API ommLibraryDesc ommGetLibraryDesc(); OMM_API ommResult ommCreateBaker(const ommBakerCreationDesc* bakeCreationDesc, ommBaker* outBaker); OMM_API ommResult ommDestroyBaker(ommBaker baker); -typedef ommHandle ommCpuBakeResult; - -typedef ommHandle ommCpuTexture; - typedef enum ommCpuTextureFormat { ommCpuTextureFormat_UNORM8, @@ -258,9 +306,10 @@ typedef enum ommCpuBakeFlags // compute. Note: can not be used if DisableDuplicateDetection is set. ommCpuBakeFlags_EnableNearDuplicateDetection = 1u << 4, - // Workload validation is a safety mechanism that will let the SDK reject workloads that become unreasonably large, which - // may lead to long baking times. When this flag is set the bake operation may return error WORKLOAD_TOO_BIG + // Enable additional validation, when enabled additional processing is performed to validate quality and sanity of input data + // which may help diagnose longer than expected bake time. ommCpuBakeFlags_EnableWorkloadValidation = 1u << 5, + } ommCpuBakeFlags; OMM_DEFINE_ENUM_FLAG_OPERATORS(ommCpuBakeFlags); @@ -838,6 +887,7 @@ typedef struct ommGpuDispatchConfigDesc uint32_t alphaTextureChannel; ommTexCoordFormat texCoordFormat; uint32_t texCoordOffsetInBytes; + // texCoordStrideInBytes: If zero, packed aligment is assumed uint32_t texCoordStrideInBytes; ommIndexFormat indexFormat; // The actual number of indices can be lower. diff --git a/omm-sdk/include/omm.hpp b/omm-sdk/include/omm.hpp index d76ea8d..a39603d 100644 --- a/omm-sdk/include/omm.hpp +++ b/omm-sdk/include/omm.hpp @@ -23,15 +23,17 @@ namespace omm INVALID_ARGUMENT, INSUFFICIENT_SCRATCH_MEMORY, NOT_IMPLEMENTED, - WORKLOAD_TOO_BIG, + WORKLOAD_TOO_BIG OMM_DEPRECATED_MSG("WORKLOAD_TOO_BIG has been deprecated and will no longer be returned. Enable logging to look for perf warnings instead."), MAX_NUM, }; - struct LibraryDesc + enum class MessageSeverity { - uint8_t versionMajor; - uint8_t versionMinor; - uint8_t versionBuild; + Info, + Warning, + PerfWarning, + Fatal, + MAX_NUM, }; enum class OpacityState @@ -89,8 +91,10 @@ namespace omm enum class IndexFormat { - I16_UINT, - I32_UINT, + UINT_16, + UINT_32, + I16_UINT OMM_DEPRECATED_MSG("omm::IndexFormat::I16_UINT is deprecated, please use omm::IndexFormat::UINT_16 instead") = UINT_16, + I32_UINT OMM_DEPRECATED_MSG("omm::IndexFormat::I32_UINT is deprecated, please use omm::IndexFormat::UINT_32 instead") = UINT_32, MAX_NUM, }; @@ -118,6 +122,13 @@ namespace omm MAX_NUM, }; + struct LibraryDesc + { + uint8_t versionMajor; + uint8_t versionMinor; + uint8_t versionBuild; + }; + struct SamplerDesc { TextureAddressMode addressingMode = TextureAddressMode::MAX_NUM; @@ -127,17 +138,37 @@ namespace omm struct MemoryAllocatorInterface { - ommAllocate Allocate = nullptr; - ommReallocate Reallocate = nullptr; - ommFree Free = nullptr; - void* UserArg = nullptr; + union { + ommAllocate allocate = nullptr; + ommAllocate OMM_DEPRECATED_MSG("Allocate is deprecated, use allocate instead") Allocate; + }; + union { + ommReallocate reallocate = nullptr; + ommReallocate OMM_DEPRECATED_MSG("Reallocate is deprecated, use reallocate instead") Reallocate; + }; + union { + ommFree free = nullptr; + ommFree OMM_DEPRECATED_MSG("Free is deprecated, use free instead") Free; + }; + union { + void* userArg = nullptr; + void* OMM_DEPRECATED_MSG("UserArg is deprecated, use userArg instead") UserArg; + }; + }; + + typedef void(*MessageCallback)(MessageSeverity severity, const char* message, void* userArg); + + struct MessageInterface + { + MessageCallback messageCallback = nullptr; + void* userArg = nullptr; }; struct BakerCreationDesc { BakerType type = BakerType::MAX_NUM; - bool enableValidation = false; MemoryAllocatorInterface memoryAllocatorInterface = {}; + MessageInterface messageInterface = {}; }; using Handle = uintptr_t; @@ -199,9 +230,9 @@ namespace omm // compute. Note: can not be used if DisableDuplicateDetection is set. EnableNearDuplicateDetection = 1u << 4, - // Workload validation is a safety mechanism that will let the SDK reject workloads that become unreasonably large, which - // may lead to long baking times. When this flag is set the bake operation may return error WORKLOAD_TOO_BIG - EnableWorkloadValidation = 1u << 5, + // Enable additional validation, when enabled additional processing is performed to validate quality and sanity of input data + // which may help diagnose longer than expected bake time. + EnableWorkloadValidation = 1u << 5, }; OMM_DEFINE_ENUM_FLAG_OPERATORS(BakeFlags); @@ -705,6 +736,7 @@ namespace omm uint32_t alphaTextureChannel = 3; TexCoordFormat texCoordFormat = TexCoordFormat::MAX_NUM; uint32_t texCoordOffsetInBytes = 0; + // texCoordStrideInBytes: If zero, packed aligment is assumed uint32_t texCoordStrideInBytes = 0; IndexFormat indexFormat = IndexFormat::MAX_NUM; // The actual number of indices can be lower. diff --git a/omm-sdk/scripts/_interface_gen_c.py b/omm-sdk/scripts/_interface_gen_c.py deleted file mode 100644 index c9179e9..0000000 --- a/omm-sdk/scripts/_interface_gen_c.py +++ /dev/null @@ -1,323 +0,0 @@ -import sys -import json -import os -import textwrap - -def GetWhitespace(indent): - s = "" - for i in range(0, indent): - s = s + " " - return s - -def WriteComment(inComment, ind): - ws = GetWhitespace(ind) - comment = "" - for manualLine in inComment.splitlines(): - autoLine = textwrap.fill(manualLine, 120) - for line in autoLine.splitlines(): - print(ws + "// " + line) - -def GetNameWithPrefix(prefixLut, key, name): - if prefixLut.get(key): - return prefixLut[key] + name - return name - -def WriteEnum(dic, prefixLut, key, obj, ind): - values = obj["values"] - - ws = GetWhitespace(ind) - ws1 = GetWhitespace(ind + 1) - name = GetNameWithPrefix(prefixLut, key, obj["name"]) - - maxLen = 0 - for val in values: - tp = name + "_" + val["name"] - maxLen = max(len(tp), maxLen) - - declLine = "typedef enum " + name - print(ws + declLine) - print(ws + "{") - first = True - for val in values: - if not first and obj.get("injectNewLine") and obj["injectNewLine"]: - print("") - tp = name + "_" + val["name"] - if val.get("comment"): - WriteComment(val["comment"], ind + 1) - - if val.get("value"): - val = GetNameWithPrefix(prefixLut, val["value"], val["value"]) - args = (tp, "=", val, ",") - print(ws1 + ('{0:<' + str(maxLen + 1) + '}{1} {2}{3}').format(*args)) - else: - print(ws1 + tp + ",") - first = False - print(ws + "} " + name + ";") - if obj.get("isFlag") and obj["isFlag"]: - print(ws + "OMM_DEFINE_ENUM_FLAG_OPERATORS(" + name + ");") - -# returns everything before the member name -def GetStructMemberLHS(dic, prefixLut, val): - typeKey = val["type"] - typeName = typeKey - if dic.get(typeKey): - typeName = dic[typeKey]["name"] - - tp = GetNameWithPrefix(prefixLut, typeKey, typeName) - - if tp == "bool": - tp = "ommBool" - - lineStr = "" - if val.get("static"): - lineStr += "static " - if val.get("constexpr"): - lineStr += "constexpr " - prefix = "" - if val.get("const") and val["const"]: - prefix = "const " - postFix = "" - if val.get("ptr") and val["ptr"]: - postFix = "*" - - return prefix + tp + postFix - -def WriteStructMembers(dic, prefixLut, members, ind): - ws = GetWhitespace(ind) - - maxLen = 0 - for val in members: - lhs = GetStructMemberLHS(dic, prefixLut,val) - maxLen = max(maxLen, len(lhs)) - - for val in members: - typeKey = val["type"] - typeName = typeKey - if dic.get(typeKey): - typeName = dic[typeKey]["name"] - - tp = GetNameWithPrefix(prefixLut, typeKey, typeName) - - if tp == "bool": - tp = "ommBool" - - if val.get("comment"): - WriteComment(val["comment"], ind) - - lhs = GetStructMemberLHS(dic, prefixLut, val) - - arg = (ws, lhs, val["name"], ";") - lineStr = ('{0}{1:<' + str(maxLen + 1) + '}{2}{3}').format(*arg) - print(lineStr) - -def WriteStructMembersDefaultValue(dic, prefixLut, members, ind): - ws = GetWhitespace(ind) - - maxLen = 0 - for val in members: - maxLen = max(len(val["name"]), maxLen) - - for val in members: - if val.get("value"): - value = val["value"] - - if value == "nullptr": - value = "NULL" - if value == "true": - value = "1" - if value == "false": - value = "0" - - if isinstance(value, str): - if value == "default": - typeKey = val["type"] - typeName = typeKey - tp = GetNameWithPrefix(prefixLut, typeKey, typeName) - value = tp + "Default()" - - args = ("v." + val["name"], " = ", value + ";") - lineStr = ('{0:<' + str(maxLen + 3) + '}{1}{2}').format(*args) - print(ws + lineStr) - elif value.get("type"): - typeKey = val["type"] - typeName = typeKey - if dic.get(typeKey): - typeName = dic[typeKey]["name"] - - tp = GetNameWithPrefix(prefixLut, typeKey, typeName) - - args = ("v." + val["name"], " = ", tp + "_" + value["value"] + ";") - lineStr = ('{0:<' + str(maxLen + 3) + '}{1}{2}').format(*args) - print(ws + lineStr) - -def AnyMemberHasDefaultValue(members): - for val in members: - if val.get("value"): - return True - return False - -def WriteStructMembersDefaultInit(dic, prefixLut, obj, name, ind): - - members = obj.get("members") - if not AnyMemberHasDefaultValue(members): - return - - ws = GetWhitespace(ind) - ws1 = GetWhitespace(ind + 1) - if members: - print(ws + "\ninline " + name + " " + name + "Default()") - print(ws + "{") - print(ws1 + name + " v;") - WriteStructMembersDefaultValue(dic, prefixLut, obj["members"], ind + 1) - print(ws1 + "return v;") - print(ws + "}") - -def WriteStruct(dic, prefixLut, obj, ind): - ws = GetWhitespace(ind) - ws1 = GetWhitespace(ind + 1) - if obj.get("cppOnly"): - return - - if obj.get("comment"): - WriteComment(obj["comment"], ind) - - name = GetNameWithPrefix(prefixLut, obj["name"], obj["name"]) - - print(ws + "typedef struct " + name) - print(ws + "{") - if obj.get("members"): - WriteStructMembers(dic, prefixLut, obj["members"], ind + 1); - if obj.get("union_members"): - print("") - print(ws1 + "union") - print(ws1 + "{") - WriteStructMembers(dic, prefixLut, obj["union_members"], ind + 2); - print(ws1 + "};") - print(ws + "} " + name + ";") - - WriteStructMembersDefaultInit(dic, prefixLut, obj, name, ind); - -def WriteFunction(dic, prefixLut, key, obj, ind): - ws = GetWhitespace(ind) - if obj.get("comment"): - WriteComment(obj["comment"], ind) - - prefix = "" - ret = obj["ret"] - lineStr = "OMM_API " - if ret.get("const") and ret["const"]: - lineStr += "const " - lineStr += GetNameWithPrefix(prefixLut, ret["type"], ret["type"]) - if ret.get("ref") and ret["ref"]: - lineStr += "*" - lineStr += " " + prefix + GetNameWithPrefix(prefixLut, key, obj["name"]); - lineStr += "(" - - argStr = "" - isFirst = True - if obj.get("args"): - for arg in obj["args"]: - if not isFirst: - argStr += ", " - isFirst = False - if arg.get("const") and arg["const"]: - argStr += "const " - - tp = arg["type"] - prefix = "" - if prefixLut.get(tp): - prefix = prefixLut[tp] - - argStr += prefix + tp - if arg.get("ref") and arg["ref"]: - argStr += "*" - if arg.get("ptr") and arg["ptr"]: - argStr += "*" - if arg.get("ptr2x") and arg["ptr2x"]: - argStr += "**" - - argStr += " " + arg["name"] - - lineStr += argStr + ");" - print(ws + lineStr) - - -def WriteNamespace(dic, prefixLut, obj, ind): - name = obj["name"] - ws = GetWhitespace(ind) - values = obj["values"] - first = True - for val in values: - if not first: - print("") - first = False - WriteObject(dic, prefixLut,val, ind) - -def WriteTypedef(dic, prefixLut,obj, ind): - name = obj["name"] - name = GetNameWithPrefix(prefixLut, name, name) - underlying_type = obj["underlying_type"] - underlying_type = GetNameWithPrefix(prefixLut, underlying_type, underlying_type) - ws = GetWhitespace(ind) - prefix = "" - print(ws + "typedef " + prefix + underlying_type + " " + name + ";") - -def WriteObject(dic, prefixLut, key, ind): - obj = dic[key] - objType = obj["type"] - if objType == "namespace": - WriteNamespace(dic, prefixLut, obj, ind) - if objType == "struct": - WriteStruct(dic, prefixLut, obj, ind) - if objType == "enum": - WriteEnum(dic, prefixLut, key, obj, ind) - if objType == "function": - WriteFunction(dic, prefixLut, key, obj, ind) - if objType == "typedef": - WriteTypedef(dic, prefixLut,obj, ind) - -def BuildTypeToPrefix(prefix, layout, prefixLut): - for key in layout: - obj = dic[key] - objType = obj["type"] - objName = obj["name"] - if objType == "namespace": - values = obj["values"] - BuildTypeToPrefix(prefix + objName, values, prefixLut) - if objType == "struct": - prefixLut[key] = prefix - if objType == "enum": - prefixLut[key] = prefix - if objType == "function": - prefixLut[key] = prefix - if objType == "typedef": - prefixLut[key] = prefix - -# first write c++ header - -dirStr = sys.argv[1] - -hFile = os.path.join(dirStr, "include", "omm.h") - -with open(hFile, 'w') as fo: - - header_file = open( os.path.join(dirStr, "scripts", "omm_header_c.txt"), "r") - json_file = open( os.path.join(dirStr, "scripts", "omm.json"), "r") - dic = json.load(json_file) - layout = dic["layout"] - - prefixLut = {} - BuildTypeToPrefix("", layout, prefixLut) - - sys.stdout = fo # Change the standard output to the file we created. - - headStr = header_file.read() - print(headStr) - print("\ntypedef uint8_t ommBool;\n") - - for key in layout: - - WriteObject(dic, prefixLut, key, 0) - print("#endif // #ifndef INCLUDE_OMM_SDK_C") - json_file.close() - fo.close() diff --git a/omm-sdk/scripts/_interface_gen_cpp.py b/omm-sdk/scripts/_interface_gen_cpp.py deleted file mode 100644 index f6e1751..0000000 --- a/omm-sdk/scripts/_interface_gen_cpp.py +++ /dev/null @@ -1,269 +0,0 @@ -import sys -import os -import json -import textwrap - -def GetWhitespace(indent): - s = "" - for i in range(0, indent): - s = s + " " - return s - -def WriteComment(inComment, ind): - ws = GetWhitespace(ind) - for manualLine in inComment.splitlines(): - autoLine = textwrap.fill(manualLine, 120) - for line in autoLine.splitlines(): - print(ws + "// " + line) - -def intersection(lst1, lst2): - lst3 = [value for value in lst1 if value not in lst2] - return lst3 - -def GetNameWithMinimalNamespace(prefixLut, ref, nameKey, name): - if prefixLut.get(nameKey) and prefixLut.get(ref): - a = prefixLut[ref] - b = prefixLut[nameKey] - ns = intersection(b, a) - if len(ns) != 0: - res = "" - isFirst = True - for val in ns: - if not isFirst: - res += "::" - res += str(val) - isFirst = False - return res + "::" + name - return name - -def WriteEnum(dic, obj, ind): - values = obj["values"] - - ws = GetWhitespace(ind) - ws1 = GetWhitespace(ind + 1) - name = obj["name"] - declLine = "enum class " + name - - maxLen = 0 - for val in values: - maxLen = max(len(val["name"]), maxLen) - - if obj.get("comment"): - WriteComment(obj["comment"], ind) - - print(ws + declLine) - print(ws + "{") - first = True - for val in values: - if not first and obj.get("injectNewLine") and obj["injectNewLine"]: - print("") - tp = val["name"] - if val.get("comment"): - WriteComment(val["comment"], ind + 1) - - if val.get("value"): - args = (tp, "=", val["value"], ",") - print(ws1 + ('{0:<' + str(maxLen + 1) + '}{1} {2}{3}').format(*args)) - else: - print(ws1 + tp + ",") - first = False - print(ws + "};") - if obj.get("isFlag") and obj["isFlag"]: - print(ws + "OMM_DEFINE_ENUM_FLAG_OPERATORS(" + name + ");") - -def GetStructMemberLHS(dic, structKey, val): - tp = val["type"] - name = val["name"] - - typeKey = val["type"] - typeName = typeKey - if dic.get(typeKey): - typeName = dic[typeKey]["name"] - - tp = GetNameWithMinimalNamespace(prefixLut, structKey, typeKey, typeName) - - lineStr = "" - if val.get("static"): - lineStr += "static " - if val.get("constexpr"): - lineStr += "constexpr " - - prefix = "" - if val.get("const") and val["const"]: - prefix = "const " - postFix = "" - if val.get("ptr") and val["ptr"]: - postFix = "*" - return lineStr + prefix + tp + postFix - -def WriteStructMembers(dic, structKey, members, ind): - ws = GetWhitespace(ind) - - maxLen = 0 - maxLenName = 0 - for val in members: - lhs = GetStructMemberLHS(dic, structKey, val) - maxLen = max(len(lhs), maxLen) - maxLenName = max(len(val["name"]), maxLenName) - - for val in members: - - if val.get("comment"): - WriteComment(val["comment"], ind) - - name = val["name"] - lhs = GetStructMemberLHS(dic, structKey, val) - - lineStr = "" - if val.get("value"): - value = val["value"] - if not isinstance(value, str): - value = value["type"] + "::" + value["value"] - else: - if value == "default": - value = "{}" - - args = (lhs, name, "=", value, ";") - lineStr += ('{0:<' + str(maxLen + 1) + '}{1:<' + str(maxLenName + 1) + '} {2} {3}{4}').format(*args) - else: - args = (lhs, name, ";") - lineStr += ('{0:<' + str(maxLen + 1) + '}{1}{2}').format(*args) - print(ws + lineStr) - -def WriteStruct(dic, key, obj, ind): - ws = GetWhitespace(ind) - ws1 = GetWhitespace(ind + 1) - if obj.get("comment"): - WriteComment(obj["comment"], ind) - - print(ws + "struct " + obj["name"]) - print(ws + "{") - if obj.get("members"): - WriteStructMembers(dic, key, obj["members"], ind + 1); - if obj.get("union_members"): - print("") - print(ws1 + "union") - print(ws1 + "{") - WriteStructMembers(dic, key, obj["union_members"], ind + 2); - print(ws1 + "};") - - print(ws + "};") - -def WriteFunction(dic, prefixLut, key, obj, ind): - ws = GetWhitespace(ind) - if obj.get("comment"): - WriteComment(obj["comment"], ind) - - ret = obj["ret"] - lineStr = "static inline " - if ret.get("const") and ret["const"]: - lineStr += "const " - lineStr += ret["type"] - if ret.get("ref") and ret["ref"]: - lineStr += "&" - lineStr += " " + obj["name"]; - lineStr += "(" - - argStr = "" - isFirst = True - if obj.get("args"): - for arg in obj["args"]: - if not isFirst: - argStr += ", " - isFirst = False - if arg.get("const") and arg["const"]: - argStr += "const " - - tn = arg["type"]; - argStr += GetNameWithMinimalNamespace(prefixLut, key, tn, tn) - if arg.get("ref") and arg["ref"]: - argStr += "&" - if arg.get("ptr") and arg["ptr"]: - argStr += "*" - if arg.get("ptr2x") and arg["ptr2x"]: - argStr += "**" - argStr += " " + arg["name"] - - lineStr += argStr + ");" - print(ws + lineStr) - - -def WriteNamespace(dic, prefixLut,obj, ind): - name = obj["name"] - ws = GetWhitespace(ind) - print(ws + "namespace " + name) - print(ws + "{\n") - values = obj["values"] - first = True - for val in values: - if not first: - print("") - first = False - WriteObject(dic,prefixLut, val, ind + 1) - print("\n" + ws + "} // namespace " + name) - -def WriteTypedef(dic, obj, ind): - name = obj["name"] - underlying_type = obj["underlying_type"] - ws = GetWhitespace(ind) - print(ws + "using " + name + " = " + underlying_type + ";") - -def WriteObject(dic, prefixLut, key, ind): - obj = dic[key] - objType = obj["type"] - if objType == "namespace": - WriteNamespace(dic, prefixLut,obj, ind) - if objType == "struct": - WriteStruct(dic, key, obj, ind) - if objType == "enum": - WriteEnum(dic, obj, ind) - if objType == "function": - WriteFunction(dic, prefixLut, key, obj, ind) - if objType == "typedef": - WriteTypedef(dic, obj, ind) - -def BuildTypeToPrefix(prefix, layout, prefixLut): - for key in layout: - obj = dic[key] - objType = obj["type"] - objName = obj["name"] - if objType == "namespace": - values = obj["values"] - prefixcpy = prefix.copy() - prefixcpy.append(objName) - BuildTypeToPrefix(prefixcpy, values, prefixLut) - if objType == "struct": - prefixLut[key] = prefix - if objType == "enum": - prefixLut[key] = prefix - if objType == "function": - prefixLut[key] = prefix - if objType == "typedef": - prefixLut[key] = prefix - -dirStr = sys.argv[1] - -hppFile = os.path.join(dirStr, "include", "omm.hpp") - -with open(hppFile, 'w') as fo: - sys.stdout = fo # Change the standard output to the file we created. - - header_file = open( os.path.join(dirStr, "scripts", "omm_header_cpp.txt"), "r") - footer_file = open( os.path.join(dirStr, "scripts", "omm_footer_cpp.txt"), "r") - json_file = open( os.path.join(dirStr, "scripts", "omm.json"), "r") - dic = json.load(json_file) - layout = dic["layout"] - - prefixLut = {} - BuildTypeToPrefix([], layout, prefixLut) - - headStr = header_file.read() - print(headStr) - - for key in layout: - WriteObject(dic, prefixLut, key, 0) - - footerStr = footer_file.read() - print(footerStr) - json_file.close() - fo.close() diff --git a/omm-sdk/scripts/interface_gen.py b/omm-sdk/scripts/interface_gen.py deleted file mode 100644 index f243d75..0000000 --- a/omm-sdk/scripts/interface_gen.py +++ /dev/null @@ -1,3 +0,0 @@ -import os -os.system("py scripts/_interface_gen_c.py") -os.system("py scripts/_interface_gen_cpp.py") diff --git a/omm-sdk/scripts/omm.json b/omm-sdk/scripts/omm.json deleted file mode 100644 index a2f0edf..0000000 --- a/omm-sdk/scripts/omm.json +++ /dev/null @@ -1,2464 +0,0 @@ -{ - "Result": { - "type": "enum", - "name": "Result", - "underlying_type": "uint32_t", - "values": [ - { - "name": "SUCCESS" - }, - { - "name": "FAILURE" - }, - { - "name": "INVALID_ARGUMENT" - }, - { - "name": "INSUFFICIENT_SCRATCH_MEMORY" - }, - { - "name": "NOT_IMPLEMENTED" - }, - { - "name": "WORKLOAD_TOO_BIG" - }, - { - "name": "MAX_NUM" - } - ] - }, - - "OpacityState": { - "type": "enum", - "name": "OpacityState", - "underlying_type": "int32_t", - "values": [ - { - "name": "Transparent" - }, - { - "name": "Opaque" - }, - { - "name": "UnknownTransparent" - }, - { - "name": "UnknownOpaque" - } - ] - }, - - "SpecialIndex": { - "type": "enum", - "name": "SpecialIndex", - "underlying_type": "int32_t", - "values": [ - { - "name": "FullyTransparent", - "value": "-1" - }, - { - "name": "FullyOpaque", - "value": "-2" - }, - { - "name": "FullyUnknownTransparent", - "value": "-3" - }, - { - "name": "FullyUnknownOpaque", - "value": "-4" - } - ] - }, - - "Format": { - "type": "enum", - "name": "Format", - "underlying_type": "uint16_t", - "values": [ - { - "name": "INVALID" - }, - { - "comment": "Value maps to DX/VK spec.", - "name": "OC1_2_State", - "value": "1" - }, - { - "comment": "Value maps to DX/VK spec.", - "name": "OC1_4_State", - "value": "2" - }, - { - "name": "MAX_NUM", - "value": "3" - } - ] - }, - - "UnknownStatePromotion": { - "type": "enum", - "name": "UnknownStatePromotion", - "underlying_type": "uint16_t", - "values": [ - { - "comment": "Will either be UO or UT depending on the coverage. If the micro-triangle is \"mostly\" opaque it will be UO (4-state) or O (2-state). If the micro-triangle is \"mostly\" transparent it will be UT (4-state) or T (2-state)", - "name": "Nearest" - }, - { - "comment": "All unknown states get promoted to O in 2-state mode, or UO in 4-state mode", - "name": "ForceOpaque" - }, - { - "comment": "All unknown states get promoted to T in 2-state mode, or UT in 4-state mode", - "name": "ForceTransparent" - }, - { - "name": "MAX_NUM" - } - ] - }, - - "BakerType": { - "type": "enum", - "name": "BakerType", - "underlying_type": "uint8_t", - "values": [ - { - "name": "GPU" - }, - { - "name": "CPU" - }, - { - "name": "MAX_NUM" - } - ] - }, - - "TexCoordFormat": { - "type": "enum", - "name": "TexCoordFormat", - "underlying_type": "uint32_t", - "values": [ - { - "name": "UV16_UNORM" - }, - { - "name": "UV16_FLOAT" - }, - { - "name": "UV32_FLOAT" - }, - { - "name": "MAX_NUM" - } - ] - }, - - "IndexFormat": { - "type": "enum", - "name": "IndexFormat", - "underlying_type": "uint32_t", - "values": [ - { - "name": "I16_UINT" - }, - { - "name": "I32_UINT" - }, - { - "name": "MAX_NUM" - } - ] - }, - - "TextureAddressMode": { - "type": "enum", - "name": "TextureAddressMode", - "underlying_type": "uint32_t", - "values": [ - { - "name": "Wrap" - }, - { - "name": "Mirror" - }, - { - "name": "Clamp" - }, - { - "name": "Border" - }, - { - "name": "MirrorOnce" - }, - { - "name": "MAX_NUM" - } - ] - }, - - "TextureFilterMode": { - "type": "enum", - "name": "TextureFilterMode", - "underlying_type": "uint32_t", - "values": [ - { - "name": "Nearest" - }, - { - "name": "Linear" - }, - { - "name": "MAX_NUM" - } - ] - }, - - "AlphaMode": { - "type": "enum", - "name": "AlphaMode", - "underlying_type": "uint32_t", - "values": [ - { - "name": "Test" - }, - { - "name": "Blend" - }, - { - "name": "MAX_NUM" - } - ] - }, - - "SamplerDesc": { - "type": "struct", - "name": "SamplerDesc", - "members": [ - { - "type": "TextureAddressMode", - "name": "addressingMode", - "value": { - "type": "TextureAddressMode", - "value": "MAX_NUM" - } - }, - { - "type": "TextureFilterMode", - "name": "filter", - "value": { - "type": "TextureFilterMode", - "value": "MAX_NUM" - } - }, - { - "type": "float", - "name": "borderAlpha", - "value": "0" - } - ] - }, - - "MemoryAllocatorInterface": { - "type": "struct", - "name": "MemoryAllocatorInterface", - "members": [ - { - "type": "ommAllocate", - "name": "Allocate", - "value": "nullptr" - }, - { - "type": "ommReallocate", - "name": "Reallocate", - "value": "nullptr" - }, - { - "type": "ommFree", - "name": "Free", - "value": "nullptr" - }, - { - "type": "void*", - "name": "UserArg", - "value": "nullptr" - } - ] - }, - - "LibraryDesc": { - "type": "struct", - "name": "LibraryDesc", - "members": [ - { - "type": "uint8_t", - "name": "versionMajor" - }, - { - "type": "uint8_t", - "name": "versionMinor" - }, - { - "type": "uint8_t", - "name": "versionBuild" - } - ] - }, - - "BakerCreationDesc": { - "type": "struct", - "name": "BakerCreationDesc", - "members": [ - { - "type": "BakerType", - "name": "type", - "value": { - "type": "BakerType", - "value": "MAX_NUM" - } - }, - { - "type": "bool", - "name": "enableValidation", - "value": "false" - }, - { - "type": "MemoryAllocatorInterface", - "name": "memoryAllocatorInterface", - "value": "default" - } - ] - }, - - "Handle": { - "type": "typedef", - "name": "Handle", - "underlying_type": "uintptr_t" - }, - - "Baker": { - "type": "typedef", - "name": "Baker", - "underlying_type": "Handle" - }, - - "BakeResult": { - "type": "typedef", - "name": "BakeResult", - "underlying_type": "Handle" - }, - - "Texture": { - "type": "typedef", - "name": "Texture", - "underlying_type": "Handle" - }, - - "fnGetLibraryDesc": { - "type": "function", - "name": "GetLibraryDesc", - "ret": { - "type": "LibraryDesc" - } - }, - - "fnCreateBaker": { - "type": "function", - "name": "CreateBaker", - "ret": { - "type": "Result" - }, - "args": [ - { - "const": true, - "ref": true, - "type": "BakerCreationDesc", - "name": "bakeCreationDesc" - }, - { - "ptr": true, - "type": "Baker", - "name": "outBaker" - } - ] - }, - - "fnDestroyBaker": { - "type": "function", - "name": "DestroyBaker", - "ret": { - "type": "Result" - }, - "args": [ - { - "type": "Baker", - "name": "baker" - } - ] - }, - - "TextureFormat": { - "type": "enum", - "name": "TextureFormat", - "values": [ - { - "name": "UNORM8" - }, - { - "name": "FP32" - }, - { - "name": "MAX_NUM" - } - ] - }, - - "cpuBakeFlags": { - "type": "enum", - "name": "BakeFlags", - "isFlag": true, - "injectNewLine": true, - "values": [ - { - "name": "None" - }, - { - "comment": "Baker will use internal threads to run the baking process in parallel.", - "name": "EnableInternalThreads", - "value": "1u << 0" - }, - { - "comment": "Will disable the use of special indices in case the OMM-state is uniform, Only set this flag for debug purposes.\nNote: This prevents promotion of fully known OMMs to use special indices, however for invalid & degenerate UV triangles special indices may still be set.", - "name": "DisableSpecialIndices", - "value": "1u << 1" - }, - { - "comment": "Force 32-bit index format in ommIndexFormat", - "name": "Force32BitIndices", - "value": "1u << 2" - }, - { - "comment": "Will disable reuse of OMMs and instead produce duplicates omm-array data. Generally only needed for debug purposes.", - "name": "DisableDuplicateDetection", - "value": "1u << 3" - }, - { - "auto_format_comment": false, - "comment": "This enables merging of \"similar\" OMMs where similarity is measured using hamming distance.\nUT and UO are considered identical.\nPros: normally reduces resulting OMM size drastically, especially when there's overlapping UVs.\nCons: The merging comes at the cost of coverage.\nThe resulting OMM Arrays will have lower fraction of known states. For large working sets it can be quite CPU heavy to compute. Note: can not be used if DisableDuplicateDetection is set.", - "name": "EnableNearDuplicateDetection", - "value": "1u << 4" - }, - { - "comment": "Workload validation is a safety mechanism that will let the SDK reject workloads that become unreasonably large, which may lead to long baking times. When this flag is set the bake operation may return error WORKLOAD_TOO_BIG", - "name": "EnableWorkloadValidation", - "value": "1u << 5" - } - ] - }, - - "TextureFlags": { - "type": "enum", - "name": "TextureFlags", - "isFlag": true, - "values": [ - { - "name": "None" - }, - { - "comment": "Controls the internal memory layout of the texture. does not change the expected input format, it does affect the baking performance and memory footprint of the texture object.", - "name": "DisableZOrder", - "value": "1u << 0" - } - ] - }, - - "TextureMipDesc": { - "type": "struct", - "name": "TextureMipDesc", - "comment": "The baker supports conservativle baking from a MIP array when the runtime wants to pick freely between texture levels at runtime without the need to update the OMM data. _However_ baking from mip level 0 only is recommended in the general case for best performance the integration guide contains more in depth discussion on the topic", - "members": [ - { - "type": "uint32_t", - "name": "width", - "value": "0" - }, - { - "type": "uint32_t", - "name": "height", - "value": "0" - }, - { - "type": "uint32_t", - "name": "rowPitch", - "value": "0" - }, - { - "type": "const void*", - "name": "textureData", - "value": "nullptr" - } - ] - }, - - "BakeInputDesc": { - "type": "struct", - "name": "BakeInputDesc", - "members": [ - { - "type": "cpuBakeFlags", - "name": "bakeFlags", - "value": { - "type": "BakeFlags", - "value": "None" - } - }, - { - "type": "Texture", - "name": "texture", - "value": "0" - }, - { - "type": "SamplerDesc", - "name": "runtimeSamplerDesc", - "value": "default", - "comment": "RuntimeSamplerDesc should match the sampler type used at runtime" - }, - { - "type": "AlphaMode", - "name": "alphaMode", - "value": { - "type": "AlphaMode", - "value": "MAX_NUM" - } - }, - { - "type": "TexCoordFormat", - "name": "texCoordFormat", - "value": { - "type": "TexCoordFormat", - "value": "MAX_NUM" - } - }, - { - "type": "const void*", - "name": "texCoords", - "value": "nullptr" - }, - { - "type": "uint32_t", - "name": "texCoordStrideInBytes", - "value": "0", - "comment": "texCoordStrideInBytes: If zero, packed aligment is assumed" - }, - { - "type": "IndexFormat", - "name": "indexFormat", - "value": { - "type": "IndexFormat", - "value": "MAX_NUM" - } - }, - { - "type": "const void*", - "name": "indexBuffer", - "value": "nullptr" - }, - { - "type": "uint32_t", - "name": "indexCount", - "value": "0" - }, - { - "type": "float", - "name": "dynamicSubdivisionScale", - "value": "2", - "comment": "Configure the target resolution when running dynamic subdivision level.\n<= 0: disabled.\n> 0: The subdivision level be chosen such that a single micro-triangle covers approximatley a dynamicSubdivisionScale * dynamicSubdivisionScale texel area." - }, - { - "type": "float", - "name": "rejectionThreshold", - "value": "0", - "comment": "Rejection threshold [0,1]. Unless OMMs achive a rate of at least rejectionThreshold known states OMMs will be discarded for the primitive. Use this to weed out \"poor\" OMMs." - }, - { - "type": "float", - "name": "alphaCutoff", - "value": "0.5f", - "comment": "The alpha cutoff value. texture > alphaCutoff ? Opaque : Transparent" - }, - { - "type": "Format", - "name": "format", - "value": { - "type": "Format", - "value": "OC1_4_State" - }, - - "comment": "The global Format. May be overriden by the per-triangle subdivision level setting." - }, - { - "type": "Format", - "const": true, - "ptr": true, - "name": "formats", - "value": "nullptr", - "comment": "Use Formats to control format on a per triangle granularity. If Format is set to Format::INVALID the global setting will be used instead." - }, - { - "type": "UnknownStatePromotion", - "name": "unknownStatePromotion", - "value": { - "type": "UnknownStatePromotion", - "value": "ForceOpaque" - }, - "comment": "Determines how to promote mixed states" - }, - { - "type": "uint8_t", - "name": "maxSubdivisionLevel", - "value": "8", - "comment": "Micro triangle count is 4^N, where N is the subdivision level.\nmaxSubdivisionLevel level must be in range [0, 12].\nWhen dynamicSubdivisionScale is enabled maxSubdivisionLevel is the max subdivision level allowed.\nWhen dynamicSubdivisionScale is disabled maxSubdivisionLevel is the subdivision level applied uniformly to all triangles." - }, - { - "type": "bool", - "name": "enableSubdivisionLevelBuffer", - "value": "false" - }, - { - "type": "const uint8_t*", - "name": "subdivisionLevels", - "value": "nullptr", - "comment": "[optional] Use subdivisionLevels to control subdivision on a per triangle granularity.\n+14 - reserved for future use.\n13 - use global value specified in 'subdivisionLevel.\n[0,12] - per triangle subdivision level'" - } - ] - }, - - "TextureDesc": { - "type": "struct", - "name": "TextureDesc", - "members": [ - { - "type": "TextureFormat", - "name": "format", - "value": { - "type": "TextureFormat", - "value": "MAX_NUM" - } - }, - { - "type": "TextureFlags", - "name": "flags", - "value": { - "type": "TextureFlags", - "value": "None" - } - }, - { - "type": "TextureMipDesc", - "const": true, - "ptr": true, - "name": "mips", - "value": "nullptr" - }, - { - "type": "uint32_t", - "name": "mipCount", - "value": "0" - }, - { - "type": "float", - "name": "alphaCutoff", - "value": "-1.f", - "comment": "Setting the alphaCutoff [0,1] allows the alpha cutoff to be embeded in the texture object which may accelerate the baking operation in some circumstances. Note: if set it must match the alphaCutoff in the bake desc exactly." - } - ] - }, - - "OpacityMicromapDesc": { - "type": "struct", - "name": "OpacityMicromapDesc", - "members": [ - { - "type": "uint32_t", - "name": "offset", - "comment": "Byte offset into the opacity micromap map array." - }, - { - "type": "uint16_t", - "name": "subdivisionLevel", - "comment": "Micro triangle count is 4^N, where N is the subdivision level." - }, - { - "type": "uint16_t", - "name": "format", - "comment": "OMM input format." - } - ] - }, - - "OpacityMicromapUsageCount": { - "type": "struct", - "name": "OpacityMicromapUsageCount", - "members": [ - { - "type": "uint32_t", - "name": "count", - "comment": "Number of OMMs with the specified subdivision level and format." - }, - { - "type": "uint16_t", - "name": "subdivisionLevel", - "comment": "Micro triangle count is 4^N, where N is the subdivision level." - }, - { - "type": "uint16_t", - "name": "format", - "comment": "OMM input format." - } - ] - }, - - "BakeResultDesc": { - "type": "struct", - "name": "BakeResultDesc", - "members": [ - { - "type": "const void*", - "name": "arrayData", - "comment": "Below is used as OMM array build input DX/VK." - }, - { - "type": "uint32_t", - "name": "arrayDataSize" - }, - { - "type": "OpacityMicromapDesc", - "const": true, - "ptr": true, - "name": "descArray" - }, - { - "type": "uint32_t", - "name": "descArrayCount" - }, - { - "type": "OpacityMicromapUsageCount", - "const": true, - "ptr": true, - "name": "descArrayHistogram", - "comment": "The histogram of all omm data referenced by 'ommDescArray', can be used as 'pOMMUsageCounts' for the OMM build in D3D12" - }, - { - "type": "uint32_t", - "name": "descArrayHistogramCount" - }, - { - "type": "const void*", - "name": "indexBuffer", - "comment": "Below is used for BLAS build input in DX/VK" - }, - { - "type": "uint32_t", - "name": "indexCount" - }, - { - "type": "IndexFormat", - "name": "indexFormat" - }, - { - "type": "OpacityMicromapUsageCount", - "const": true, - "ptr": true, - "name": "indexHistogram", - "comment": "Same as ommDescArrayHistogram but usage count equals the number of references by ommIndexBuffer. Can be used as 'pOMMUsageCounts' for the BLAS OMM attachment in D3D12" - }, - { - "type": "uint32_t", - "name": "indexHistogramCount" - } - ] - }, - - "fnCreateTexture": { - "type": "function", - "name": "CreateTexture", - "ret": { - "type": "Result" - }, - "args": [ - { - "type": "Baker", - "name": "baker" - }, - { - "const": true, - "ref": true, - "type": "TextureDesc", - "name": "desc" - }, - { - "ptr": true, - "type": "Texture", - "name": "outTexture" - } - ] - }, - - "fnDestroyTexture": { - "type": "function", - "name": "DestroyTexture", - "ret": { - "type": "Result" - }, - "args": [ - { - "type": "Baker", - "name": "baker" - }, - { - "type": "Texture", - "name": "texture" - } - ] - }, - - "fnBakeCPU": { - "type": "function", - "name": "Bake", - "ret": { - "type": "Result" - }, - "args": [ - { - "type": "Baker", - "name": "baker" - }, - { - "const": true, - "ref": true, - "type": "BakeInputDesc", - "name": "bakeInputDesc" - }, - { - "ptr": true, - "type": "BakeResult", - "name": "outBakeResult" - } - ] - }, - - "fnDestroyBakeResult": { - "type": "function", - "name": "DestroyBakeResult", - "ret": { - "type": "Result" - }, - "args": [ - { - "type": "BakeResult", - "name": "bakeResult" - } - ] - }, - - "fnGetBakeResultDesc": { - "type": "function", - "name": "GetBakeResultDesc", - "ret": { - "type": "Result" - }, - "args": [ - { - "type": "BakeResult", - "name": "bakeResult" - }, - { - "type": "BakeResultDesc", - "const": true, - "ptr2x": true, - "name": "desc" - } - ] - }, - - "Pipeline": { - "type": "typedef", - "name": "Pipeline", - "underlying_type": "Handle" - }, - - "DescriptorType": { - "type": "enum", - "name": "DescriptorType", - "underlying_type": "uint32_t", - "values": [ - { - "name": "TextureRead" - }, - { - "name": "BufferRead" - }, - { - "name": "RawBufferRead" - }, - { - "name": "RawBufferWrite" - }, - { - "name": "MAX_NUM" - } - ] - }, - - "ResourceType": { - "type": "enum", - "name": "ResourceType", - "underlying_type": "uint32_t", - "values": [ - { - "name": "IN_ALPHA_TEXTURE", - "comment": "1-4 channels, any format." - }, - { - "name": "IN_TEXCOORD_BUFFER" - }, - { - "name": "IN_INDEX_BUFFER" - }, - { - "name": "IN_SUBDIVISION_LEVEL_BUFFER", - "comment": "(Optional) R8, Values must be in range [-2, 12].\nPositive values to enforce specific subdibision level for the primtive.\n-1 to use global subdivision level.\n-2 to use automatic subduvision level based on tunable texel-area heuristic" - }, - { - "name": "OUT_OMM_ARRAY_DATA", - "comment": "Used directly as argument for OMM build in DX/VK" - }, - { - "name": "OUT_OMM_DESC_ARRAY", - "comment": "Used directly as argument for OMM build in DX/VK" - }, - { - "name": "OUT_OMM_DESC_ARRAY_HISTOGRAM", - "comment": "Used directly as argument for OMM build in DX/VK. (Read back to CPU to query memory requirements during OMM Array build)" - }, - { - "name": "OUT_OMM_INDEX_BUFFER", - "comment": "Used directly as argument for OMM build in DX/VK" - }, - { - "name": "OUT_OMM_INDEX_HISTOGRAM", - "comment": "Used directly as argument for OMM build in DX/VK. (Read back to CPU to query memory requirements during OMM Blas build)" - }, - { - "name": "OUT_POST_DISPATCH_INFO", - "comment": "Read back the PostDispatchInfo struct containing the actual sizes of ARRAY_DATA and DESC_ARRAY." - }, - { - "name": "TRANSIENT_POOL_BUFFER", - "comment": "Can be reused after baking" - }, - { - "name": "STATIC_VERTEX_BUFFER", - "comment": "Initialize on startup. Read-only." - }, - { - "name": "STATIC_INDEX_BUFFER", - "comment": "Initialize on startup. Read-only." - }, - { - "name": "MAX_NUM" - } - ] - }, - - "PrimitiveTopology": { - "type": "enum", - "name": "PrimitiveTopology", - "underlying_type": "uint32_t", - "values": [ - { - "name": "TriangleList" - }, - { - "name": "MAX_NUM" - } - ] - }, - - "PipelineType": { - "type": "enum", - "name": "PipelineType", - "underlying_type": "uint32_t", - "values": [ - { - "name": "Compute" - }, - { - "name": "Graphics" - }, - { - "name": "MAX_NUM" - } - ] - }, - - "DispatchType": { - "type": "enum", - "name": "DispatchType", - "underlying_type": "uint32_t", - "values": [ - { - "name": "Compute" - }, - { - "name": "ComputeIndirect" - }, - { - "name": "DrawIndexedIndirect" - }, - { - "name": "BeginLabel" - }, - { - "name": "EndLabel" - }, - { - "name": "MAX_NUM" - } - ] - }, - - "BufferFormat": { - "type": "enum", - "name": "BufferFormat", - "underlying_type": "uint32_t", - "values": [ - { - "name": "R32_UINT" - }, - { - "name": "MAX_NUM" - } - ] - }, - - "RasterCullMode": { - "type": "enum", - "name": "RasterCullMode", - "underlying_type": "uint32_t", - "values": [ - { - "name": "None" - } - ] - }, - - "RenderAPI": { - "type": "enum", - "name": "RenderAPI", - "underlying_type": "uint32_t", - "values": [ - { - "name": "DX12" - }, - { - "name": "Vulkan" - }, - { - "name": "MAX_NUM" - } - ] - }, - - "ScratchMemoryBudget": { - "type": "enum", - "name": "ScratchMemoryBudget", - "underlying_type": "size_t", - "values": [ - { - "name": "Undefined" - }, - { - "name": "MB_4", - "value": "4ull << 20ull" - }, - { - "name": "MB_32", - "value": "32ull << 20ull" - }, - { - "name": "MB_64", - "value": "64ull << 20ull" - }, - { - "name": "MB_128", - "value": "128ull << 20ull" - }, - { - "name": "MB_256", - "value": "256ull << 20ull" - }, - { - "name": "MB_512", - "value": "512ull << 20ull" - }, - { - "name": "MB_1024", - "value": "1024ull << 20ull" - }, - { - "name": "Default", - "value": "256ull << 20ull" - } - ] - }, - - "gpuBakeFlags": { - "type": "enum", - "name": "BakeFlags", - "underlying_type": "uint32_t", - "isFlag": true, - "injectNewLine": true, - "values": [ - { - "name": "Invalid", - "value": "0", - "comment": "Either PerformSetup, PerformBake (or both simultaneously) must be set." - }, - { - "name": "PerformSetup", - "value": "1u << 0", - "comment": "(Default) OUT_OMM_DESC_ARRAY_HISTOGRAM, OUT_OMM_INDEX_HISTOGRAM, OUT_OMM_INDEX_BUFFER, OUT_OMM_DESC_ARRAY and OUT_POST_DISPATCH_INFO will be updated." - }, - { - "name": "PerformBake", - "value": "1u << 1", - "comment": "(Default) OUT_OMM_INDEX_HISTOGRAM, OUT_OMM_INDEX_BUFFER, OUT_OMM_ARRAY_DATA and OUT_POST_DISPATCH_INFO (if stats enabled) will be updated. If special indices are detected OUT_OMM_INDEX_BUFFER may also be modified.\nIf PerformBuild is not used with this flag, OUT_OMM_DESC_ARRAY_HISTOGRAM, OUT_OMM_INDEX_HISTOGRAM, OUT_OMM_INDEX_BUFFER, OUT_OMM_DESC_ARRAY must contain valid data from a prior PerformSetup pass." - }, - { - "name": "PerformSetupAndBake", - "value": "3u", - "comment": "Alias for (PerformSetup | PerformBake)" - }, - { - "name": "ComputeOnly", - "value": "1u << 2", - "comment": "Baking will only be done using compute shaders and no gfx involvement (drawIndirect or graphics PSOs). (Beta)\nWill become default mode in the future.\n+ Useful for async workloads\n+ Less memory hungry\n+ Faster baking on low texel ratio to micro-triangle ratio (=rasterizing small triangles)\n- May looses efficency when resampling large triangles (tail-effect). Potential mitigation is to batch multiple bake jobs. However this is generally not a big problem." - }, - { - "name": "EnablePostDispatchInfoStats", - "value": "1u << 3", - "comment": "Must be used together with EnablePostDispatchInfo. If set baking (PerformBake) will fill the stats data of OUT_POST_DISPATCH_INFO." - }, - { - "name": "DisableSpecialIndices", - "value": "1u << 4", - "comment": "Will disable the use of special indices in case the OMM-state is uniform. Only set this flag for debug purposes." - }, - { - "name": "DisableTexCoordDeduplication", - "value": "1u << 5", - "comment": "If texture coordinates are known to be unique tex cooord deduplication can be disabled to save processing time and free up scratch memory." - }, - { - "name": "Force32BitIndices", - "value": "1u << 6", - "comment": "Force 32-bit indices in OUT_OMM_INDEX_BUFFER" - }, - { - "name": "DisableLevelLineIntersection", - "value": "1u << 7", - "comment": "Use only for debug purposes. Level Line Intersection method is vastly superior in 4-state mode." - }, - { - "name": "EnableNsightDebugMode", - "value": "1u << 8", - "comment": "Slightly modifies the dispatch to aid frame capture debugging." - } - ] - }, - - "Resource": { - "type": "struct", - "name": "Resource", - "members": [ - { - "type": "DescriptorType", - "name": "stateNeeded" - }, - { - "type": "ResourceType", - "name": "type" - }, - { - "type": "uint16_t", - "name": "indexInPool" - }, - { - "type": "uint16_t", - "name": "mipOffset" - }, - { - "type": "uint16_t", - "name": "mipNum" - } - ] - }, - - "DescriptorRangeDesc": { - "type": "struct", - "name": "DescriptorRangeDesc", - "members": [ - { - "type": "DescriptorType", - "name": "descriptorType" - }, - { - "type": "uint32_t", - "name": "baseRegisterIndex" - }, - { - "type": "uint32_t", - "name": "descriptorNum" - } - ] - }, - - "BufferDesc": { - "type": "struct", - "name": "BufferDesc", - "members": [ - { - "type": "size_t", - "name": "bufferSize" - } - ] - }, - - "ShaderBytecode": { - "type": "struct", - "name": "ShaderBytecode", - "members": [ - { - "type": "const void*", - "name": "data" - }, - { - "type": "size_t", - "name": "size" - } - ] - }, - - "ComputePipelineDesc": { - "type": "struct", - "name": "ComputePipelineDesc", - "members": [ - { - "type": "ShaderBytecode", - "name": "computeShader" - }, - { - "type": "const char*", - "name": "shaderFileName" - }, - { - "type": "const char*", - "name": "shaderEntryPointName" - }, - { - "type": "DescriptorRangeDesc", - "const": true, - "ptr": true, - "name": "descriptorRanges" - }, - { - "type": "uint32_t", - "name": "descriptorRangeNum" - }, - { - "type": "bool", - "name": "hasConstantData", - "comment": "if \"true\" all constant buffers share same \"ConstantBufferDesc\" description. if \"false\" this pipeline doesn't have a constant buffer" - } - ] - }, - - "GraphicsPipelineInputElementDesc": { - "type": "struct", - "name": "GraphicsPipelineInputElementDesc", - "members": [ - { - "static": "true", - "constexpr": "true", - "type": "const char*", - "name": "semanticName", - "value": "\"POSITION\"" - }, - { - "static": "true", - "constexpr": "true", - "type": "BufferFormat", - "name": "format", - "value": { - "type": "BufferFormat", - "value": "R32_UINT" - } - }, - { - "static": "true", - "constexpr": "true", - "type": "uint32_t", - "name": "inputSlot", - "value": "0" - }, - { - "static": "true", - "constexpr": "true", - "type": "uint32_t", - "name": "semanticIndex", - "value": "0" - }, - { - "static": "true", - "constexpr": "true", - "type": "bool", - "name": "isPerInstanced", - "value": "false" - } - - ] - }, - - "GraphicsPipelineDesc": { - "type": "struct", - "name": "GraphicsPipelineDesc", - "comment": "Config specification not declared in the GraphicsPipelineDesc is implied, but may become explicit in future versions.\nStenci state = disabled\nBlendState = disabled\nPrimitive topology = triangle list\nInput element = count 1, see GraphicsPipelineInputElementDesc\nFill mode = solid\nTrack any changes via OMM_GRAPHICS_PIPELINE_DESC_VERSION\n", - "members": [ - { - "type": "ShaderBytecode", - "name": "vertexShader" - }, - { - "type": "const char*", - "name": "vertexShaderFileName" - }, - { - "type": "const char*", - "name": "vertexShaderEntryPointName" - }, - { - "type": "ShaderBytecode", - "name": "geometryShader" - }, - { - "type": "const char*", - "name": "geometryShaderFileName" - }, - { - "type": "const char*", - "name": "geometryShaderEntryPointName" - }, - { - "type": "ShaderBytecode", - "name": "pixelShader" - }, - { - "type": "const char*", - "name": "pixelShaderFileName" - }, - { - "type": "const char*", - "name": "pixelShaderEntryPointName" - }, - { - "type": "bool", - "name": "conservativeRasterization" - }, - { - "type": "DescriptorRangeDesc", - "const": true, - "ptr": true, - "name": "descriptorRanges" - }, - { - "type": "uint32_t", - "name": "descriptorRangeNum" - }, - { - "type": "uint32_t", - "name": "numRenderTargets", - "comment": "if NumRenderTargets = 0 a null RTV is implied." - }, - { - "type": "bool", - "name": "hasConstantData", - "comment": "if \"true\" all constant buffers share same \"ConstantBufferDesc\" description. if \"false\" this pipeline doesn't have a constant buffer" - } - ] - }, - - "PipelineDesc": { - "type": "struct", - "name": "PipelineDesc", - "members": [ - { - "type": "PipelineType", - "name": "type" - } - ], - "union_members": [ - { - "type": "ComputePipelineDesc", - "name": "compute" - }, - { - "type": "GraphicsPipelineDesc", - "name": "graphics" - } - ] - }, - - "DescriptorSetDesc": { - "type": "struct", - "name": "DescriptorSetDesc", - "members": [ - { - "type": "uint32_t", - "name": "constantBufferMaxNum" - }, - { - "type": "uint32_t", - "name": "storageBufferMaxNum" - }, - { - "type": "uint32_t", - "name": "descriptorRangeMaxNumPerPipeline" - } - ] - }, - - "ConstantBufferDesc": { - "type": "struct", - "name": "ConstantBufferDesc", - "members": [ - { - "type": "uint32_t", - "name": "registerIndex" - }, - { - "type": "uint32_t", - "name": "maxDataSize" - } - ] - }, - - "Viewport": { - "type": "struct", - "name": "Viewport", - "members": [ - { - "type": "float", - "name": "minWidth" - }, - { - "type": "float", - "name": "minHeight" - }, - { - "type": "float", - "name": "maxWidth" - }, - { - "type": "float", - "name": "maxHeight" - } - ] - }, - - "ComputeDesc": { - "type": "struct", - "name": "ComputeDesc", - "members": [ - { - "type": "const char*", - "name": "name" - }, - { - "type": "Resource", - "const": true, - "ptr": true, - "name": "resources", - "comment": "concatenated resources for all \"DescriptorRangeDesc\" descriptions in DenoiserDesc::pipelines[ pipelineIndex ]" - }, - { - "type": "uint32_t", - "name": "resourceNum" - }, - { - "type": "const uint8_t*", - "name": "localConstantBufferData", - "comment": "\"root constants\" in DX12" - }, - { - "type": "uint32_t", - "name": "localConstantBufferDataSize" - }, - { - "type": "uint16_t", - "name": "pipelineIndex" - }, - { - "type": "uint32_t", - "name": "gridWidth" - }, - { - "type": "uint32_t", - "name": "gridHeight" - } - ] - }, - - "ComputeIndirectDesc": { - "type": "struct", - "name": "ComputeIndirectDesc", - "members": [ - { - "type": "const char*", - "name": "name" - }, - { - "type": "Resource", - "const": true, - "ptr": true, - "name": "resources", - "comment": "concatenated resources for all \"DescriptorRangeDesc\" descriptions in DenoiserDesc::pipelines[ pipelineIndex ]" - }, - { - "type": "uint32_t", - "name": "resourceNum" - }, - { - "type": "const uint8_t*", - "name": "localConstantBufferData", - "comment": "\"root constants\" in DX12" - }, - { - "type": "uint32_t", - "name": "localConstantBufferDataSize" - }, - { - "type": "uint16_t", - "name": "pipelineIndex" - }, - { - "type": "Resource", - "name": "indirectArg" - }, - { - "type": "size_t", - "name": "indirectArgByteOffset" - } - ] - }, - - "DrawIndexedIndirectDesc": { - "type": "struct", - "name": "DrawIndexedIndirectDesc", - "members": [ - { - "type": "const char*", - "name": "name" - }, - { - "type": "Resource", - "const": true, - "ptr": true, - "name": "resources", - "comment": "concatenated resources for all \"DescriptorRangeDesc\" descriptions in DenoiserDesc::pipelines[ pipelineIndex ]" - }, - { - "type": "uint32_t", - "name": "resourceNum" - }, - { - "type": "const uint8_t*", - "name": "localConstantBufferData", - "comment": "\"root constants\" in DX12" - }, - { - "type": "uint32_t", - "name": "localConstantBufferDataSize" - }, - { - "type": "uint16_t", - "name": "pipelineIndex" - }, - { - "type": "Resource", - "name": "indirectArg" - }, - { - "type": "size_t", - "name": "indirectArgByteOffset" - }, - { - "type": "Viewport", - "name": "viewport" - }, - { - "type": "Resource", - "name": "indexBuffer" - }, - { - "type": "uint32_t", - "name": "indexBufferOffset" - }, - { - "type": "Resource", - "name": "vertexBuffer" - }, - { - "type": "uint32_t", - "name": "vertexBufferOffset" - } - ] - }, - - "BeginLabelDesc": { - "type": "struct", - "name": "BeginLabelDesc", - "members": [ - { - "type": "const char*", - "name": "debugName" - } - ] - }, - - "DispatchDesc": { - "type": "struct", - "name": "DispatchDesc", - "members": [ - { - "type": "DispatchType", - "name": "type" - } - ], - "union_members": [ - { - "type": "ComputeDesc", - "name": "compute" - }, - { - "type": "ComputeIndirectDesc", - "name": "computeIndirect" - }, - { - "type": "DrawIndexedIndirectDesc", - "name": "drawIndexedIndirect" - }, - { - "type": "BeginLabelDesc", - "name": "beginLabel" - } - ] - }, - - "StaticSamplerDesc": { - "type": "struct", - "name": "StaticSamplerDesc", - "members": [ - { - "type": "SamplerDesc", - "name": "desc" - }, - { - "type": "uint32_t", - "name": "registerIndex" - } - ] - }, - - "SPIRVBindingOffsets": { - "type": "struct", - "name": "SPIRVBindingOffsets", - "members": [ - { - "type": "uint32_t", - "name": "samplerOffset" - }, - { - "type": "uint32_t", - "name": "textureOffset" - }, - { - "type": "uint32_t", - "name": "constantBufferOffset" - }, - { - "type": "uint32_t", - "name": "storageTextureAndBufferOffset" - } - ] - }, - - "PipelineConfigDesc": { - "type": "struct", - "name": "PipelineConfigDesc", - "members": [ - { - "type": "RenderAPI", - "name": "renderAPI", - "value": { - "type": "RenderAPI", - "value": "DX12" - }, - "comment": "API is required to make sure indirect buffers are written to in suitable format" - } - ] - }, - - "DispatchConfigDesc": { - "type": "struct", - "name": "DispatchConfigDesc", - "members": [ - { - "type": "gpuBakeFlags", - "name": "bakeFlags", - "value": { - "type": "BakeFlags", - "value": "PerformSetupAndBake" - } - }, - { - "type": "SamplerDesc", - "name": "runtimeSamplerDesc", - "value": "default", - "comment": "RuntimeSamplerDesc describes the texture sampler that will be used in the runtime alpha test shader code." - }, - { - "type": "AlphaMode", - "name": "alphaMode", - "value": { - "type": "AlphaMode", - "value": "MAX_NUM" - } - }, - { - "type": "uint32_t", - "name": "alphaTextureWidth", - "value": "0", - "comment": " The texture dimensions of IN_ALPHA_TEXTURE" - }, - { - "type": "uint32_t", - "name": "alphaTextureHeight", - "value": "0", - "comment": " The texture dimensions of IN_ALPHA_TEXTURE" - }, - { - "type": "uint32_t", - "name": "alphaTextureChannel", - "value": "3", - "comment": "The channel in IN_ALPHA_TEXTURE containing opacity values" - }, - { - "type": "TexCoordFormat", - "name": "texCoordFormat", - "value": { - "type": "TexCoordFormat", - "value": "MAX_NUM" - } - }, - { - "type": "uint32_t", - "name": "texCoordOffsetInBytes", - "value": "0" - }, - { - "type": "uint32_t", - "name": "texCoordStrideInBytes", - "value": "0" - }, - { - "type": "IndexFormat", - "name": "indexFormat", - "value": { - "type": "IndexFormat", - "value": "MAX_NUM" - } - }, - { - "type": "uint32_t", - "name": "indexCount", - "value": "0", - "comment": "The actual number of indices can be lower." - }, - { - "type": "uint32_t", - "name": "indexStrideInBytes", - "value": "0", - "comment": "If zero packed aligment is assumed." - }, - { - "type": "float", - "name": "alphaCutoff", - "value": "0.5f", - "comment": "The alpha cutoff value. texture > alphaCutoff ? Opaque : Transparent." - }, - { - "type": "float", - "name": "dynamicSubdivisionScale", - "value": "2", - "comment": "Configure the target resolution when running dynamic subdivision level. <= 0: disabled. > 0: The subdivision level be chosen such that a single micro-triangle covers approximatley a dynamicSubdivisionScale * dynamicSubdivisionScale texel area." - }, - { - "type": "Format", - "name": "globalFormat", - "value": { - "type": "Format", - "value": "OC1_4_State" - }, - "comment": "The global Format. May be overriden by the per-triangle config." - }, - { - "type": "uint8_t", - "name": "maxSubdivisionLevel", - "value": "8" - }, - { - "type": "bool", - "name": "enableSubdivisionLevelBuffer", - "value": "false" - }, - { - "type": "uint32_t", - "name": "maxOutOmmArraySize", - "value": "0xFFFFFFFF", - "comment": "The SDK will try to limit the omm array size of PreDispatchInfo::outOmmArraySizeInBytes and PostDispatchInfo::outOmmArraySizeInBytes.\nCurrently a greedy algorithm is implemented with a first come-first serve order.\nThe SDK may (or may not) apply more sophisticated heuristics in the future.\nIf no memory is available to allocate an OMM Array Block the state will default to Unknown Opaque (ignoring any bake flags do disable special indices)." - }, - { - "type": "ScratchMemoryBudget", - "name": "maxScratchMemorySize", - "value": { - "type": "ScratchMemoryBudget", - "value": "Default" - }, - "comment": "Target scratch memory budget, The SDK will try adjust the sum of the transient pool buffers to match this value. Higher budget more efficiently executes the baking operation. May return INSUFFICIENT_SCRATCH_MEMORY if set too low." - } - ] - }, - - "PipelineInfoDesc": { - "type": "struct", - "name": "PipelineInfoDesc", - "members": [ - { - "type": "SPIRVBindingOffsets", - "name": "spirvBindingOffsets" - }, - { - "type": "PipelineDesc", - "const": true, - "ptr": true, - "name": "pipelines" - }, - { - "type": "uint32_t", - "name": "pipelineNum" - }, - { - "type": "ConstantBufferDesc", - "name": "globalConstantBufferDesc" - }, - { - "type": "ConstantBufferDesc", - "name": "localConstantBufferDesc" - }, - { - "type": "DescriptorSetDesc", - "name": "descriptorSetDesc" - }, - { - "type": "StaticSamplerDesc", - "const": true, - "ptr": true, - "name": "staticSamplers" - }, - { - "type": "uint32_t", - "name": "staticSamplersNum" - } - ] - }, - - "PreDispatchInfo": { - "type": "struct", - "name": "PreDispatchInfo", - "comment": "Note: sizes may return size zero, this means the buffer will not be used in the dispatch.", - "members": [ - { - "type": "IndexFormat", - "name": "outOmmIndexBufferFormat", - "value": { - "type": "IndexFormat", - "value": "MAX_NUM" - }, - "comment": "Format of outOmmIndexBuffer" - }, - { - "type": "uint32_t", - "name": "outOmmIndexCount", - "value": "0xFFFFFFFF" - }, - { - "type": "uint32_t", - "name": "outOmmArraySizeInBytes", - "value": "0xFFFFFFFF", - "comment": "Min required size of OUT_OMM_ARRAY_DATA. GetPreDispatchInfo returns most conservative estimation while less conservative number can be obtained via BakePrepass" - }, - { - "type": "uint32_t", - "name": "outOmmDescSizeInBytes", - "value": "0xFFFFFFFF", - "comment": "Min required size of OUT_OMM_DESC_ARRAY. GetPreDispatchInfo returns most conservative estimation while less conservative number can be obtained via BakePrepass" - }, - { - "type": "uint32_t", - "name": "outOmmIndexBufferSizeInBytes", - "value": "0xFFFFFFFF", - "comment": "Min required size of OUT_OMM_INDEX_BUFFER" - }, - { - "type": "uint32_t", - "name": "outOmmArrayHistogramSizeInBytes", - "value": "0xFFFFFFFF", - "comment": "Min required size of OUT_OMM_ARRAY_HISTOGRAM" - }, - { - "type": "uint32_t", - "name": "outOmmIndexHistogramSizeInBytes", - "value": "0xFFFFFFFF", - "comment": "Min required size of OUT_OMM_INDEX_HISTOGRAM" - }, - { - "type": "uint32_t", - "name": "outOmmPostDispatchInfoSizeInBytes", - "value": "0xFFFFFFFF", - "comment": "Min required size of OUT_POST_DISPATCH_INFO" - }, - { - "type": "uint32_t", - "name": "transientPoolBufferSizeInBytes[OMM_MAX_TRANSIENT_POOL_BUFFERS]", - "comment": "Min required sizes of TRANSIENT_POOL_BUFFERs" - }, - { - "type": "uint32_t", - "name": "numTransientPoolBuffers", - "value": "0" - } - ] - }, - - "BufferSizes": { - "type": "struct", - "name": "BufferSizes", - "members": [ - { - "type": "uint32_t", - "name": "ommArraySizeInBytes", - "value": "0xFFFFFFFF", - "comment": "Maximum size of OUT_OMM_ARRAY_DATA" - }, - { - "type": "uint32_t", - "name": "ommDescSizeInBytes", - "value": "0xFFFFFFFF", - "comment": "Maximum size of OUT_OMM_DESC_ARRAY" - }, - { - "type": "uint32_t", - "name": "preBakeResult", - "value": "0xFFFFFFFF", - "comment": "Data passed from preBakePass. Used for validation purposes." - } - ] - }, - - "PostDispatchInfo": { - "type": "struct", - "name": "PostDispatchInfo", - "comment": "Format of OUT_POST_DISPATCH_INFO", - "members": [ - { - "type": "uint32_t", - "name": "outOmmArraySizeInBytes" - }, - { - "type": "uint32_t", - "name": "outOmmDescSizeInBytes" - }, - { - "type": "uint32_t", - "name": "outStatsTotalOpaqueCount", - "comment": "Will be populated if EnablePostDispatchInfoStats is set." - }, - { - "type": "uint32_t", - "name": "outStatsTotalTransparentCount", - "comment": "Will be populated if EnablePostDispatchInfoStats is set." - }, - { - "type": "uint32_t", - "name": "outStatsTotalUnknownCount", - "comment": "Will be populated if EnablePostDispatchInfoStats is set." - }, - { - "type": "uint32_t", - "name": "outStatsTotalFullyOpaqueCount", - "comment": "Will be populated if EnablePostDispatchInfoStats is set." - }, - { - "type": "uint32_t", - "name": "outStatsTotalFullyTransparentCount", - "comment": "Will be populated if EnablePostDispatchInfoStats is set." - }, - { - "type": "uint32_t", - "name": "outStatsTotalFullyStatsUnknownCount", - "comment": "Will be populated if EnablePostDispatchInfoStats is set." - } - ] - }, - - "DispatchChain": { - "type": "struct", - "name": "DispatchChain", - "members": [ - { - "type": "DispatchDesc", - "const": true, - "ptr": true, - "name": "dispatches" - }, - { - "type": "uint32_t", - "name": "numDispatches" - }, - { - "type": "const uint8_t*", - "name": "globalCBufferData" - }, - { - "type": "uint32_t", - "name": "globalCBufferDataSize" - } - ] - }, - - "fnGetStaticResourceData": { - "type": "function", - "name": "GetStaticResourceData", - "comment": "Global immutable resources. These contain the static immutable resources being shared acroess all bake calls. Currently it's the specific IB and VB that represents a tesselated triangle arranged in bird curve order, for different subdivision levels.", - "ret": { - "type": "Result" - }, - "args": [ - { - "type": "ResourceType", - "name": "resource" - }, - { - "type": "uint8_t*", - "name": "data" - }, - { - "type": "size_t*", - "name": "outByteSize" - } - ] - }, - - "fnCreatePipeline": { - "type": "function", - "name": "CreatePipeline", - "ret": { - "type": "Result" - }, - "args": [ - { - "type": "Baker", - "name": "baker" - }, - { - "type": "PipelineConfigDesc", - "const": true, - "ref": true, - "name": "pipelineCfg" - }, - { - "type": "Pipeline", - "ptr": true, - "name": "outPipeline" - } - ] - }, - - "fnDestroyPipeline": { - "type": "function", - "name": "DestroyPipeline", - "ret": { - "type": "Result" - }, - "args": [ - { - "type": "Baker", - "name": "baker" - }, - { - "type": "Pipeline", - "name": "pipeline" - } - ] - }, - - "fnGetPipelineDesc": { - "type": "function", - "name": "GetPipelineDesc", - "comment": "Return the required pipelines. Does not depend on per-dispatch settings.", - "ret": { - "type": "Result" - }, - "args": [ - { - "type": "Pipeline", - "name": "pipeline" - }, - { - "type": "PipelineInfoDesc", - "const": true, - "ptr2x": true, - "name": "outPipelineDesc" - } - ] - }, - - "fnGetPreDispatchInfo": { - "type": "function", - "name": "GetPreDispatchInfo", - "comment": "Returns the scratch and output memory requirements of the baking operation.", - "ret": { - "type": "Result" - }, - "args": [ - { - "type": "Pipeline", - "name": "pipeline" - }, - { - "type": "DispatchConfigDesc", - "const": true, - "ref": true, - "name": "config" - }, - { - "type": "PreDispatchInfo", - "ptr": true, - "name": "outPreDispatchInfo" - } - ] - }, - - "fnDispatchGPU": { - "type": "function", - "name": "Dispatch", - "comment": "Returns the dispatch order to perform the baking operation. Once complete the OUT_OMM_* resources will be written to and can be consumed by the application.", - "ret": { - "type": "Result" - }, - "args": [ - { - "type": "Pipeline", - "name": "pipeline" - }, - { - "type": "DispatchConfigDesc", - "const": true, - "ref": true, - "name": "config" - }, - { - "type": "DispatchChain", - "const": true, - "ptr2x": true, - "name": "outDispatchDesc" - } - ] - }, - - "SaveImagesDesc": { - "type": "struct", - "name": "SaveImagesDesc", - "members": [ - { - "type": "const char*", - "name": "path", - "value": "\"\"" - }, - { - "type": "const char*", - "name": "filePostfix", - "value": "\"\"" - }, - { - "type": "bool", - "name": "detailedCutout", - "value": "false", - "comment": "The default behaviour is to dump the entire alpha texture with the OMM-triangle in it. Enabling detailedCutout will generate cropped version zoomed in on the OMM, and supersampled for detailed analysis" - }, - { - "type": "bool", - "name": "dumpOnlyFirstOMM", - "value": "false", - "comment": "Only dump index 0." - }, - { - "type": "bool", - "name": "monochromeUnknowns", - "value": "false", - "comment": "Will draw unknown transparent and unknown opaque in the same color." - }, - { - "type": "bool", - "name": "oneFile", - "value": "false", - "comment": "true:Will draw all primitives to the same file. false: will draw each primitive separatley." - } - ] - }, - - "fnSaveAsImages": { - "type": "function", - "name": "SaveAsImages", - "comment": "Walk each primitive and dumps the corresponding OMM overlay to the alpha textures.", - "ret": { - "type": "Result" - }, - "args": [ - { - "type": "Baker", - "name": "baker" - }, - { - "type": "BakeInputDesc", - "const": true, - "ref": true, - "name": "bakeInputDesc" - }, - { - "type": "BakeResultDesc", - "const": true, - "ptr": true, - "name": "res" - }, - { - "type": "SaveImagesDesc", - "const": true, - "ref": true, - "name": "desc" - } - ] - }, - - "Stats": { - "type": "struct", - "name": "Stats", - "members": [ - { - "type": "uint64_t", - "name": "totalOpaque", - "value": "0" - }, - { - "type": "uint64_t", - "name": "totalTransparent", - "value": "0" - }, - { - "type": "uint64_t", - "name": "totalUnknownTransparent", - "value": "0" - }, - { - "type": "uint64_t", - "name": "totalUnknownOpaque", - "value": "0" - }, - { - "type": "uint32_t", - "name": "totalFullyOpaque", - "value": "0" - }, - { - "type": "uint32_t", - "name": "totalFullyTransparent", - "value": "0" - }, - { - "type": "uint32_t", - "name": "totalFullyUnknownOpaque", - "value": "0" - }, - { - "type": "uint32_t", - "name": "totalFullyUnknownTransparent", - "value": "0" - } - ] - }, - - "fnGetStats": { - "type": "function", - "name": "GetStats", - "ret": { - "type": "Result" - }, - "args": [ - { - "type": "Baker", - "name": "baker" - }, - { - "type": "BakeResultDesc", - "const": true, - "ptr": true, - "name": "res" - }, - { - "type": "Stats", - "ptr": true, - "name": "out" - } - ] - }, - - "cpu": { - "type": "namespace", - "name": "Cpu", - "values": [ - "BakeResult", - "Texture", - "TextureFormat", - "TextureFlags", - "cpuBakeFlags", - "TextureMipDesc", - "TextureDesc", - "BakeInputDesc", - "OpacityMicromapDesc", - "OpacityMicromapUsageCount", - "BakeResultDesc", - "fnCreateTexture", - "fnDestroyTexture", - "fnBakeCPU", - "fnDestroyBakeResult", - "fnGetBakeResultDesc" - ] - }, - - "gpu": { - "type": "namespace", - "name": "Gpu", - "values": [ - "Pipeline", - "DescriptorType", - "ResourceType", - "PrimitiveTopology", - "PipelineType", - "DispatchType", - "BufferFormat", - "RasterCullMode", - "RenderAPI", - "ScratchMemoryBudget", - "gpuBakeFlags", - "Resource", - "DescriptorRangeDesc", - "BufferDesc", - "ShaderBytecode", - "ComputePipelineDesc", - "GraphicsPipelineInputElementDesc", - "GraphicsPipelineDesc", - "PipelineDesc", - "DescriptorSetDesc", - "ConstantBufferDesc", - "Viewport", - "ComputeDesc", - "ComputeIndirectDesc", - "DrawIndexedIndirectDesc", - "BeginLabelDesc", - "DispatchDesc", - "StaticSamplerDesc", - "SPIRVBindingOffsets", - "PipelineConfigDesc", - "PreDispatchInfo", - "DispatchConfigDesc", - "PipelineInfoDesc", - "PostDispatchInfo", - "DispatchChain", - "fnGetStaticResourceData", - "fnCreatePipeline", - "fnDestroyPipeline", - "fnGetPipelineDesc", - "fnGetPreDispatchInfo", - "fnDispatchGPU" - ] - }, - - "debug": { - "type": "namespace", - "name": "Debug", - "values": [ - "SaveImagesDesc", - "fnSaveAsImages", - "Stats", - "fnGetStats" - ] - }, - - "omm": { - "type": "namespace", - "name": "omm", - "values": [ - "Result", - "LibraryDesc", - "OpacityState", - "SpecialIndex", - "Format", - "UnknownStatePromotion", - "BakerType", - "TexCoordFormat", - "IndexFormat", - "TextureAddressMode", - "TextureFilterMode", - "AlphaMode", - "SamplerDesc", - "MemoryAllocatorInterface", - "BakerCreationDesc", - "Handle", - "Baker", - "fnGetLibraryDesc", - "fnCreateBaker", - "fnDestroyBaker", - "cpu", - "gpu", - "debug" - ] - }, - - "layout": [ - "omm" - ] -} \ No newline at end of file diff --git a/omm-sdk/scripts/omm_footer_cpp.txt b/omm-sdk/scripts/omm_footer_cpp.txt deleted file mode 100644 index e8ddd9b..0000000 --- a/omm-sdk/scripts/omm_footer_cpp.txt +++ /dev/null @@ -1,81 +0,0 @@ - -namespace omm -{ - static inline LibraryDesc GetLibraryDesc() - { - ommLibraryDesc res = ommGetLibraryDesc(); - return reinterpret_cast(res); - } - static inline Result CreateBaker(const BakerCreationDesc& bakeCreationDesc, Baker* outBaker) - { - static_assert(sizeof(BakerCreationDesc) == sizeof(ommBakerCreationDesc)); - return (Result)ommCreateBaker(reinterpret_cast(&bakeCreationDesc), (ommBaker*)outBaker); - } - static inline Result DestroyBaker(Baker baker) - { - return (Result)ommDestroyBaker((ommBaker)baker); - } - namespace Cpu - { - static inline Result CreateTexture(Baker baker, const TextureDesc& desc, Texture* outTexture) - { - return (Result)ommCpuCreateTexture((ommBaker)baker, reinterpret_cast(&desc), (ommCpuTexture*)outTexture); - } - static inline Result DestroyTexture(Baker baker, Texture texture) - { - return (Result)ommCpuDestroyTexture((ommBaker)baker, (ommCpuTexture)texture); - } - static inline Result Bake(Baker baker, const BakeInputDesc& bakeInputDesc, BakeResult* outBakeResult) - { - return (Result)ommCpuBake((ommBaker)baker, reinterpret_cast(&bakeInputDesc), (ommCpuBakeResult*)outBakeResult); - } - static inline Result DestroyBakeResult(BakeResult bakeResult) - { - return (Result)ommCpuDestroyBakeResult((ommCpuBakeResult)bakeResult); - } - static inline Result GetBakeResultDesc(BakeResult bakeResult, const BakeResultDesc** desc) - { - return (Result)ommCpuGetBakeResultDesc((ommCpuBakeResult)bakeResult, reinterpret_cast(desc)); - } - } - namespace Gpu - { - static inline Result GetStaticResourceData(ResourceType resource, uint8_t* data, size_t* outByteSize) - { - return (Result)ommGpuGetStaticResourceData((ommGpuResourceType)resource, data, outByteSize); - } - static inline Result CreatePipeline(Baker baker, const PipelineConfigDesc& pipelineCfg, Pipeline* outPipeline) - { - return (Result)ommGpuCreatePipeline((ommBaker)baker, reinterpret_cast(&pipelineCfg), (ommGpuPipeline*)outPipeline); - } - static inline Result DestroyPipeline(Baker baker, Pipeline pipeline) - { - return (Result)ommGpuDestroyPipeline((ommBaker)baker, (ommGpuPipeline)pipeline); - } - static inline Result GetPipelineDesc(Pipeline pipeline, const PipelineInfoDesc** outPipelineDesc) - { - return (Result)ommGpuGetPipelineDesc((ommGpuPipeline)pipeline, reinterpret_cast(outPipelineDesc)); - } - static inline Result GetPreDispatchInfo(Pipeline pipeline, const DispatchConfigDesc& config, PreDispatchInfo* outPreBuildInfo) - { - return (Result)ommGpuGetPreDispatchInfo((ommGpuPipeline)pipeline, reinterpret_cast(&config), reinterpret_cast(outPreBuildInfo)); - } - static inline Result Dispatch(Pipeline pipeline, const DispatchConfigDesc& config, const DispatchChain** outDispatchDesc) - { - return (Result)ommGpuDispatch((ommGpuPipeline)pipeline, reinterpret_cast(&config), reinterpret_cast(outDispatchDesc)); - } - } - namespace Debug - { - static inline Result SaveAsImages(Baker baker, const Cpu::BakeInputDesc& bakeInputDesc, const Cpu::BakeResultDesc* res, const SaveImagesDesc& desc) - { - return (Result)ommDebugSaveAsImages((ommBaker)baker, reinterpret_cast(&bakeInputDesc), reinterpret_cast(res), reinterpret_cast(&desc)); - } - static inline Result GetStats(Baker baker, const Cpu::BakeResultDesc* res, Stats* out) - { - return (Result)ommDebugGetStats((ommBaker)baker, reinterpret_cast(res), reinterpret_cast(out)); - } - } -} - -#endif // #ifndef INCLUDE_OMM_SDK_CPP \ No newline at end of file diff --git a/omm-sdk/scripts/omm_header_c.txt b/omm-sdk/scripts/omm_header_c.txt deleted file mode 100644 index be155fb..0000000 --- a/omm-sdk/scripts/omm_header_c.txt +++ /dev/null @@ -1,49 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -#ifndef INCLUDE_OMM_SDK_C -#define INCLUDE_OMM_SDK_C - -#include -#include - -#define OMM_VERSION_MAJOR 1 -#define OMM_VERSION_MINOR 1 -#define OMM_VERSION_BUILD 1 - -#define OMM_MAX_TRANSIENT_POOL_BUFFERS 8 - -#define OMM_GRAPHICS_PIPELINE_DESC_VERSION 3 - -#if defined(_MSC_VER) - #define OMM_CALL __fastcall -#elif !defined(__aarch64__) && !defined(__x86_64) && (defined(__GNUC__) || defined (__clang__)) - #define OMM_CALL __attribute__((fastcall)) -#else - #define OMM_CALL -#endif - -#ifndef OMM_API - #ifdef __cplusplus - #define OMM_API extern "C" - #else - #define OMM_API - #endif -#endif - -#ifdef DEFINE_ENUM_FLAG_OPERATORS -#define OMM_DEFINE_ENUM_FLAG_OPERATORS(x) DEFINE_ENUM_FLAG_OPERATORS(x) -#else -#define OMM_DEFINE_ENUM_FLAG_OPERATORS(x) -#endif - -typedef void* (*ommAllocate)(void* userArg, size_t size, size_t alignment); -typedef void* (*ommReallocate)(void* userArg, void* memory, size_t size, size_t alignment); -typedef void (*ommFree)(void* userArg, void* memory); \ No newline at end of file diff --git a/omm-sdk/scripts/omm_header_cpp.txt b/omm-sdk/scripts/omm_header_cpp.txt deleted file mode 100644 index 8db1284..0000000 --- a/omm-sdk/scripts/omm_header_cpp.txt +++ /dev/null @@ -1,14 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -#ifndef INCLUDE_OMM_SDK_CPP -#define INCLUDE_OMM_SDK_CPP - -#include "omm.h" diff --git a/omm-sdk/shaders/omm.hlsli b/omm-sdk/shaders/omm.hlsli index abf70cb..1185fb7 100644 --- a/omm-sdk/shaders/omm.hlsli +++ b/omm-sdk/shaders/omm.hlsli @@ -38,6 +38,14 @@ enum class SpecialIndex : int { FullyUnknownOpaque = -4, }; +enum class TexCoordFormat : int { + UV16_UNORM, + UV16_FLOAT, + UV32_FLOAT, + + MAX_NUM +}; + OpacityState _getOpacityStateInternal(uint numOpaque, uint numTransparent) { if (numOpaque == 0) diff --git a/omm-sdk/shaders/clear_buffer.cs.hlsl b/omm-sdk/shaders/omm_clear_buffer.cs.hlsl similarity index 82% rename from omm-sdk/shaders/clear_buffer.cs.hlsl rename to omm-sdk/shaders/omm_clear_buffer.cs.hlsl index 2b73e5f..11f9381 100644 --- a/omm-sdk/shaders/clear_buffer.cs.hlsl +++ b/omm-sdk/shaders/omm_clear_buffer.cs.hlsl @@ -8,17 +8,13 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -#include "platform.hlsli" -#include "clear_buffer.cs.resources.hlsli" +#include "omm_platform.hlsli" +#include "omm_clear_buffer.cs.resources.hlsli" OMM_DECLARE_LOCAL_CONSTANT_BUFFER OMM_DECLARE_OUTPUT_RESOURCES OMM_DECLARE_INPUT_RESOURCES -uint GetNumMicroTri(uint subdivisionLevel) { - return (1u << (subdivisionLevel << 1u)); -} - [numthreads(128, 1, 1)] void main(uint3 tid : SV_DispatchThreadID) { diff --git a/omm-sdk/shaders/clear_buffer.cs.resources.hlsli b/omm-sdk/shaders/omm_clear_buffer.cs.resources.hlsli similarity index 100% rename from omm-sdk/shaders/clear_buffer.cs.resources.hlsli rename to omm-sdk/shaders/omm_clear_buffer.cs.resources.hlsli diff --git a/omm-sdk/shaders/omm_work_setup_common.hlsli b/omm-sdk/shaders/omm_common.hlsli similarity index 73% rename from omm-sdk/shaders/omm_work_setup_common.hlsli rename to omm-sdk/shaders/omm_common.hlsli index ebe3c3b..8932374 100644 --- a/omm-sdk/shaders/omm_work_setup_common.hlsli +++ b/omm-sdk/shaders/omm_common.hlsli @@ -11,7 +11,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #ifndef WORK_SETUP_COMMON_HLSLI #define WORK_SETUP_COMMON_HLSLI -#include "platform.hlsli" +#include "omm_platform.hlsli" #include "omm.hlsli" #include "omm_global_cb.hlsli" #include "omm_global_samplers.hlsli" @@ -99,6 +99,22 @@ uint GetHash(TexCoords tex, uint subdivisionLevel) seed); } +float2 UnpackUNORM16Pair(uint packed) +{ + float2 data; + data.x = float(packed & 0x0000FFFF) / float(0xFFFF); + data.y = float((packed >> 16u) & 0x0000FFFF) / float(0xFFFF); + return data; +} + +float2 UnpackFP16Pair(uint packed) +{ + uint2 data; + data.x = packed & 0x0000FFFF; + data.y = (packed >> 16u) & 0x0000FFFF; + return f16tof32(data); +} + TexCoords FetchTexCoords(Buffer indexBuffer, ByteAddressBuffer texCoordBuffer, uint primitiveIndex) { uint3 indices; @@ -107,9 +123,25 @@ TexCoords FetchTexCoords(Buffer indexBuffer, ByteAddressBuffer texCoordBuf indices.z = indexBuffer[primitiveIndex * 3 + 2]; float2 vertexUVs[3]; - vertexUVs[0] = asfloat(texCoordBuffer.Load2(g_GlobalConstants.TexCoord1Offset + indices.x * g_GlobalConstants.TexCoord1Stride)); - vertexUVs[1] = asfloat(texCoordBuffer.Load2(g_GlobalConstants.TexCoord1Offset + indices.y * g_GlobalConstants.TexCoord1Stride)); - vertexUVs[2] = asfloat(texCoordBuffer.Load2(g_GlobalConstants.TexCoord1Offset + indices.z * g_GlobalConstants.TexCoord1Stride)); + + if ((TexCoordFormat)g_GlobalConstants.TexCoord1Format == TexCoordFormat::UV16_UNORM) + { + vertexUVs[0] = UnpackUNORM16Pair(texCoordBuffer.Load(g_GlobalConstants.TexCoord1Offset + indices.x * g_GlobalConstants.TexCoord1Stride)); + vertexUVs[1] = UnpackUNORM16Pair(texCoordBuffer.Load(g_GlobalConstants.TexCoord1Offset + indices.y * g_GlobalConstants.TexCoord1Stride)); + vertexUVs[2] = UnpackUNORM16Pair(texCoordBuffer.Load(g_GlobalConstants.TexCoord1Offset + indices.z * g_GlobalConstants.TexCoord1Stride)); + } + else if ((TexCoordFormat)g_GlobalConstants.TexCoord1Format == TexCoordFormat::UV16_FLOAT) + { + vertexUVs[0] = UnpackFP16Pair(texCoordBuffer.Load(g_GlobalConstants.TexCoord1Offset + indices.x * g_GlobalConstants.TexCoord1Stride)); + vertexUVs[1] = UnpackFP16Pair(texCoordBuffer.Load(g_GlobalConstants.TexCoord1Offset + indices.y * g_GlobalConstants.TexCoord1Stride)); + vertexUVs[2] = UnpackFP16Pair(texCoordBuffer.Load(g_GlobalConstants.TexCoord1Offset + indices.z * g_GlobalConstants.TexCoord1Stride)); + } + else // if (g_GlobalConstants.TexCoord1Format == TexCoordFormat::UV32_FLOAT) + { + vertexUVs[0] = asfloat(texCoordBuffer.Load2(g_GlobalConstants.TexCoord1Offset + indices.x * g_GlobalConstants.TexCoord1Stride)); + vertexUVs[1] = asfloat(texCoordBuffer.Load2(g_GlobalConstants.TexCoord1Offset + indices.y * g_GlobalConstants.TexCoord1Stride)); + vertexUVs[2] = asfloat(texCoordBuffer.Load2(g_GlobalConstants.TexCoord1Offset + indices.z * g_GlobalConstants.TexCoord1Stride)); + } TexCoords tex; tex.Init(vertexUVs[0], vertexUVs[1], vertexUVs[2]); diff --git a/omm-sdk/shaders/omm_compress.cs.hlsl b/omm-sdk/shaders/omm_compress.cs.hlsl index a973250..3de6315 100644 --- a/omm-sdk/shaders/omm_compress.cs.hlsl +++ b/omm-sdk/shaders/omm_compress.cs.hlsl @@ -8,7 +8,7 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -#include "platform.hlsli" +#include "omm_platform.hlsli" #include "omm.hlsli" #include "omm_global_cb.hlsli" #include "omm_global_samplers.hlsli" diff --git a/omm-sdk/shaders/omm_desc_patch.cs.hlsl b/omm-sdk/shaders/omm_desc_patch.cs.hlsl index 273b41b..c8b1ba4 100644 --- a/omm-sdk/shaders/omm_desc_patch.cs.hlsl +++ b/omm-sdk/shaders/omm_desc_patch.cs.hlsl @@ -8,7 +8,7 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -#include "platform.hlsli" +#include "omm_platform.hlsli" #include "omm.hlsli" #include "omm_global_cb.hlsli" #include "omm_global_samplers.hlsli" diff --git a/omm-sdk/shaders/omm_global_cb.hlsli b/omm-sdk/shaders/omm_global_cb.hlsli index 5cd203e..87753d2 100644 --- a/omm-sdk/shaders/omm_global_cb.hlsli +++ b/omm-sdk/shaders/omm_global_cb.hlsli @@ -32,14 +32,19 @@ OMM_CONSTANTS_START(GlobalConstants) \ OMM_CONSTANT(uint, TexCoordHashTableEntryCount) \ \ OMM_CONSTANT(float, DynamicSubdivisionScale) \ + OMM_CONSTANT(uint, TexCoord1Format) \ OMM_CONSTANT(uint, TexCoord1Offset) \ OMM_CONSTANT(uint, TexCoord1Stride) \ - OMM_CONSTANT(float, AlphaCutoff) \ \ + OMM_CONSTANT(float, AlphaCutoff) \ OMM_CONSTANT(uint, AlphaTextureChannel) \ OMM_CONSTANT(uint, FilterType) /* TextureFilterMode */ \ OMM_CONSTANT(uint, EnableLevelLine) \ + \ OMM_CONSTANT(uint, EnablePostDispatchInfoStats) \ + OMM_CONSTANT(uint, IndirectDispatchEntryStride) \ + OMM_CONSTANT(uint, Pad1) \ + OMM_CONSTANT(uint, Pad2) \ \ OMM_CONSTANT(float2, TexSize) \ OMM_CONSTANT(float2, InvTexSize) \ diff --git a/omm-sdk/shaders/omm_hash_table.hlsli b/omm-sdk/shaders/omm_hash_table.hlsli index 3394a89..bb3e240 100644 --- a/omm-sdk/shaders/omm_hash_table.hlsli +++ b/omm-sdk/shaders/omm_hash_table.hlsli @@ -8,11 +8,11 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -#include "platform.hlsli" +#include "omm_platform.hlsli" #include "omm.hlsli" #include "omm_global_cb.hlsli" #include "omm_global_samplers.hlsli" -#include "omm_work_setup_common.hlsli" +#include "omm_common.hlsli" namespace hashTable { diff --git a/omm-sdk/shaders/omm_index_write.cs.hlsl b/omm-sdk/shaders/omm_index_write.cs.hlsl index dfc4262..f7c7452 100644 --- a/omm-sdk/shaders/omm_index_write.cs.hlsl +++ b/omm-sdk/shaders/omm_index_write.cs.hlsl @@ -9,7 +9,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. */ -#include "platform.hlsli" +#include "omm_platform.hlsli" #include "omm.hlsli" #include "omm_global_cb.hlsli" #include "omm_global_samplers.hlsli" diff --git a/omm-sdk/shaders/omm_init_buffers_cs.cs.hlsl b/omm-sdk/shaders/omm_init_buffers_cs.cs.hlsl index 2ddf920..44d8bf7 100644 --- a/omm-sdk/shaders/omm_init_buffers_cs.cs.hlsl +++ b/omm-sdk/shaders/omm_init_buffers_cs.cs.hlsl @@ -8,7 +8,7 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -#include "platform.hlsli" +#include "omm_platform.hlsli" #include "omm_global_cb.hlsli" #include "omm_global_samplers.hlsli" #include "omm_init_buffers_cs.cs.resources.hlsli" @@ -28,7 +28,7 @@ void main(uint3 tid : SV_DispatchThreadID) const uint subdivisionLevel = tid.x; - const uint strideInBytes = 12; + const uint strideInBytes = g_GlobalConstants.IndirectDispatchEntryStride; OMM_SUBRESOURCE_STORE(IEBakeCsBuffer, strideInBytes * tid.x + 0, 0); OMM_SUBRESOURCE_STORE(IEBakeCsBuffer, strideInBytes * tid.x + 4, 1); diff --git a/omm-sdk/shaders/omm_init_buffers_gfx.cs.hlsl b/omm-sdk/shaders/omm_init_buffers_gfx.cs.hlsl index 9c07ffe..232d49b 100644 --- a/omm-sdk/shaders/omm_init_buffers_gfx.cs.hlsl +++ b/omm-sdk/shaders/omm_init_buffers_gfx.cs.hlsl @@ -8,7 +8,7 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -#include "platform.hlsli" +#include "omm_platform.hlsli" #include "omm_global_cb.hlsli" #include "omm_global_samplers.hlsli" #include "omm_init_buffers_gfx.cs.resources.hlsli" @@ -34,7 +34,7 @@ void main(uint3 tid : SV_DispatchThreadID) const uint batchIndex = tid.x % g_GlobalConstants.MaxBatchCount; { - const uint strideInBytes = 20; + const uint strideInBytes = g_GlobalConstants.IndirectDispatchEntryStride; OMM_SUBRESOURCE_STORE(IEBakeBuffer, strideInBytes * tid.x + 0, 3 * GetNumMicroTri(subdivisionLevel)); /*IndexCountPerInstance*/ OMM_SUBRESOURCE_STORE(IEBakeBuffer, strideInBytes * tid.x + 4, 0);/*InstanceCount*/ @@ -44,7 +44,7 @@ void main(uint3 tid : SV_DispatchThreadID) } { - const uint strideInBytes = 12; + const uint strideInBytes = g_GlobalConstants.IndirectDispatchEntryStride; OMM_SUBRESOURCE_STORE(IECompressCsBuffer, strideInBytes * tid.x + 0, 0); OMM_SUBRESOURCE_STORE(IECompressCsBuffer, strideInBytes * tid.x + 4, 1); diff --git a/omm-sdk/shaders/platform.hlsli b/omm-sdk/shaders/omm_platform.hlsli similarity index 100% rename from omm-sdk/shaders/platform.hlsli rename to omm-sdk/shaders/omm_platform.hlsli diff --git a/omm-sdk/shaders/omm_post_build_info.cs.hlsl b/omm-sdk/shaders/omm_post_build_info.cs.hlsl index a899d97..f3104da 100644 --- a/omm-sdk/shaders/omm_post_build_info.cs.hlsl +++ b/omm-sdk/shaders/omm_post_build_info.cs.hlsl @@ -8,7 +8,7 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -#include "platform.hlsli" +#include "omm_platform.hlsli" #include "omm.hlsli" #include "omm_global_cb.hlsli" diff --git a/omm-sdk/shaders/omm_rasterize.gs.hlsl b/omm-sdk/shaders/omm_rasterize.gs.hlsl index 1081181..0219078 100644 --- a/omm-sdk/shaders/omm_rasterize.gs.hlsl +++ b/omm-sdk/shaders/omm_rasterize.gs.hlsl @@ -8,7 +8,7 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -#include "platform.hlsli" +#include "omm_platform.hlsli" #include "omm.hlsli" #include "omm_global_cb.hlsli" #include "omm_global_samplers.hlsli" diff --git a/omm-sdk/shaders/omm_rasterize.vs.hlsl b/omm-sdk/shaders/omm_rasterize.vs.hlsl index 091b042..ab44861 100644 --- a/omm-sdk/shaders/omm_rasterize.vs.hlsl +++ b/omm-sdk/shaders/omm_rasterize.vs.hlsl @@ -8,7 +8,7 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -#include "platform.hlsli" +#include "omm_platform.hlsli" #include "omm.hlsli" #include "omm_global_cb.hlsli" #include "omm_global_samplers.hlsli" diff --git a/omm-sdk/shaders/omm_rasterize_common.vs.hlsli b/omm-sdk/shaders/omm_rasterize_common.vs.hlsli index 57a43cc..84eb267 100644 --- a/omm-sdk/shaders/omm_rasterize_common.vs.hlsli +++ b/omm-sdk/shaders/omm_rasterize_common.vs.hlsli @@ -13,6 +13,8 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. // each i_pos is the discrete 2D barycentric coordinate packed. // The resulting texture coord is then mapped to a raster position in the vertex shader. +#include "omm_common.hlsli" + float2 GetTexCoordForVertex( uint i_pos, // : POSITION uint i_primitiveIndex // : SV_InstanceID @@ -24,19 +26,11 @@ float2 GetTexCoordForVertex( const OMMFormat vmFormat = (OMMFormat)(vmFormatAndPrimitiveIndex >> 30); const uint primitiveIndex = vmFormatAndPrimitiveIndex & 0x3FFFFFFF; - uint3 indices; - indices.x = t_indexBuffer[primitiveIndex * 3 + 0]; - indices.y = t_indexBuffer[primitiveIndex * 3 + 1]; - indices.z = t_indexBuffer[primitiveIndex * 3 + 2]; - - float2 vertexUVs[3]; - vertexUVs[0] = asfloat(t_texCoordBuffer.Load2(g_GlobalConstants.TexCoord1Offset + indices.x * g_GlobalConstants.TexCoord1Stride)); - vertexUVs[1] = asfloat(t_texCoordBuffer.Load2(g_GlobalConstants.TexCoord1Offset + indices.y * g_GlobalConstants.TexCoord1Stride)); - vertexUVs[2] = asfloat(t_texCoordBuffer.Load2(g_GlobalConstants.TexCoord1Offset + indices.z * g_GlobalConstants.TexCoord1Stride)); + const TexCoords texCoords = FetchTexCoords(t_indexBuffer, t_texCoordBuffer, primitiveIndex); - const float2 p0 = vertexUVs[0]; - const float2 v0 = (vertexUVs[1] - p0); - const float2 v1 = vertexUVs[2] - p0; + const float2 p0 = texCoords.p0; + const float2 v0 = texCoords.p1 - p0; + const float2 v1 = texCoords.p2 - p0; const uint N = 1u << g_LocalConstants.SubdivisionLevel; const uint i = (i_pos & 0xFFFF); diff --git a/omm-sdk/shaders/omm_rasterize_cs.hlsli b/omm-sdk/shaders/omm_rasterize_cs.hlsli index eb84ef6..982d233 100644 --- a/omm-sdk/shaders/omm_rasterize_cs.hlsli +++ b/omm-sdk/shaders/omm_rasterize_cs.hlsli @@ -20,7 +20,7 @@ * DEALINGS IN THE SOFTWARE. */ -#include "platform.hlsli" +#include "omm_platform.hlsli" #include "omm.hlsli" #include "omm_global_cb.hlsli" #include "omm_global_samplers.hlsli" @@ -33,6 +33,7 @@ OMM_DECLARE_INPUT_RESOURCES OMM_DECLARE_OUTPUT_RESOURCES OMM_DECLARE_SUBRESOURCES +#include "omm_common.hlsli" #include "omm_resample_common.hlsli" namespace bird @@ -168,10 +169,6 @@ PRECISE float2 InterpolateTriangleUV(float3 bc, Triangle triangleUVs) return triangleUVs.p[0] * bc.x + triangleUVs.p[1] * bc.y + triangleUVs.p[2] * bc.z; } -uint GetNumMicroTriangles(uint numSubdivisionLevels) { - return 1u << (numSubdivisionLevels << 1u); -} - Triangle GetMicroTriangle(const Triangle t, uint index, uint subdivisionLevel) { float2 uv0; @@ -197,18 +194,10 @@ Triangle GetMacroTriangle(uint iPrimitiveIndex, out uint vmArrayOffset, out uint vmFormat = (OMMFormat)(vmFormatAndPrimitiveIndex >> 30); vmPrimitiveIndex = vmFormatAndPrimitiveIndex & 0x3FFFFFFF; - uint3 indices; - indices.x = t_indexBuffer[vmPrimitiveIndex * 3 + 0]; - indices.y = t_indexBuffer[vmPrimitiveIndex * 3 + 1]; - indices.z = t_indexBuffer[vmPrimitiveIndex * 3 + 2]; - - PRECISE float2 vertexUVs[3]; - vertexUVs[0] = asfloat(t_texCoordBuffer.Load2(g_GlobalConstants.TexCoord1Offset + indices.x * g_GlobalConstants.TexCoord1Stride)); - vertexUVs[1] = asfloat(t_texCoordBuffer.Load2(g_GlobalConstants.TexCoord1Offset + indices.y * g_GlobalConstants.TexCoord1Stride)); - vertexUVs[2] = asfloat(t_texCoordBuffer.Load2(g_GlobalConstants.TexCoord1Offset + indices.z * g_GlobalConstants.TexCoord1Stride)); + const TexCoords texCoords = FetchTexCoords(t_indexBuffer, t_texCoordBuffer, vmPrimitiveIndex); Triangle retT; - retT.Init(vertexUVs[0], vertexUVs[1], vertexUVs[2]); + retT.Init(texCoords.p0, texCoords.p1, texCoords.p2); return retT; } diff --git a/omm-sdk/shaders/omm_rasterize_debug.ps.hlsl b/omm-sdk/shaders/omm_rasterize_debug.ps.hlsl index f2d8421..c304cd3 100644 --- a/omm-sdk/shaders/omm_rasterize_debug.ps.hlsl +++ b/omm-sdk/shaders/omm_rasterize_debug.ps.hlsl @@ -8,7 +8,7 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -#include "platform.hlsli" +#include "omm_platform.hlsli" #include "omm.hlsli" #include "omm_global_cb.hlsli" #include "omm_global_samplers.hlsli" diff --git a/omm-sdk/shaders/omm_rasterize_debug.vs.hlsl b/omm-sdk/shaders/omm_rasterize_debug.vs.hlsl index 9c9a743..2a0c2fa 100644 --- a/omm-sdk/shaders/omm_rasterize_debug.vs.hlsl +++ b/omm-sdk/shaders/omm_rasterize_debug.vs.hlsl @@ -8,7 +8,7 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -#include "platform.hlsli" +#include "omm_platform.hlsli" #include "omm.hlsli" #include "omm_global_cb.hlsli" #include "omm_global_samplers.hlsli" diff --git a/omm-sdk/shaders/omm_rasterize_ps.hlsli b/omm-sdk/shaders/omm_rasterize_ps.hlsli index a365207..805eaa7 100644 --- a/omm-sdk/shaders/omm_rasterize_ps.hlsli +++ b/omm-sdk/shaders/omm_rasterize_ps.hlsli @@ -8,7 +8,7 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -#include "platform.hlsli" +#include "omm_platform.hlsli" #include "omm.hlsli" #include "omm_global_cb.hlsli" #include "omm_global_samplers.hlsli" diff --git a/omm-sdk/shaders/render_target_clear.ps.hlsl b/omm-sdk/shaders/omm_render_target_clear.ps.hlsl similarity index 85% rename from omm-sdk/shaders/render_target_clear.ps.hlsl rename to omm-sdk/shaders/omm_render_target_clear.ps.hlsl index 95563b6..2d3dcf9 100644 --- a/omm-sdk/shaders/render_target_clear.ps.hlsl +++ b/omm-sdk/shaders/omm_render_target_clear.ps.hlsl @@ -8,8 +8,8 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -#include "platform.hlsli" -#include "render_target_clear.ps.resources.hlsli" +#include "omm_platform.hlsli" +#include "omm_render_target_clear.ps.resources.hlsli" void main(out float4 o_color : SV_Target0) { diff --git a/omm-sdk/shaders/render_target_clear.ps.resources.hlsli b/omm-sdk/shaders/omm_render_target_clear.ps.resources.hlsli similarity index 100% rename from omm-sdk/shaders/render_target_clear.ps.resources.hlsli rename to omm-sdk/shaders/omm_render_target_clear.ps.resources.hlsli diff --git a/omm-sdk/shaders/omm_resample_common.hlsli b/omm-sdk/shaders/omm_resample_common.hlsli index b661063..6278cc5 100644 --- a/omm-sdk/shaders/omm_resample_common.hlsli +++ b/omm-sdk/shaders/omm_resample_common.hlsli @@ -242,19 +242,18 @@ namespace raster const bool IsOpaque2 = g_GlobalConstants.AlphaCutoff < gatherAlphaSwizzled.z; const bool IsOpaque3 = g_GlobalConstants.AlphaCutoff < gatherAlphaSwizzled.w; - { - IsOpaque |= IsInside0 && IsOpaque0; - IsTransparent |= IsInside0 && !IsOpaque0; - - IsOpaque |= IsInside1 && IsOpaque1; - IsTransparent |= IsInside1 && !IsOpaque1; - - IsOpaque |= IsInside2 && IsOpaque2; - IsTransparent |= IsInside2 && !IsOpaque2; - - IsOpaque |= IsInside3 && IsOpaque3; - IsTransparent |= IsInside3 && !IsOpaque3; - } + IsOpaque = IsOpaque || + (IsInside0 && IsOpaque0) || + (IsInside1 && IsOpaque1) || + (IsInside2 && IsOpaque2) || + (IsInside3 && IsOpaque3); + + IsTransparent = IsTransparent || + (IsInside0 && !IsOpaque0) || + (IsInside1 && !IsOpaque1) || + (IsInside2 && !IsOpaque2) || + (IsInside3 && !IsOpaque3); + // We've already concluded it's unknown -> return! if (IsOpaque && IsTransparent) diff --git a/omm-sdk/shaders/omm_work_setup_bake_only_cs.cs.hlsl b/omm-sdk/shaders/omm_work_setup_bake_only_cs.cs.hlsl index af9aed2..f351470 100644 --- a/omm-sdk/shaders/omm_work_setup_bake_only_cs.cs.hlsl +++ b/omm-sdk/shaders/omm_work_setup_bake_only_cs.cs.hlsl @@ -8,7 +8,7 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -#include "platform.hlsli" +#include "omm_platform.hlsli" #include "omm.hlsli" #include "omm_global_cb.hlsli" #include "omm_global_samplers.hlsli" @@ -20,7 +20,7 @@ OMM_DECLARE_INPUT_RESOURCES OMM_DECLARE_OUTPUT_RESOURCES OMM_DECLARE_SUBRESOURCES -#include "omm_work_setup_common.hlsli" +#include "omm_common.hlsli" uint TryScheduledForBake(uint ommDescIndex, uint primitiveIndex) { @@ -121,7 +121,7 @@ void main(uint3 tid : SV_DispatchThreadID) // Increment the drawcall count for the current batch & subdivisiolevel. { - const uint strideInBytes = 12; // arg count of Dispatch + const uint strideInBytes = g_GlobalConstants.IndirectDispatchEntryStride; // arg count of Dispatch const uint ThreadCountXOffsetInBytes = 0; // offset of ThreadCountX in Dispatch const uint offset = ThreadCountXOffsetInBytes + strideInBytes * subdivisionLevel; diff --git a/omm-sdk/shaders/omm_work_setup_bake_only_gfx.cs.hlsl b/omm-sdk/shaders/omm_work_setup_bake_only_gfx.cs.hlsl index 1fd873a..269b72c 100644 --- a/omm-sdk/shaders/omm_work_setup_bake_only_gfx.cs.hlsl +++ b/omm-sdk/shaders/omm_work_setup_bake_only_gfx.cs.hlsl @@ -8,7 +8,7 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -#include "platform.hlsli" +#include "omm_platform.hlsli" #include "omm.hlsli" #include "omm_global_cb.hlsli" #include "omm_global_samplers.hlsli" @@ -20,7 +20,7 @@ OMM_DECLARE_INPUT_RESOURCES OMM_DECLARE_OUTPUT_RESOURCES OMM_DECLARE_SUBRESOURCES -#include "omm_work_setup_common.hlsli" +#include "omm_common.hlsli" bool TryScheduledForBake(uint ommDescIndex) { @@ -116,7 +116,7 @@ void main(uint3 tid : SV_DispatchThreadID) // Increment the drawcall count for the current batch & subdivisiolevel. { - const uint strideInBytes = 20; // arg count of DrawIndexedInstanced + const uint strideInBytes = g_GlobalConstants.IndirectDispatchEntryStride; // arg count of DrawIndexedInstanced const uint InstanceCountOffsetInBytes = 4; // offset of InstanceCount in DrawIndexedInstanced const uint offset = InstanceCountOffsetInBytes + strideInBytes * (subdivisionLevel * g_GlobalConstants.MaxBatchCount + bakeResultBatchIndex); @@ -144,7 +144,7 @@ void main(uint3 tid : SV_DispatchThreadID) // Increment the thread GROUP count for the current batch & subdivisiolevel. { - const uint strideInBytes = 12; // arg count of Dispatch + const uint strideInBytes = g_GlobalConstants.IndirectDispatchEntryStride; // arg count of Dispatch const uint ThreadCountXOffsetInBytes = 0; // offset of ThreadCountX in Dispatch const uint offset = ThreadCountXOffsetInBytes + strideInBytes * (subdivisionLevel * g_GlobalConstants.MaxBatchCount + bakeResultBatchIndex); diff --git a/omm-sdk/shaders/omm_work_setup_cs.cs.hlsl b/omm-sdk/shaders/omm_work_setup_cs.cs.hlsl index 537910b..c4c6e68 100644 --- a/omm-sdk/shaders/omm_work_setup_cs.cs.hlsl +++ b/omm-sdk/shaders/omm_work_setup_cs.cs.hlsl @@ -8,7 +8,7 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -#include "platform.hlsli" +#include "omm_platform.hlsli" #include "omm.hlsli" #include "omm_global_cb.hlsli" #include "omm_global_samplers.hlsli" @@ -20,7 +20,7 @@ OMM_DECLARE_INPUT_RESOURCES OMM_DECLARE_OUTPUT_RESOURCES OMM_DECLARE_SUBRESOURCES -#include "omm_work_setup_common.hlsli" +#include "omm_common.hlsli" #include "omm_hash_table.hlsli" [numthreads(128, 1, 1)] @@ -133,7 +133,7 @@ void main(uint3 tid : SV_DispatchThreadID) // Increment the drawcall count for the current batch & subdivisiolevel. { - const uint strideInBytes = 12; // arg count of Dispatch + const uint strideInBytes = g_GlobalConstants.IndirectDispatchEntryStride; // arg count of Dispatch const uint ThreadCountXOffsetInBytes = 0; // offset of ThreadCountX in Dispatch const uint offset = ThreadCountXOffsetInBytes + strideInBytes * subdivisionLevel; diff --git a/omm-sdk/shaders/omm_work_setup_gfx.cs.hlsl b/omm-sdk/shaders/omm_work_setup_gfx.cs.hlsl index bb77c41..0bbf55f 100644 --- a/omm-sdk/shaders/omm_work_setup_gfx.cs.hlsl +++ b/omm-sdk/shaders/omm_work_setup_gfx.cs.hlsl @@ -8,7 +8,7 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -#include "platform.hlsli" +#include "omm_platform.hlsli" #include "omm.hlsli" #include "omm_global_cb.hlsli" @@ -21,7 +21,7 @@ OMM_DECLARE_INPUT_RESOURCES OMM_DECLARE_OUTPUT_RESOURCES OMM_DECLARE_SUBRESOURCES -#include "omm_work_setup_common.hlsli" +#include "omm_common.hlsli" #include "omm_hash_table.hlsli" [numthreads(128, 1, 1)] @@ -119,7 +119,7 @@ void main(uint3 tid : SV_DispatchThreadID) // Increment the drawcall count for the current batch & subdivisiolevel. { - const uint strideInBytes = 20; // arg count of DrawIndexedInstanced + const uint strideInBytes = g_GlobalConstants.IndirectDispatchEntryStride; // arg count of DrawIndexedInstanced const uint InstanceCountOffsetInBytes = 4; // offset of InstanceCount in DrawIndexedInstanced const uint offset = InstanceCountOffsetInBytes + strideInBytes * (subdivisionLevel * g_GlobalConstants.MaxBatchCount + bakeResultBatchIndex); @@ -147,7 +147,7 @@ void main(uint3 tid : SV_DispatchThreadID) // Increment the thread GROUP count for the current batch & subdivisiolevel. { - const uint strideInBytes = 12; // arg count of Dispatch + const uint strideInBytes = g_GlobalConstants.IndirectDispatchEntryStride; // arg count of Dispatch const uint ThreadCountXOffsetInBytes = 0; // offset of ThreadCountX in Dispatch const uint offset = ThreadCountXOffsetInBytes + strideInBytes * (subdivisionLevel * g_GlobalConstants.MaxBatchCount + bakeResultBatchIndex); diff --git a/omm-sdk/src/bake.cpp b/omm-sdk/src/bake.cpp index 065dfc4..bd02339 100644 --- a/omm-sdk/src/bake.cpp +++ b/omm-sdk/src/bake.cpp @@ -57,15 +57,17 @@ OMM_API ommResult OMM_CALL ommCpuCreateTexture(ommBaker baker, const ommCpuTextu { if (baker == 0) return ommResult_INVALID_ARGUMENT; + + Cpu::BakerImpl* impl = GetBakerImpl(baker); + if (desc == 0) - return ommResult_INVALID_ARGUMENT; + return impl->GetLog().InvalidArg("texture desc was not set"); if (GetBakerType(baker) != ommBakerType_CPU) - return ommResult_INVALID_ARGUMENT; + return impl->GetLog().InvalidArg("Baker was not created as the right type"); - Cpu::BakerImpl* impl = GetBakerImpl(baker); StdAllocator& memoryAllocator = (*impl).GetStdAllocator(); - TextureImpl* implementation = Allocate(memoryAllocator, memoryAllocator); + TextureImpl* implementation = Allocate(memoryAllocator, memoryAllocator, impl->GetLog()); const ommResult result = implementation->Create(*desc); if (result == ommResult_SUCCESS) @@ -82,10 +84,12 @@ OMM_API ommResult OMM_CALL ommCpuDestroyTexture(ommBaker baker, ommCpuTexture te { if (texture == 0) return ommResult_INVALID_ARGUMENT; - if (GetBakerType(baker) != ommBakerType_CPU) - return ommResult_INVALID_ARGUMENT; Cpu::BakerImpl* impl = GetBakerImpl(baker); + + if (GetBakerType(baker) != ommBakerType_CPU) + return impl->GetLog().InvalidArg("Baker was not created as the right type"); + StdAllocator& memoryAllocator = (*impl).GetStdAllocator(); Deallocate(memoryAllocator, (TextureImpl*)texture); @@ -97,12 +101,14 @@ OMM_API ommResult OMM_CALL ommCpuBake(ommBaker baker, const ommCpuBakeInputDesc* { if (baker == 0) return ommResult_INVALID_ARGUMENT; + + Cpu::BakerImpl* impl = GetBakerImpl(baker); + if (bakeInputDesc == 0) - return ommResult_INVALID_ARGUMENT; + return impl->GetLog().InvalidArg("input desc was not set"); if (GetBakerType(baker) != ommBakerType_CPU) - return ommResult_INVALID_ARGUMENT; + return impl->GetLog().InvalidArg("Baker was not created as the right type"); - Cpu::BakerImpl* impl = GetBakerImpl(baker); return (*impl).BakeOpacityMicromap(*bakeInputDesc, bakeResult); } @@ -135,11 +141,13 @@ OMM_API ommResult OMM_CALL ommGpuCreatePipeline(ommBaker baker, const ommGpuPipe { if (baker == 0) return ommResult_INVALID_ARGUMENT; + + Gpu::BakerImpl* bakePtr = GetBakerImpl(baker); + if (config == 0) - return ommResult_INVALID_ARGUMENT; + return bakePtr->GetLog().InvalidArg("[Invalid Arg] - pipeline config desc must be provided"); if (GetBakerType(baker) != ommBakerType_GPU) - return ommResult_INVALID_ARGUMENT; - Gpu::BakerImpl* bakePtr = GetBakerImpl(baker); + return bakePtr->GetLog().InvalidArg("[Invalid Arg] - invalid baker type"); return bakePtr->CreatePipeline(*config, outPipeline); } @@ -235,10 +243,10 @@ OMM_API ommResult OMM_CALL ommCreateBaker(const ommBakerCreationDesc* desc, ommB StdMemoryAllocatorInterface o = { - .Allocate = desc->memoryAllocatorInterface.Allocate, - .Reallocate = desc->memoryAllocatorInterface.Reallocate, - .Free = desc->memoryAllocatorInterface.Free, - .UserArg = desc->memoryAllocatorInterface.UserArg + .Allocate = desc->memoryAllocatorInterface.allocate, + .Reallocate = desc->memoryAllocatorInterface.reallocate, + .Free = desc->memoryAllocatorInterface.free, + .UserArg = desc->memoryAllocatorInterface.userArg }; CheckAndSetDefaultAllocator(o); diff --git a/omm-sdk/src/bake_cpu_impl.cpp b/omm-sdk/src/bake_cpu_impl.cpp index efcfcad..616a513 100644 --- a/omm-sdk/src/bake_cpu_impl.cpp +++ b/omm-sdk/src/bake_cpu_impl.cpp @@ -87,21 +87,25 @@ namespace Cpu BakerImpl::~BakerImpl() {} - ommResult BakerImpl::Create(const ommBakerCreationDesc& vmBakeCreationDesc) + ommResult BakerImpl::Create(const ommBakerCreationDesc& desc) { + m_log = Logger(desc.messageInterface); + return ommResult_SUCCESS; } ommResult BakerImpl::Validate(const ommCpuBakeInputDesc& desc) { if (desc.texture == 0) - return ommResult_INVALID_ARGUMENT; + { + return m_log.InvalidArg("[Invalid Argument] - ommCpuBakeInputDesc has no texture set"); + } return ommResult_SUCCESS; } ommResult BakerImpl::BakeOpacityMicromap(const ommCpuBakeInputDesc& bakeInputDesc, ommCpuBakeResult* outBakeommResult) { RETURN_STATUS_IF_FAILED(Validate(bakeInputDesc)); - BakeOutputImpl* implementation = Allocate(m_stdAllocator, m_stdAllocator); + BakeOutputImpl* implementation = Allocate(m_stdAllocator, m_stdAllocator, m_log); ommResult result = implementation->Bake(bakeInputDesc); if (result == ommResult_SUCCESS) @@ -114,8 +118,9 @@ namespace Cpu return result; } - BakeOutputImpl::BakeOutputImpl(const StdAllocator& stdAllocator) : + BakeOutputImpl::BakeOutputImpl(const StdAllocator& stdAllocator, const Logger& log) : m_stdAllocator(stdAllocator), + m_log(log), m_bakeInputDesc({}), m_bakeResult(stdAllocator), bakeDispatchTable(stdAllocator.GetInterface()) @@ -178,37 +183,45 @@ namespace Cpu { } - ommResult BakeOutputImpl::ValidateDesc(const ommCpuBakeInputDesc& desc) { + ommResult BakeOutputImpl::ValidateDesc(const ommCpuBakeInputDesc& desc) const { const Options options(desc.bakeFlags); if (desc.texture == 0) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Argument] - texture is not set"); if (desc.alphaMode == ommAlphaMode_MAX_NUM) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Argument] - alphaMode is not set"); if (desc.runtimeSamplerDesc.addressingMode == ommTextureAddressMode_MAX_NUM) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Argument] - runtimeSamplerDesc.addressingMode is not set"); if (desc.runtimeSamplerDesc.filter == ommTextureFilterMode_MAX_NUM) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Argument] - runtimeSamplerDesc.filter is not set"); if (desc.texCoordFormat == ommTexCoordFormat_MAX_NUM) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Argument] - texCoordFormat is not set"); if (desc.texCoords == nullptr) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Argument] - texCoords is not set"); if (desc.indexFormat == ommIndexFormat_MAX_NUM) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Argument] - indexFormat is not set"); if (desc.indexBuffer == nullptr) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Argument] - indexBuffer is not set"); if (desc.indexCount == 0) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Argument] - indexCount is not set"); if (desc.maxSubdivisionLevel > kMaxSubdivLevel) - return ommResult_INVALID_ARGUMENT; + { + static_assert(kMaxSubdivLevel == 12, ""); + if (desc.maxSubdivisionLevel > kMaxSubdivLevel) + return m_log.InvalidArgf("[Invalid Argument] - maxSubdivisionLevel (%d) is greater than maximum supported (%d)", desc.maxSubdivisionLevel, kMaxSubdivLevel); + } if ((options.enableNearDuplicateDetection || options.enableNearDuplicateDetectionBruteForce) && options.disableDuplicateDetection) - return ommResult_INVALID_ARGUMENT; + { + return m_log.InvalidArg("[Invalid Argument] - EnableNearDuplicateDetection or EnableNearDuplicateDetectionBruteForce is used together with DisableDuplicateDetection"); + } + if (options.enableWorkloadValidation && !m_log.HasLogger()) + return m_log.InvalidArg("[Invalid Argument] - EnableWorkloadValidation is set but not message callback was provided"); // this works more as documentation since it won't be logged if (TextureImpl* texture = ((TextureImpl*)desc.texture)) { if (texture->HasAlphaCutoff() && texture->GetAlphaCutoff() != desc.alphaCutoff) { - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArgf("[Invalid Argument] - Texture object alpha cutoff threshold (%.6f) is different from alpha cutoff threshold in bake input (%.6f)", texture->GetAlphaCutoff(), desc.alphaCutoff); } } @@ -471,7 +484,7 @@ namespace Cpu namespace impl { static ommResult SetupWorkItems( - StdAllocator& allocator, const ommCpuBakeInputDesc& desc, const Options& options, + StdAllocator& allocator, const Logger& log, const ommCpuBakeInputDesc& desc, const Options& options, vector& vmWorkItems) { const TextureImpl* texture = ((const TextureImpl*)desc.texture); @@ -523,8 +536,9 @@ namespace Cpu if ((it == triangleIDToWorkItem.end() || options.disableDuplicateDetection)) { if (kMaxSubdivLevel < subdivisionLevel) - return ommResult_INVALID_ARGUMENT; - + { + return log.InvalidArg("[Invalid Argument] - subdivisionLevel for primitive (i) is (d) which exceeds kMaxSubdivLevel(12)"); + } uint32_t workItemIdx = (uint32_t)vmWorkItems.size(); // Temporarily set the triangle->vm desc mapping like this. triangleIDToWorkItem.insert(std::make_pair(vmId, workItemIdx)); @@ -539,7 +553,7 @@ namespace Cpu } static ommResult ValidateWorkloadSize( - StdAllocator& allocator, const ommCpuBakeInputDesc& desc, const Options& options, vector& vmWorkItems) + StdAllocator& allocator, Logger log, const ommCpuBakeInputDesc& desc, const Options& options, vector& vmWorkItems) { // Check if the baking will complete in "finite" amount of time... if (!options.enableWorkloadValidation) @@ -563,17 +577,20 @@ namespace Cpu const uint64_t kMaxWorkloadSize = 1 << 27; // 128 * 1024x1024 texels. if (workloadSize > kMaxWorkloadSize) { - return ommResult_WORKLOAD_TOO_BIG; + const uint64_t num1Ktextures = workloadSize >> (20ull); // divide by 1024x1024 + + log.PerfWarnf("[Perf Warning] - The workload consists of %lld work items (number of texels to classify), which corresponds to roughly %lld 1024x1024 textures." + " This is unusually large and may result in long bake times.", workloadSize, num1Ktextures); } return ommResult_SUCCESS; } template - static ommResult ResampleCoarse(const ommCpuBakeInputDesc& desc, const Options& options, vector& vmWorkItems) + static ommResult ResampleCoarse(const ommCpuBakeInputDesc& desc, const Logger& log, const Options& options, vector& vmWorkItems) { if (options.enableAABBTesting && !options.disableLevelLineIntersection) - return ommResult_INVALID_ARGUMENT; + return log.InvalidArg("[Invalid Arg] - EnableAABBTesting can't be used without also setting DisableLevelLineIntersection"); const TextureImpl* texture = ((const TextureImpl*)desc.texture); @@ -665,10 +682,10 @@ namespace Cpu } template - static ommResult ResampleFine(const ommCpuBakeInputDesc& desc, const Options& options, vector& vmWorkItems) + static ommResult ResampleFine(const ommCpuBakeInputDesc& desc, const Logger& log, const Options& options, vector& vmWorkItems) { if (options.enableAABBTesting && !options.disableLevelLineIntersection) - return ommResult_INVALID_ARGUMENT; + return log.InvalidArg("[Invalid Arg] - EnableAABBTesting can't be used without also setting DisableLevelLineIntersection"); if (options.disableFineClassification) return ommResult_SUCCESS; @@ -1477,7 +1494,7 @@ namespace Cpu } // Compress to 16 bit indices if possible & allowed. - ommIndexFormat ommIndexFormat = ommIndexFormat_I32_UINT; + ommIndexFormat ommIndexFormat = ommIndexFormat_UINT_32; { const bool force32bit = ((int32_t)desc.bakeFlags & (int32_t)ommCpuBakeFlags_Force32BitIndices) == (int32_t)ommCpuBakeFlags_Force32BitIndices; const bool canCompressTo16Bit = triangleCount <= std::numeric_limits::max(); @@ -1491,7 +1508,7 @@ namespace Cpu ommIndexBuffer16[i] = idx16; } - ommIndexFormat = ommIndexFormat_I16_UINT; + ommIndexFormat = ommIndexFormat_UINT_16; } } @@ -1510,24 +1527,24 @@ namespace Cpu m_bakeInputDesc = desc; - auto impl__ResampleCoarse = [](const ommCpuBakeInputDesc& desc, const Options& options, vector& vmWorkItems) { - return impl::ResampleCoarse(desc, options, vmWorkItems); + auto impl__ResampleCoarse = [](const ommCpuBakeInputDesc& desc, const Logger& log, const Options& options, vector& vmWorkItems) { + return impl::ResampleCoarse(desc, log, options, vmWorkItems); }; - auto impl__ResampleFine = [](const ommCpuBakeInputDesc& desc, const Options& options, vector& vmWorkItems) { - return impl::ResampleFine(desc, options, vmWorkItems); + auto impl__ResampleFine = [](const ommCpuBakeInputDesc& desc, const Logger& log, const Options& options, vector& vmWorkItems) { + return impl::ResampleFine(desc, log, options, vmWorkItems); }; { vector vmWorkItems(m_stdAllocator.GetInterface()); - RETURN_STATUS_IF_FAILED(impl::SetupWorkItems(m_stdAllocator, desc, options, vmWorkItems)); + RETURN_STATUS_IF_FAILED(impl::SetupWorkItems(m_stdAllocator, m_log, desc, options, vmWorkItems)); - RETURN_STATUS_IF_FAILED(impl::ValidateWorkloadSize(m_stdAllocator, desc, options, vmWorkItems)); + RETURN_STATUS_IF_FAILED(impl::ValidateWorkloadSize(m_stdAllocator, m_log, desc, options, vmWorkItems)); - RETURN_STATUS_IF_FAILED(impl__ResampleCoarse(desc, options, vmWorkItems)); + RETURN_STATUS_IF_FAILED(impl__ResampleCoarse(desc, m_log, options, vmWorkItems)); - RETURN_STATUS_IF_FAILED(impl__ResampleFine(desc, options, vmWorkItems)); + RETURN_STATUS_IF_FAILED(impl__ResampleFine(desc, m_log, options, vmWorkItems)); RETURN_STATUS_IF_FAILED(impl::PromoteToSpecialIndices(desc, options, vmWorkItems)); diff --git a/omm-sdk/src/bake_cpu_impl.h b/omm-sdk/src/bake_cpu_impl.h index 34ed44b..c0ba527 100644 --- a/omm-sdk/src/bake_cpu_impl.h +++ b/omm-sdk/src/bake_cpu_impl.h @@ -14,6 +14,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "defines.h" #include "std_containers.h" #include "texture_impl.h" +#include "log.h" #include #include @@ -40,6 +41,9 @@ namespace Cpu inline StdAllocator& GetStdAllocator() { return m_stdAllocator; } + inline const Logger& GetLog() const + { return m_log; } + ommResult Create(const ommBakerCreationDesc& bakeCreationDesc); ommResult BakeOpacityMicromap(const ommCpuBakeInputDesc& bakeInputDesc, ommCpuBakeResult* bakeOutput); @@ -47,6 +51,7 @@ namespace Cpu ommResult Validate(const ommCpuBakeInputDesc& desc); private: StdAllocator m_stdAllocator; + Logger m_log; }; struct BakeResultImpl @@ -86,7 +91,7 @@ namespace Cpu class BakeOutputImpl { public: - BakeOutputImpl(const StdAllocator& stdAllocator); + BakeOutputImpl(const StdAllocator& stdAllocator, const Logger& log); ~BakeOutputImpl(); inline StdAllocator& GetStdAllocator() @@ -102,7 +107,7 @@ namespace Cpu inline ommResult GetBakeResultDesc(const ommCpuBakeResultDesc** desc) { if (desc == nullptr) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Arg] - No BakeResultDesc provided"); *desc = &m_bakeResult.bakeOutputDesc; return ommResult_SUCCESS; @@ -111,7 +116,7 @@ namespace Cpu ommResult Bake(const ommCpuBakeInputDesc& desc); private: - static ommResult ValidateDesc(const ommCpuBakeInputDesc& desc); + ommResult ValidateDesc(const ommCpuBakeInputDesc& desc) const; template ommResult BakeImpl(const ommCpuBakeInputDesc& desc); @@ -122,6 +127,7 @@ namespace Cpu ommResult InvokeDispatch(const ommCpuBakeInputDesc& desc); private: StdAllocator m_stdAllocator; + const Logger& m_log; ommCpuBakeInputDesc m_bakeInputDesc; BakeResultImpl m_bakeResult; }; diff --git a/omm-sdk/src/bake_gpu_impl.cpp b/omm-sdk/src/bake_gpu_impl.cpp index 672e57e..5538e47 100644 --- a/omm-sdk/src/bake_gpu_impl.cpp +++ b/omm-sdk/src/bake_gpu_impl.cpp @@ -257,19 +257,19 @@ ommResult PipelineImpl::Validate(const ommGpuDispatchConfigDesc& config) const const bool doBake = (((uint32_t)config.bakeFlags & (uint32_t)ommGpuBakeFlags_PerformBake) == (uint32_t)ommGpuBakeFlags_PerformBake); if (config.indexCount == 0) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Arg] - indexCount must be non-zero"); if (config.indexCount % 3 != 0) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Arg] - indexCount must be multiple of 3"); if (!computeOnly && config.maxSubdivisionLevel > MaxSubdivLevelGfx) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Arg] - maxSubdivisionLevel must be less than MaxSubdivLevelGfx(10) for non-compute only baking"); if (computeOnly && config.maxSubdivisionLevel > MaxSubdivLevelCS) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Arg] - maxSubdivisionLevel must be less than MaxSubdivLevelCS(12)"); if (config.enableSubdivisionLevelBuffer) - return ommResult_NOT_IMPLEMENTED; + return m_log.NotImplemented("[Invalid Arg] - enableSubdivisionLevelBuffer support is currently not implemented"); if (config.alphaTextureChannel > 3) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Arg] - alphaTextureChannel must be greater than 3"); if (!doBake && !doSetup) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Arg] - Either ommGpuBakeFlags_PerformBake or ommGpuBakeFlags_PerformSetup must be set"); return ommResult_SUCCESS; } @@ -303,9 +303,9 @@ ommResult PipelineImpl::Create(const ommGpuPipelineConfigDesc& config) m_pipelineBuilder.AddStaticSamplerDesc({ {ommSamplerDesc{ommTextureAddressMode_Clamp, ommTextureFilterMode_Nearest} , 6} }); m_pipelineBuilder.AddStaticSamplerDesc({ {ommSamplerDesc{ommTextureAddressMode_Border, ommTextureFilterMode_Nearest} , 7} }); - m_pipelines.clearBufferIdx = m_pipelineBuilder.AddComputePipeline( - ByteCodeFromName("clear_buffer.cs", clear_buffer_cs), - m_pipelines.clearBufferBindings.GetRanges(), m_pipelines.clearBufferBindings.GetNumRanges()); + m_pipelines.ommClearBufferIdx = m_pipelineBuilder.AddComputePipeline( + ByteCodeFromName("omm_clear_buffer.cs", omm_clear_buffer_cs), + m_pipelines.ommClearBufferBindings.GetRanges(), m_pipelines.ommClearBufferBindings.GetNumRanges()); m_pipelines.ommInitBuffersCsIdx = m_pipelineBuilder.AddComputePipeline( ByteCodeFromName("omm_init_buffers_cs.cs", omm_init_buffers_cs_cs), @@ -395,13 +395,13 @@ ommResult PipelineImpl::Create(const ommGpuPipelineConfigDesc& config) ByteCodeFromName("omm_index_write.cs", omm_index_write_cs), m_pipelines.ommIndexWriteBindings.GetRanges(), m_pipelines.ommIndexWriteBindings.GetNumRanges()); - m_pipelines.renderTargetClearDebugIdx = m_pipelineBuilder.AddGraphicsPipeline( + m_pipelines.ommRenderTargetClearDebugIdx = m_pipelineBuilder.AddGraphicsPipeline( ByteCodeFromName("omm_rasterize_debug.vs", omm_rasterize_debug_vs), PipelineBuilder::ByteCode(), - ByteCodeFromName("render_target_clear.ps", render_target_clear_ps), + ByteCodeFromName("omm_render_target_clear.ps", omm_render_target_clear_ps), false /*ConservativeRasterization*/, 1 /*NumRenderTargets*/, - m_pipelines.renderTargetClearDebugBindings.GetRanges(), m_pipelines.renderTargetClearDebugBindings.GetNumRanges()); + m_pipelines.ommRenderTargetClearDebugBindings.GetRanges(), m_pipelines.ommRenderTargetClearDebugBindings.GetNumRanges()); m_pipelines.ommRasterizeDebugIdx = m_pipelineBuilder.AddGraphicsPipeline( ByteCodeFromName("omm_rasterize_debug.vs", omm_rasterize_debug_vs), @@ -418,7 +418,7 @@ ommResult PipelineImpl::Create(const ommGpuPipelineConfigDesc& config) ommResult PipelineImpl::GetPipelineDesc(const ommGpuPipelineInfoDesc** outPipelineDesc) { if (outPipelineDesc == nullptr) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Arg] - PipelineDesc is null"); *outPipelineDesc = &m_pipelineBuilder._desc; return ommResult_SUCCESS; @@ -502,9 +502,8 @@ ommResult PipelineImpl::GetPreDispatchInfo(const ommGpuDispatchConfigDesc& confi } { - const uint32_t indirectDispatchEntrySize = m_config.renderAPI == ommGpuRenderAPI_DX12 ? 12 : 12; const uint32_t IEBakeCountCs = (config.maxSubdivisionLevel + 1); - const uint32_t IEBakeCountCsSize = IEBakeCountCs * indirectDispatchEntrySize; + const uint32_t IEBakeCountCsSize = IEBakeCountCs * kIndirectDispatchEntryStride; RETURN_STATUS_IF_FAILED(outInfo.indArgBuffer.Allocate(IEBakeCountCsSize, defaultAlignment, outInfo.IEBakeCsBuffer)); } } @@ -565,16 +564,14 @@ ommResult PipelineImpl::GetPreDispatchInfo(const ommGpuDispatchConfigDesc& confi } { - const uint32_t indirectDrawEntrySize = m_config.renderAPI == ommGpuRenderAPI_DX12 ? 20 : 20; const uint32_t indirectDrawCount = (config.maxSubdivisionLevel + 1) * outInfo.MaxBatchCount; - const uint32_t indirectDrawSize = indirectDrawEntrySize * indirectDrawCount; + const uint32_t indirectDrawSize = indirectDrawCount * kIndirectDispatchEntryStride; RETURN_STATUS_IF_FAILED(outInfo.indArgBuffer.Allocate(indirectDrawSize, defaultAlignment, outInfo.IEBakeBuffer)); } { - const uint32_t indirectDispatchEntrySize = m_config.renderAPI == ommGpuRenderAPI_DX12 ? 12 : 12; const uint32_t indirectPostCsCount = (config.maxSubdivisionLevel + 1) * outInfo.MaxBatchCount; - const uint32_t indirectPostCsSize = indirectPostCsCount * indirectDispatchEntrySize; + const uint32_t indirectPostCsSize = indirectPostCsCount * kIndirectDispatchEntryStride; RETURN_STATUS_IF_FAILED(outInfo.indArgBuffer.Allocate(indirectPostCsSize, defaultAlignment, outInfo.IECompressCsBuffer)); } } @@ -596,7 +593,7 @@ ommResult PipelineImpl::GetPreDispatchInfo(const ommGpuDispatchConfigDesc& confi ommResult PipelineImpl::GetPreDispatchInfo(const ommGpuDispatchConfigDesc& config, ommGpuPreDispatchInfo* outPreBuildInfo) const { if (!outPreBuildInfo) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Arg] - preBuildInfo is null"); const bool force32BitIndices = ((uint32_t)config.bakeFlags & (uint32_t)ommGpuBakeFlags_Force32BitIndices) == (uint32_t)ommGpuBakeFlags_Force32BitIndices; const bool doBake = (((uint32_t)config.bakeFlags & (uint32_t)ommGpuBakeFlags_PerformBake) == (uint32_t)ommGpuBakeFlags_PerformBake); @@ -607,11 +604,11 @@ ommResult PipelineImpl::GetPreDispatchInfo(const ommGpuDispatchConfigDesc& confi const size_t maxNumMicroTris = bird::GetNumMicroTriangles(config.maxSubdivisionLevel); const size_t bitsPerState = size_t(config.globalFormat); const size_t vmArraySizeInBits = size_t(primitiveCount) * std::max(maxNumMicroTris * bitsPerState, 32u); - ommIndexFormat outOmmIndexBufferFormat = primitiveCount < std::numeric_limits::max() - kNumSpecialIndices ? ommIndexFormat_I16_UINT : ommIndexFormat_I32_UINT; + ommIndexFormat outOmmIndexBufferFormat = primitiveCount < std::numeric_limits::max() - kNumSpecialIndices ? ommIndexFormat_UINT_16 : ommIndexFormat_UINT_32; if (force32BitIndices) - outOmmIndexBufferFormat = ommIndexFormat_I32_UINT; + outOmmIndexBufferFormat = ommIndexFormat_UINT_32; - const size_t indexBufferFormatSize = outOmmIndexBufferFormat == ommIndexFormat_I16_UINT ? 2 : 4; + const size_t indexBufferFormatSize = outOmmIndexBufferFormat == ommIndexFormat_UINT_16 ? 2 : 4; const size_t outMaxTheoreticalOmmArraySizeInBytes = math::Align(math::DivUp(vmArraySizeInBits, 8u), 4u); @@ -690,7 +687,7 @@ ommResult PipelineImpl::InitGlobalConstants(const ommGpuDispatchConfigDesc& conf const uint32_t primitiveCount = config.indexCount / 3; const uint32_t hashTableEntryCount = info.hashTableBuffer.GetSize() / kHashTableEntrySize; - const bool IsOmmIndexFormat16bit = preBuildInfo.outOmmIndexBufferFormat == ommIndexFormat_I16_UINT; + const bool IsOmmIndexFormat16bit = preBuildInfo.outOmmIndexBufferFormat == ommIndexFormat_UINT_16; const bool enableSpecialIndices = ((uint32_t)config.bakeFlags & (uint32_t)ommGpuBakeFlags_DisableSpecialIndices) != (uint32_t)ommGpuBakeFlags_DisableSpecialIndices; const bool enableTexCoordDeduplication = (((uint32_t)config.bakeFlags & (uint32_t)ommGpuBakeFlags_DisableTexCoordDeduplication) != (uint32_t)ommGpuBakeFlags_DisableTexCoordDeduplication); const bool computeOnly = (((uint32_t)config.bakeFlags & (uint32_t)ommGpuBakeFlags_ComputeOnly) == (uint32_t)ommGpuBakeFlags_ComputeOnly); @@ -716,6 +713,7 @@ ommResult PipelineImpl::InitGlobalConstants(const ommGpuDispatchConfigDesc& conf cbuffer.IsOmmIndexFormat16bit = IsOmmIndexFormat16bit; cbuffer.DoSetup = doSetup; cbuffer.EnablePostDispatchInfoStats = enablePostDispatchInfoStats && doBake; + cbuffer.IndirectDispatchEntryStride = kIndirectDispatchEntryStride; cbuffer.SamplerIndex = m_pipelineBuilder.GetStaticSamplerIndex(config.runtimeSamplerDesc); cbuffer.BakeResultBufferSize = info.bakeResultBuffer.GetSize(); cbuffer.ViewportSize = viewportSize; @@ -729,8 +727,9 @@ ommResult PipelineImpl::InitGlobalConstants(const ommGpuDispatchConfigDesc& conf cbuffer.TexSize = float2(config.alphaTextureWidth, config.alphaTextureHeight); static_assert(sizeof(float2) == sizeof(float) * 2); cbuffer.InvTexSize = 1.f / cbuffer.TexSize; + cbuffer.TexCoord1Format = (uint32_t)config.texCoordFormat; cbuffer.TexCoord1Offset = config.texCoordOffsetInBytes; - cbuffer.TexCoord1Stride = config.texCoordStrideInBytes; + cbuffer.TexCoord1Stride = config.texCoordStrideInBytes == 0 ? GetTexCoordFormatSize(config.texCoordFormat) : config.texCoordStrideInBytes; cbuffer.AlphaCutoff = config.alphaCutoff; cbuffer.AlphaTextureChannel = config.alphaTextureChannel; cbuffer.FilterType = (uint32_t)config.runtimeSamplerDesc.filter; @@ -769,7 +768,7 @@ ommResult PipelineImpl::InitGlobalConstants(const ommGpuDispatchConfigDesc& conf ommResult PipelineImpl::GetDispatchDesc(const ommGpuDispatchConfigDesc& config, const ommGpuDispatchChain** outDispatchDesc) { if (outDispatchDesc == nullptr) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Arg] - dispatchDesc is null"); RETURN_STATUS_IF_FAILED(Validate(config)); @@ -789,7 +788,7 @@ ommResult PipelineImpl::GetDispatchDesc(const ommGpuDispatchConfigDesc& config, const bool computeOnly = (((uint32_t)config.bakeFlags & (uint32_t)ommGpuBakeFlags_ComputeOnly) == (uint32_t)ommGpuBakeFlags_ComputeOnly); const bool doSetup = (((uint32_t)config.bakeFlags & (uint32_t)ommGpuBakeFlags_PerformSetup) == (uint32_t)ommGpuBakeFlags_PerformSetup); const bool doBake = (((uint32_t)config.bakeFlags & (uint32_t)ommGpuBakeFlags_PerformBake) == (uint32_t)ommGpuBakeFlags_PerformBake); - const bool IsOmmIndexFormat16bit = preBuildInfo.outOmmIndexBufferFormat == ommIndexFormat_I16_UINT; + const bool IsOmmIndexFormat16bit = preBuildInfo.outOmmIndexBufferFormat == ommIndexFormat_UINT_16; bool enableValidation = false; @@ -797,7 +796,7 @@ ommResult PipelineImpl::GetDispatchDesc(const ommGpuDispatchConfigDesc& config, auto ClearBuffer = [&](const char* name, const BufferResource* resource) { SCOPED_LABEL(name); - BEGIN_PASS(name, ommGpuDispatchType_Compute, m_pipelines.clearBufferBindings); + BEGIN_PASS(name, ommGpuDispatchType_Compute, m_pipelines.ommClearBufferBindings); p.UseGlobalCbuffer(); p.BindResource("u_targetBuffer", resource->type, resource->indexInPool); @@ -805,7 +804,7 @@ ommResult PipelineImpl::GetDispatchDesc(const ommGpuDispatchConfigDesc& config, OMM_ASSERT(byteSize % 4 == 0); const uint32_t numElements = resource->allocator.GetCurrentReservation() / 4; - CBufferWriter& lCb = p.AddComputeDispatch(m_pipelines.clearBufferIdx, math::DivUp(numElements, 128u), 1); + CBufferWriter& lCb = p.AddComputeDispatch(m_pipelines.ommClearBufferIdx, math::DivUp(numElements, 128u), 1); lCb.WriteDW(0 /*ClearValue*/); lCb.WriteDW(numElements /*NumElements*/); lCb.WriteDW(0 /*BufferOffset*/); @@ -817,7 +816,7 @@ ommResult PipelineImpl::GetDispatchDesc(const ommGpuDispatchConfigDesc& config, auto ClearResource = [&](const char* name, const ommGpuResourceType resourceType, uint32_t byteSize) { SCOPED_LABEL(name); - BEGIN_PASS(name, ommGpuDispatchType_Compute, m_pipelines.clearBufferBindings); + BEGIN_PASS(name, ommGpuDispatchType_Compute, m_pipelines.ommClearBufferBindings); p.UseGlobalCbuffer(); p.BindResource("u_targetBuffer", resourceType); @@ -827,7 +826,7 @@ ommResult PipelineImpl::GetDispatchDesc(const ommGpuDispatchConfigDesc& config, const uint32_t threadGroupCountX = math::DivUp(numElements, 128u); OMM_ASSERT(threadGroupCountX != 0); - CBufferWriter& lCb = p.AddComputeDispatch(m_pipelines.clearBufferIdx, threadGroupCountX, 1); + CBufferWriter& lCb = p.AddComputeDispatch(m_pipelines.ommClearBufferIdx, threadGroupCountX, 1); lCb.WriteDW(0 /*ClearValue*/); lCb.WriteDW(numElements /*NumElements*/); lCb.WriteDW(0 /*BufferOffset*/); @@ -860,7 +859,7 @@ ommResult PipelineImpl::GetDispatchDesc(const ommGpuDispatchConfigDesc& config, p.BindResource("u_ommDescArrayHistogramBuffer", ommGpuResourceType_OUT_OMM_DESC_ARRAY_HISTOGRAM); p.BindResource("u_ommIndexHistogramBuffer", ommGpuResourceType_OUT_OMM_INDEX_HISTOGRAM); p.AddComputeDispatch(m_pipelines.ommInitBuffersCsIdx, math::DivUp(config.maxSubdivisionLevel + 1, 128u), 1); - }); + }, enableValidation); } if (doSetup) @@ -889,7 +888,7 @@ ommResult PipelineImpl::GetDispatchDesc(const ommGpuDispatchConfigDesc& config, p.BindSubRange("RasterItemsBuffer", info.rasterItemsBuffer); p.AddComputeDispatch(m_pipelines.ommWorkSetupCsIdx, math::DivUp(primitiveCount, 128u), 1); - }); + }, enableValidation); } else { @@ -914,7 +913,7 @@ ommResult PipelineImpl::GetDispatchDesc(const ommGpuDispatchConfigDesc& config, p.BindSubRange("IEBakeCsBuffer", info.IEBakeCsBuffer); p.AddComputeDispatch(m_pipelines.ommWorkSetupBakeOnlyCsIdx, math::DivUp(primitiveCount, 128u), 1); - }); + }, enableValidation); } if (doSetup) @@ -933,7 +932,7 @@ ommResult PipelineImpl::GetDispatchDesc(const ommGpuDispatchConfigDesc& config, p.BindSubRange("OmmDescAllocatorCounterBuffer", info.ommDescAllocatorCounter); p.AddComputeDispatch(m_pipelines.ommPostBuildInfoBuffersIdx, 1, 1); - }); + }, enableValidation); } if (doBake) @@ -963,7 +962,7 @@ ommResult PipelineImpl::GetDispatchDesc(const ommGpuDispatchConfigDesc& config, return m_pipelines.ommRasterizeACsIdx; }; - CBufferWriter& lCb = p.AddComputeIndirect(GetPipelineIndex(config.alphaTextureChannel), info.IEBakeCsBuffer, 12 * subdivisionLevel); + CBufferWriter& lCb = p.AddComputeIndirect(GetPipelineIndex(config.alphaTextureChannel), info.IEBakeCsBuffer, kIndirectDispatchEntryStride * subdivisionLevel); lCb.WriteDW(subdivisionLevel /*levelIt*/); for (uint32_t i = 0; i < 7u; ++i) lCb.WriteDW(0u /*dummy*/); @@ -993,7 +992,7 @@ ommResult PipelineImpl::GetDispatchDesc(const ommGpuDispatchConfigDesc& config, p.BindResource("u_ommDescArrayHistogramBuffer", ommGpuResourceType_OUT_OMM_DESC_ARRAY_HISTOGRAM); p.BindResource("u_ommIndexHistogramBuffer", ommGpuResourceType_OUT_OMM_INDEX_HISTOGRAM); p.AddComputeDispatch(m_pipelines.ommInitBuffersGfxIdx, math::DivUp((config.maxSubdivisionLevel + 1) * info.MaxBatchCount, 128u), 1); - }); + }, enableValidation); } { @@ -1025,7 +1024,7 @@ ommResult PipelineImpl::GetDispatchDesc(const ommGpuDispatchConfigDesc& config, p.BindSubRange("IECompressCsBuffer", info.IECompressCsBuffer); p.AddComputeDispatch(m_pipelines.ommWorkSetupGfxIdx, math::DivUp(primitiveCount, 128u), 1); - }); + }, enableValidation); } else { @@ -1049,7 +1048,7 @@ ommResult PipelineImpl::GetDispatchDesc(const ommGpuDispatchConfigDesc& config, p.BindSubRange("IECompressCsBuffer", info.IECompressCsBuffer); p.AddComputeDispatch(m_pipelines.ommWorkSetupBakeOnlyGfxIdx, math::DivUp(primitiveCount, 128u), 1); - }); + }, enableValidation); } } @@ -1069,7 +1068,7 @@ ommResult PipelineImpl::GetDispatchDesc(const ommGpuDispatchConfigDesc& config, p.BindSubRange("OmmDescAllocatorCounterBuffer", info.ommDescAllocatorCounter); p.AddComputeDispatch(m_pipelines.ommPostBuildInfoBuffersIdx, 1, 1); - }); + }, enableValidation); } auto GetOmmRasterizeIdx = [&](uint alphaTextureChannel) { @@ -1134,7 +1133,7 @@ ommResult PipelineImpl::GetDispatchDesc(const ommGpuDispatchConfigDesc& config, 0, 0, cbuffer.ViewportSize.x, cbuffer.ViewportSize.y); - const uint32_t indirectDrawStrideInBytes = 20; // DX12 + const uint32_t indirectDrawStrideInBytes = kIndirectDispatchEntryStride; const uint32_t offset = levelIt * info.MaxBatchCount + batchIt; const uint32_t PrimitiveIdOffset = batchIt * maxItemsPerBatch; @@ -1162,7 +1161,7 @@ ommResult PipelineImpl::GetDispatchDesc(const ommGpuDispatchConfigDesc& config, } { SCOPED_LABEL("ClearRenderTarget"); - PushBakeRasterize("ClearRenderTarget", m_pipelines.renderTargetClearDebugIdx, m_pipelines.renderTargetClearDebugBindings); + PushBakeRasterize("ClearRenderTarget", m_pipelines.ommRenderTargetClearDebugIdx, m_pipelines.ommRenderTargetClearDebugBindings); } } @@ -1181,7 +1180,7 @@ ommResult PipelineImpl::GetDispatchDesc(const ommGpuDispatchConfigDesc& config, p.BindResource("u_vmArrayBuffer", ommGpuResourceType_OUT_OMM_ARRAY_DATA); - const uint32_t indirectDispatchStrideInBytes = 12; // DX12 + const uint32_t indirectDispatchStrideInBytes = kIndirectDispatchEntryStride; const uint32_t offset = levelIt * info.MaxBatchCount + batchIt; const uint32_t PrimitiveIdOffset = batchIt * maxItemsPerBatch; @@ -1192,7 +1191,7 @@ ommResult PipelineImpl::GetDispatchDesc(const ommGpuDispatchConfigDesc& config, lCb.WriteDW(PrimitiveIdOffset /*PrimitiveIdOffset*/); for (uint32_t i = 0; i < 5u; ++i) lCb.WriteDW(4u /*dummy*/); - }); + }, enableValidation); } } } @@ -1217,7 +1216,7 @@ ommResult PipelineImpl::GetDispatchDesc(const ommGpuDispatchConfigDesc& config, p.BindSubRange("SpecialIndicesStateBuffer", info.specialIndicesStateBuffer); p.AddComputeDispatch(m_pipelines.ommDescPatchIdx, math::DivUp(primitiveCount, 128u), 1); - }); + }, enableValidation); } { @@ -1237,7 +1236,7 @@ ommResult PipelineImpl::GetDispatchDesc(const ommGpuDispatchConfigDesc& config, lCb.WriteDW(threadCount /*threadCount*/); for (uint32_t i = 0; i < 7u; ++i) lCb.WriteDW(4u /*dummy*/); - }); + }, enableValidation); } m_passBuilder.Finalize(); @@ -1257,9 +1256,10 @@ ommResult PipelineImpl::ConfigurePipeline(const ommGpuPipelineConfigDesc& confi BakerImpl::~BakerImpl() {} -ommResult BakerImpl::Create(const ommBakerCreationDesc& vmBakeCreationDesc) +ommResult BakerImpl::Create(const ommBakerCreationDesc& desc) { - m_bakeCreationDesc = vmBakeCreationDesc; + m_bakeCreationDesc = desc; + m_log = Logger(desc.messageInterface); return ommResult_SUCCESS; } @@ -1268,7 +1268,7 @@ ommResult BakerImpl::CreatePipeline(const ommGpuPipelineConfigDesc& config, ommG RETURN_STATUS_IF_FAILED(PipelineImpl::Validate(config)); StdAllocator& memoryAllocator = GetStdAllocator(); - PipelineImpl* implementation = Allocate(memoryAllocator, memoryAllocator, m_bakeCreationDesc.enableValidation); + PipelineImpl* implementation = Allocate(memoryAllocator, memoryAllocator, GetLog()); RETURN_STATUS_IF_FAILED(implementation->Create(config)); *outPipeline = (ommGpuPipeline)implementation; return ommResult_SUCCESS; @@ -1277,7 +1277,8 @@ ommResult BakerImpl::CreatePipeline(const ommGpuPipelineConfigDesc& config, ommG ommResult BakerImpl::DestroyPipeline(ommGpuPipeline pipeline) { if (pipeline == 0) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Arg] - pipeline is null"); + PipelineImpl* impl = (PipelineImpl*)pipeline; StdAllocator& memoryAllocator = GetStdAllocator(); Deallocate(memoryAllocator, impl); diff --git a/omm-sdk/src/bake_gpu_impl.h b/omm-sdk/src/bake_gpu_impl.h index 64555bd..dcf82d6 100644 --- a/omm-sdk/src/bake_gpu_impl.h +++ b/omm-sdk/src/bake_gpu_impl.h @@ -14,6 +14,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "std_containers.h" #include "shader_bindings.h" #include "std_allocator.h" +#include "log.h" #include #include @@ -664,7 +665,7 @@ namespace Gpu } } - PassBuilder(const StdAllocator& stdAllocator, const PipelineBuilder& pipelines, StringCache& strings, bool enableValidation) + PassBuilder(const StdAllocator& stdAllocator, const PipelineBuilder& pipelines, StringCache& strings) : _stdAllocator(stdAllocator) , _dispatches(stdAllocator) , _resources(stdAllocator) @@ -672,7 +673,6 @@ namespace Gpu , _globalCbufferData(stdAllocator) , _pipelines(pipelines) , _strings(strings) - , _enableValidation(enableValidation) { } void SetGlobalCbuffer(const uint8_t* cbuffer, size_t size) @@ -681,8 +681,8 @@ namespace Gpu _globalCbufferData.insert(_globalCbufferData.end(), cbuffer, cbuffer + size); } - void PushPass(const char* pass, ommGpuDispatchType type, const ShaderBindings& binding, std::function fillConfigCb) { - PassConfig dt(_stdAllocator, type, binding, _enableValidation); + void PushPass(const char* pass, ommGpuDispatchType type, const ShaderBindings& binding, std::function fillConfigCb, bool enableValidation) { + PassConfig dt(_stdAllocator, type, binding, enableValidation); fillConfigCb(dt); // Copy to shared memory structs etc. FinalizePass(pass, dt); @@ -898,7 +898,6 @@ namespace Gpu vector _globalCbufferData; ommGpuDispatchChain _result; StringCache& _strings; - bool _enableValidation; }; struct OmmStaticBuffers @@ -910,14 +909,14 @@ namespace Gpu { // Internal public: - PipelineImpl(const StdAllocator& stdAllocator, bool enableValidation) + PipelineImpl(const StdAllocator& stdAllocator, const Logger& log) : m_stdAllocator(stdAllocator) + , m_log(log) , m_scratchBufferDescs(stdAllocator) , m_pipelineBuilder(stdAllocator) , m_strings(stdAllocator) - , m_passBuilder(stdAllocator, m_pipelineBuilder, m_strings, enableValidation) + , m_passBuilder(stdAllocator, m_pipelineBuilder, m_strings) , m_pipelines(stdAllocator) - , m_enableValidation(enableValidation) {} ~PipelineImpl(); @@ -937,22 +936,23 @@ namespace Gpu static constexpr uint32_t kHashTableEntrySize = sizeof(uint32_t) * 2; static constexpr int32_t kViewportScale = 5; // Increasing this to 6 fails... TODO: investigate why! + static constexpr int32_t kIndirectDispatchEntryStride = 64; // The stride of consecutive dispatch indirect buffer entries ommGpuPipelineConfigDesc m_config; StdAllocator m_stdAllocator; + const Logger& m_log; vector m_scratchBufferDescs; PipelineBuilder m_pipelineBuilder; StringCache m_strings; PassBuilder m_passBuilder; - bool m_enableValidation; struct Pipelines { - clear_buffer_cs_bindings clearBufferBindings; - uint32_t clearBufferIdx = -1; + omm_clear_buffer_cs_bindings ommClearBufferBindings; + uint32_t ommClearBufferIdx = -1; - render_target_clear_bindings renderTargetClearDebugBindings; - uint32_t renderTargetClearDebugIdx = -1; + omm_render_target_clear_bindings ommRenderTargetClearDebugBindings; + uint32_t ommRenderTargetClearDebugIdx = -1; omm_init_buffers_cs_cs_bindings ommInitBuffersCsBindings; uint32_t ommInitBuffersCsIdx = -1; @@ -1000,8 +1000,8 @@ namespace Gpu uint32_t ommRasterizeDebugIdx = -1; Pipelines(const StdAllocator& stdAllocator) - : clearBufferBindings(stdAllocator) - , renderTargetClearDebugBindings(stdAllocator) + : ommClearBufferBindings(stdAllocator) + , ommRenderTargetClearDebugBindings(stdAllocator) , ommInitBuffersCsBindings(stdAllocator) , ommInitBuffersGfxBindings(stdAllocator) , ommPostBuildInfoBindings(stdAllocator) @@ -1065,6 +1065,8 @@ namespace Gpu inline StdAllocator& GetStdAllocator() { return m_stdAllocator; } + inline const Logger& GetLog() const + { return m_log; } ommResult Create(const ommBakerCreationDesc& bakeCreationDesc); @@ -1073,6 +1075,7 @@ namespace Gpu private: StdAllocator m_stdAllocator; + Logger m_log; ommBakerCreationDesc m_bakeCreationDesc; }; } // namespace Gpu diff --git a/omm-sdk/src/log.h b/omm-sdk/src/log.h new file mode 100644 index 0000000..cc4df9a --- /dev/null +++ b/omm-sdk/src/log.h @@ -0,0 +1,106 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#pragma once + +#include "defines.h" +#include + +#include + +namespace omm +{ + class Logger + { + public: + + Logger() : m_log(ommMessageInterfaceDefault()) { } + + explicit Logger(ommMessageInterface log) :m_log(log) { } + + bool HasLogger() const + { + return m_log.messageCallback != nullptr; + } + + void Info(const char* msg) const + { + _Log(ommMessageSeverity_Info, msg); + } + + void PerfWarn(const char* msg) const + { + _Log(ommMessageSeverity_PerfWarning, msg); + } + + template + void PerfWarnf(const char* format, Args&&... args) const + { + _Logf(ommMessageSeverity_PerfWarning, format, std::forward(args)...); + } + + void Fatal(const char* msg) const + { + _Log(ommMessageSeverity_Fatal, msg); + } + + // Helper versions that return specific error codes + + [[nodiscard]] ommResult InvalidArg(const char* msg) const + { + _Log(ommMessageSeverity_Fatal, msg); + return ommResult_INVALID_ARGUMENT; + } + + template + [[nodiscard]] ommResult InvalidArgf(const char* format, Args&&... args) const + { + RETURN_STATUS_IF_FAILED(_Logf(ommMessageSeverity_Fatal, format, std::forward(args)...)); + return ommResult_INVALID_ARGUMENT; + } + + [[nodiscard]] ommResult NotImplemented(const char* msg) const + { + _Log(ommMessageSeverity_Fatal, msg); + return ommResult_NOT_IMPLEMENTED; + } + + private: + + void _Log(ommMessageSeverity severity, const char* msg) const + { + if (m_log.messageCallback) + { + (*m_log.messageCallback)(severity, msg, m_log.userArg); + } + } + + template + ommResult _Logf(ommMessageSeverity severity, const char* format, Args&&... args) const + { + if (m_log.messageCallback) + { + char buffer[N]; + int result = std::snprintf(buffer, sizeof(buffer), format, std::forward(args)...); + if (result < 0) { + return ommResult_FAILURE; // sprintf_s failed for some reason + } + + (*m_log.messageCallback)(severity, buffer, m_log.userArg); + } + return ommResult_SUCCESS; + } + + private: + ommMessageInterface m_log; + }; + + +} // namespace omm diff --git a/omm-sdk/src/shader_registry.h b/omm-sdk/src/shader_registry.h index 90555f5..8352136 100644 --- a/omm-sdk/src/shader_registry.h +++ b/omm-sdk/src/shader_registry.h @@ -11,8 +11,8 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. // SHADERS ================================================================================= #ifdef OMM_ENABLE_PRECOMPILED_SHADERS_DXIL - #include "clear_buffer.cs.dxil.h" - #include "render_target_clear.ps.dxil.h" + #include "omm_clear_buffer.cs.dxil.h" + #include "omm_render_target_clear.ps.dxil.h" #include "omm_init_buffers_cs.cs.dxil.h" #include "omm_init_buffers_gfx.cs.dxil.h" @@ -41,8 +41,8 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #endif #ifdef OMM_ENABLE_PRECOMPILED_SHADERS_SPIRV - #include "clear_buffer.cs.spirv.h" - #include "render_target_clear.ps.spirv.h" + #include "omm_clear_buffer.cs.spirv.h" + #include "omm_render_target_clear.ps.spirv.h" #include "omm_init_buffers_cs.cs.spirv.h" #include "omm_init_buffers_gfx.cs.spirv.h" @@ -82,8 +82,8 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. OMM_DECLARE_GLOBAL_CONSTANT_BUFFER // SHADER BINDINGS ========================================================================= -BEGIN_DECLARE_SHADER_BINDINGS(clear_buffer_cs_bindings) -#include "clear_buffer.cs.resources.hlsli" +BEGIN_DECLARE_SHADER_BINDINGS(omm_clear_buffer_cs_bindings) +#include "omm_clear_buffer.cs.resources.hlsli" #include "shader_bindings_expand.h" END_DECLARE_SHADER_BINDINGS /// ********************************************************************************** @@ -147,8 +147,8 @@ BEGIN_DECLARE_SHADER_BINDINGS(omm_index_write_cs_bindings) #include "shader_bindings_expand.h" END_DECLARE_SHADER_BINDINGS /// ********************************************************************************** -BEGIN_DECLARE_SHADER_BINDINGS(render_target_clear_bindings) -#include "render_target_clear.ps.resources.hlsli" +BEGIN_DECLARE_SHADER_BINDINGS(omm_render_target_clear_bindings) +#include "omm_render_target_clear.ps.resources.hlsli" #include "shader_bindings_expand.h" END_DECLARE_SHADER_BINDINGS /// ********************************************************************************** \ No newline at end of file diff --git a/omm-sdk/src/texture_impl.cpp b/omm-sdk/src/texture_impl.cpp index c21f80d..f1134ca 100644 --- a/omm-sdk/src/texture_impl.cpp +++ b/omm-sdk/src/texture_impl.cpp @@ -21,8 +21,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. namespace omm { - TextureImpl::TextureImpl(const StdAllocator& stdAllocator) : + TextureImpl::TextureImpl(const StdAllocator& stdAllocator, const Logger& log) : m_stdAllocator(stdAllocator), + m_log(log), m_mips(stdAllocator), m_textureFormat(ommCpuTextureFormat_MAX_NUM), m_tilingMode(TilingMode::MAX_NUM), @@ -37,24 +38,24 @@ namespace omm Deallocate(); } - ommResult TextureImpl::Validate(const ommCpuTextureDesc& desc) { + ommResult TextureImpl::Validate(const ommCpuTextureDesc& desc) const { if (desc.mipCount == 0) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Arg] - mipCount must be non-zero"); if (desc.format == ommCpuTextureFormat_MAX_NUM) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Arg] - format is not set"); for (uint32_t i = 0; i < desc.mipCount; ++i) { if (!desc.mips[i].textureData) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Arg] - mips.textureData is not set"); if (desc.mips[i].width == 0) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Arg] - mips.width must be non-zero"); if (desc.mips[i].height == 0) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Arg] - mips.height must be non-zero"); if (desc.mips[i].width > kMaxDim.x) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Arg] - mips.width must be less than kMaxDim.x (65536)"); if (desc.mips[i].height > kMaxDim.y) - return ommResult_INVALID_ARGUMENT; + return m_log.InvalidArg("[Invalid Arg] - mips.height must be less than kMaxDim.y (65536)"); } return ommResult_SUCCESS; @@ -107,7 +108,7 @@ namespace omm else { OMM_ASSERT(false); - return ommResult_INVALID_ARGUMENT; + return ommResult_FAILURE; } totalSize += sizePerPixel * m_mips[mipIt].numElements; @@ -177,7 +178,7 @@ namespace omm else { OMM_ASSERT(false); - return ommResult_INVALID_ARGUMENT; + return ommResult_FAILURE; } if (enableSAT) diff --git a/omm-sdk/src/texture_impl.h b/omm-sdk/src/texture_impl.h index 65963aa..e42a04b 100644 --- a/omm-sdk/src/texture_impl.h +++ b/omm-sdk/src/texture_impl.h @@ -13,6 +13,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "omm.h" #include "std_containers.h" +#include "log.h" #include #include @@ -30,7 +31,7 @@ namespace omm class TextureImpl { public: - TextureImpl(const StdAllocator& stdAllocator); + TextureImpl(const StdAllocator& stdAllocator, const Logger& log); ~TextureImpl(); ommResult Create(const ommCpuTextureDesc& desc); @@ -115,7 +116,7 @@ namespace omm } private: - static ommResult Validate(const ommCpuTextureDesc& desc); + ommResult Validate(const ommCpuTextureDesc& desc) const; void Deallocate(); template static uint64_t From2Dto1D(const int2& idx, const int2& size) { @@ -127,6 +128,7 @@ namespace omm static constexpr size_t kAlignment = 64; StdAllocator m_stdAllocator; + const Logger& m_log; struct Mips { @@ -144,7 +146,6 @@ namespace omm float m_alphaCutoff; uint8_t* m_data; uint8_t* m_dataSAT; - size_t m_dataSize; }; template diff --git a/omm-sdk/src/version.h b/omm-sdk/src/version.h index b35b732..5621e93 100644 --- a/omm-sdk/src/version.h +++ b/omm-sdk/src/version.h @@ -12,8 +12,8 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define STR(x) STR_HELPER(x) #define VERSION_MAJOR 1 -#define VERSION_MINOR 1 -#define VERSION_BUILD 1 +#define VERSION_MINOR 2 +#define VERSION_BUILD 0 #define VERSION_REVISION 0 #define VERSION_STRING STR(VERSION_MAJOR.VERSION_MINOR.VERSION_BUILD.VERSION_REVISION) diff --git a/shared/shared/parse.h b/shared/shared/parse.h index 42e7c23..a712722 100644 --- a/shared/shared/parse.h +++ b/shared/shared/parse.h @@ -18,8 +18,8 @@ namespace omm namespace parse { static int32_t GetOmmIndexForTriangleIndex(const ommCpuBakeResultDesc& resDesc, uint32_t i) { - OMM_ASSERT(resDesc.indexFormat == ommIndexFormat_I16_UINT || resDesc.indexFormat == ommIndexFormat_I32_UINT); - if (resDesc.indexFormat == ommIndexFormat_I16_UINT) + OMM_ASSERT(resDesc.indexFormat == ommIndexFormat_UINT_16 || resDesc.indexFormat == ommIndexFormat_UINT_32); + if (resDesc.indexFormat == ommIndexFormat_UINT_16) return reinterpret_cast(resDesc.indexBuffer)[i]; else return reinterpret_cast(resDesc.indexBuffer)[i]; diff --git a/shared/shared/triangle.h b/shared/shared/triangle.h index cd5a478..93a0e83 100644 --- a/shared/shared/triangle.h +++ b/shared/shared/triangle.h @@ -108,46 +108,19 @@ namespace omm return *(offset + component); } - template - inline float convertUvToFloat(const void* texCoords, uint32_t texCoordStrideInBytes, uint32_t index, uint32_t component); - - template<> // UV16_UNORM specialisation - inline float convertUvToFloat(const void* texCoords, uint32_t texCoordStrideInBytes, uint32_t index, uint32_t component) - { - return ((float)getUvComponantStorage(texCoords, texCoordStrideInBytes, index, component)) * (1.f / 65535.f); - } - - template<> // UV16_FLOAT specialisation - inline float convertUvToFloat(const void* texCoords, uint32_t texCoordStrideInBytes, uint32_t index, uint32_t component) - { - return float16ToFloat32(getUvComponantStorage(texCoords, texCoordStrideInBytes, index, component)); - } - - template<> // UV32_FLOAT specialisation - inline float convertUvToFloat(const void* texCoords, uint32_t texCoordStrideInBytes, uint32_t index, uint32_t component) - { - return getUvComponantStorage(texCoords, texCoordStrideInBytes, index, component); - } - static float2 FetchUV(const void* texCoords, uint32_t texCoordStrideInBytes, ommTexCoordFormat texCoordFormat, const uint32_t index) { const uint32_t* texCoords32 = (const uint32_t*)texCoords; switch (texCoordFormat) { case ommTexCoordFormat_UV16_UNORM: - return { - convertUvToFloat(texCoords, texCoordStrideInBytes, index, 0), - convertUvToFloat(texCoords, texCoordStrideInBytes, index, 1) - }; + return glm::unpackUnorm2x16(getUvComponantStorage(texCoords, texCoordStrideInBytes, index, 0)); case ommTexCoordFormat_UV16_FLOAT: - return { - convertUvToFloat(texCoords, texCoordStrideInBytes, index, 0), - convertUvToFloat(texCoords, texCoordStrideInBytes, index, 1) - }; + return glm::unpackHalf2x16(getUvComponantStorage(texCoords, texCoordStrideInBytes, index, 0)); case ommTexCoordFormat_UV32_FLOAT: return { - convertUvToFloat(texCoords, texCoordStrideInBytes, index, 0), - convertUvToFloat(texCoords, texCoordStrideInBytes, index, 1) + getUvComponantStorage(texCoords, texCoordStrideInBytes, index, 0), + getUvComponantStorage(texCoords, texCoordStrideInBytes, index, 1) }; default: return { 0,0 }; @@ -165,7 +138,7 @@ namespace omm static void GetUInt32Indices(ommIndexFormat indexFormat, const void* indices, size_t triIndexIndex, uint32_t outIndices[3]) { - if (indexFormat == ommIndexFormat_I16_UINT) + if (indexFormat == ommIndexFormat_UINT_16) { outIndices[0] = ((const uint16_t*)indices)[triIndexIndex + 0]; outIndices[1] = ((const uint16_t*)indices)[triIndexIndex + 1]; diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 2c66b59..9af1a3e 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -50,12 +50,4 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/gtest) set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) add_subdirectory("gtest") set_target_properties("gmock" "gmock_main" "gtest_main" "gtest" PROPERTIES FOLDER "${OMM_PROJECT_FOLDER}/Thirdparty") -endif() - -# gbenchmark -if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/gbenchmark) - set(BENCHMARK_ENABLE_INSTALL OFF) - set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE) - add_subdirectory("gbenchmark") - set_target_properties("benchmark" "benchmark_main" PROPERTIES FOLDER "${OMM_PROJECT_FOLDER}/Thirdparty") -endif() +endif() \ No newline at end of file diff --git a/thirdparty/ShaderMake b/thirdparty/ShaderMake index 3c6d07b..7565397 160000 --- a/thirdparty/ShaderMake +++ b/thirdparty/ShaderMake @@ -1 +1 @@ -Subproject commit 3c6d07b8ab852ab9f88d64dd764cb38f51fd5fae +Subproject commit 75653974a912605255b62fbe0324515246a62a57 diff --git a/thirdparty/stb b/thirdparty/stb index af1a5bc..013ac3b 160000 --- a/thirdparty/stb +++ b/thirdparty/stb @@ -1 +1 @@ -Subproject commit af1a5bc352164740c1cc1354942b1c6b72eacb8a +Subproject commit 013ac3beddff3dbffafd5177e7972067cd2b5083 diff --git a/thirdparty/xxHash b/thirdparty/xxHash index e31acd5..d5fe4f5 160000 --- a/thirdparty/xxHash +++ b/thirdparty/xxHash @@ -1 +1 @@ -Subproject commit e31acd5786bdfc7a7e1add726f532a368f18d018 +Subproject commit d5fe4f54c47bc8b8e76c6da9146c32d5c720cd79