Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Main minimal 1.2.0 #51

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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()
40 changes: 32 additions & 8 deletions integration/omm-sdk-nvrhi/omm-sdk-nvrhi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 --

/*
Expand Down Expand Up @@ -191,6 +213,7 @@ class GpuBakeNvrhiImpl
const std::vector<uint8_t>& ommIndexHistogramBuffer,
const void* indexBuffer,
const uint32_t indexCount,
nvrhi::Format ommTexCoordBufferFormat,
const void* texCoords,
const float* imageData,
const uint32_t width,
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1101,13 +1122,14 @@ void GpuBakeNvrhiImpl::DumpDebug(
const std::vector<uint8_t>& 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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1237,6 +1259,7 @@ void GpuBakeNvrhi::DumpDebug(
const std::vector<uint8_t>& ommIndexHistogramBuffer,
const void* indexBuffer,
const uint32_t indexCount,
nvrhi::Format ommTexCoordBufferFormat,
const void* texCoords,
const float* imageData,
const uint32_t width,
Expand All @@ -1255,6 +1278,7 @@ void GpuBakeNvrhi::DumpDebug(
ommIndexHistogramBuffer,
indexBuffer,
indexCount,
ommTexCoordBufferFormat,
texCoords,
imageData,
width,
Expand Down
2 changes: 2 additions & 0 deletions integration/omm-sdk-nvrhi/omm-sdk-nvrhi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -154,6 +155,7 @@ namespace omm
const std::vector<uint8_t>& ommIndexHistogramBuffer,
const void* indexBuffer,
const uint32_t indexCount,
nvrhi::Format ommTexCoordBufferFormat,
const void* texCoords,
const float* imageData,
const uint32_t width,
Expand Down
30 changes: 0 additions & 30 deletions omm-sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
Loading