Skip to content

Commit

Permalink
Changing application name to WebGPUTracer.
Browse files Browse the repository at this point in the history
  • Loading branch information
kugimasa committed Aug 26, 2023
1 parent 5c0995b commit 04401f2
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 33 deletions.
24 changes: 12 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.22)
project(
Portracer
WebGPUTracer
VERSION 0.1.0
LANGUAGES CXX C
)
Expand All @@ -13,7 +13,7 @@ add_subdirectory(glfw)
add_subdirectory(glfw3webgpu)
add_subdirectory(webgpu)

add_executable(Portracer
add_executable(WebGPUTracer
src/main.cpp
src/camera.cpp
src/render.cpp
Expand All @@ -30,40 +30,40 @@ include_directories("external/stb")
include_directories("external/tinyobjloader")

# Output directory
target_compile_definitions(Portracer PRIVATE
target_compile_definitions(WebGPUTracer PRIVATE
OUTPUT_DIR="${CMAKE_BINARY_DIR}/output"
)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/output)

if (DEV_MODE)
target_compile_definitions(Portracer PRIVATE
target_compile_definitions(WebGPUTracer PRIVATE
RESOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/resources"
)
else ()
file(COPY resources DESTINATION ${CMAKE_BINARY_DIR})
target_compile_definitions(Portracer PRIVATE
target_compile_definitions(WebGPUTracer PRIVATE
RESOURCE_DIR="./resources"
)
endif ()

target_link_libraries(Portracer PRIVATE glfw webgpu glfw3webgpu)
target_link_libraries(WebGPUTracer PRIVATE glfw webgpu glfw3webgpu)

set_target_properties(Portracer PROPERTIES
set_target_properties(WebGPUTracer PROPERTIES
CXX_STANDARD 17
)
# Warning Settings
if (MSVC)
set_target_properties(Portracer PROPERTIES VS_DEBUGGER_ENVIRONMENT "DAWN_DEBUG_BREAK_ON_ERROR=1")
target_compile_options(Portracer PRIVATE /W4)
set_target_properties(WebGPUTracer PROPERTIES VS_DEBUGGER_ENVIRONMENT "DAWN_DEBUG_BREAK_ON_ERROR=1")
target_compile_options(WebGPUTracer PRIVATE /W4)
else ()
target_compile_options(Portracer PRIVATE -Wall -Wextra -pedantic)
target_compile_options(WebGPUTracer PRIVATE -Wall -Wextra -pedantic)
endif ()

if(XCODE)
set_target_properties(Portracer PROPERTIES
set_target_properties(WebGPUTracer PROPERTIES
XCODE_GENERATE_SCHEME ON
XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE "Metal")
endif()

# This might be unnecessary
target_copy_webgpu_binaries(Portracer)
target_copy_webgpu_binaries(WebGPUTracer)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Portracer (_)=---=(_)
# WebGPUTracer (_)=---=(_)

[![Windows Build wgpu-native](https://github.com/kugimasa/Portracer/actions/workflows/windows_build_wgpu.yml/badge.svg)](https://github.com/kugimasa/Portracer/actions/workflows/windows_build_wgpu.yml) [![Windows Build Dawn](https://github.com/kugimasa/Portracer/actions/workflows/windows_build_dawn.yml/badge.svg)](https://github.com/kugimasa/Portracer/actions/workflows/windows_build_dawn.yml)
[![Windows Build wgpu-native](https://github.com/kugimasa/WebGPUTracer/actions/workflows/windows_build_wgpu.yml/badge.svg)](https://github.com/kugimasa/WebGPUTracer/actions/workflows/windows_build_wgpu.yml) [![Windows Build Dawn](https://github.com/kugimasa/WebGPUTracer/actions/workflows/windows_build_dawn.yml/badge.svg)](https://github.com/kugimasa/WebGPUTracer/actions/workflows/windows_build_dawn.yml)

A WebGPU ray tracer for Ray Tracing Camp 9 (2023)

Expand Down
19 changes: 12 additions & 7 deletions src/include/utils/print_util.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
#pragma once

#include <iostream>
#include <string>

enum class PrintInfoType {
WebGPU,
GLFW,
Portracer,
WebGPU,
GLFW,
WebGPUTracer,
};

std::string inline GetInfoTypeStr(PrintInfoType info_type) {
switch (info_type) {
case PrintInfoType::WebGPU:return "WebGPU";
case PrintInfoType::GLFW:return "GLFW";
case PrintInfoType::Portracer:return "Portracer";
default:return "";
case PrintInfoType::WebGPU:
return "WebGPU";
case PrintInfoType::GLFW:
return "GLFW";
case PrintInfoType::WebGPUTracer:
return "WebGPUTracer";
default:
return "";
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/include/utils/wgpu_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void inline OnQueueWorkDone(QueueWorkDoneStatus status) {
ShaderModule inline LoadShaderModule(const fs::path &path, Device device) {
std::ifstream file(path);
if (!file.is_open()) {
Error(PrintInfoType::Portracer, "Could not load shader from path: ", path);
Error(PrintInfoType::WebGPUTracer, "Could not load shader from path: ", path);
return nullptr;
}
file.seekg(0, std::ios::end);
Expand Down
8 changes: 4 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "renderer.h"

int main(int argc, char *argv[]) {
Print(PrintInfoType::Portracer, "Starting Portracer (_)=---=(_)");
Print(PrintInfoType::WebGPUTracer, "Starting WebGPUTracer (_)=---=(_)");
Renderer renderer;
bool hasWindow = false;
renderer.OnInit(hasWindow);
Expand All @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) {
uint32_t start_frame = 1;
uint32_t end_frame = 600;
// コマンドライン入力形式
// ./Portracer.exe --frame [start] [end]
// ./WebGPUTracer.exe --frame [start] [end]
if (argc == 4) {
if (strcmp(argv[1], "--frame") == 0) {
start_frame = (uint32_t) atoi(argv[2]);
Expand All @@ -26,11 +26,11 @@ int main(int argc, char *argv[]) {

// ComputePipeline
if (!renderer.OnCompute(start_frame, end_frame)) {
Error(PrintInfoType::Portracer, "(_)=--.. Something went wrong");
Error(PrintInfoType::WebGPUTracer, "(_)=--.. Something went wrong");
return 1;
}

renderer.OnFinish();
Print(PrintInfoType::Portracer, "(_)=---=(_) Portracer Finished");
Print(PrintInfoType::WebGPUTracer, "(_)=---=(_) WebGPUTracer Finished");
return 0;
}
10 changes: 5 additions & 5 deletions src/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bool Renderer::OnInit(bool hasWindow) {
/// Create Window
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
window_ = glfwCreateWindow(WIDTH, HEIGHT, "Portracer (_)=---=(_)", NULL, NULL);
window_ = glfwCreateWindow(WIDTH, HEIGHT, "WebGPUTracer (_)=---=(_)", NULL, NULL);
}

buffer_size_ = 64 * sizeof(float); // seed
Expand Down Expand Up @@ -95,7 +95,7 @@ bool Renderer::InitDevice() {
requiredLimits.limits.minUniformBufferOffsetAlignment = supported_limits.limits.minUniformBufferOffsetAlignment;
// Minimal descriptor setting
DeviceDescriptor device_desc = {};
device_desc.label = "Portracer Device";
device_desc.label = "WebGPUTracer Device";
device_desc.requiredFeaturesCount = 0;
device_desc.requiredLimits = &requiredLimits;
device_desc.defaultQueue.label = "Default Queue";
Expand Down Expand Up @@ -343,7 +343,7 @@ void Renderer::InitBindGroup() {

/// \brief Compute pass
bool Renderer::OnCompute(uint32_t start_frame, uint32_t end_frame) {
Print(PrintInfoType::Portracer, "Running compute pass ...");
Print(PrintInfoType::WebGPUTracer, "Running compute pass ...");
auto success = false;
// chrono変数
std::chrono::system_clock::time_point start, end;
Expand All @@ -359,7 +359,7 @@ bool Renderer::OnCompute(uint32_t start_frame, uint32_t end_frame) {
double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
std::ostringstream sout;
sout << elapsed * 0.001 << "(sec)s";
Print(PrintInfoType::Portracer, "Finished: ", sout.str());
Print(PrintInfoType::WebGPUTracer, "Finished: ", sout.str());
return success;
}

Expand Down Expand Up @@ -419,7 +419,7 @@ bool Renderer::OnRender(uint32_t frame) {
sout << std::setw(3) << std::setfill('0') << frame;
std::string output_file = OUTPUT_DIR "/" + sout.str() + ".png";
if (!saveTexture(output_file.c_str(), device_, texture_, 0 /* output MIP level */)) {
Error(PrintInfoType::Portracer, "Image output failed.");
Error(PrintInfoType::WebGPUTracer, "Image output failed.");
return false;
}
// Clean up
Expand Down
4 changes: 2 additions & 2 deletions src/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ void Scene::LoadVertices(const char *file_path, std::vector<Vertex> &vertices) {
reader_config.mtl_search_path = "./assets/obj/";
if (!reader.ParseFromFile(file_path, reader_config)) {
if (!reader.Error().empty()) {
Error(PrintInfoType::Portracer, "TinyObjReader: ", reader.Error());
Error(PrintInfoType::WebGPUTracer, "TinyObjReader: ", reader.Error());
}
exit(1);
}

if (!reader.Warning().empty()) {
Print(PrintInfoType::Portracer, "TinyObjReader: ", reader.Warning());
Print(PrintInfoType::WebGPUTracer, "TinyObjReader: ", reader.Warning());
}
tinyobj::attrib_t attrib = reader.GetAttrib();
std::vector<tinyobj::shape_t> shapes = reader.GetShapes();
Expand Down

0 comments on commit 04401f2

Please sign in to comment.