Skip to content

Commit 2727054

Browse files
committed
add d3d12
1 parent 2d4f5d2 commit 2727054

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

CMakeLists.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,9 @@ function(add_shader FILE)
6262
add_custom_target(${NAME} DEPENDS ${BINARY})
6363
add_dependencies(rtiow ${NAME})
6464
endfunction()
65-
if(WIN32)
66-
package(${DXIL})
67-
elseif(APPLE)
68-
package(${MSL})
69-
else()
70-
package(${SPV})
71-
endif()
65+
package(${DXIL})
7266
package(${JSON})
67+
package(${MSL})
68+
package(${SPV})
7369
endfunction()
7470
add_shader(shader.comp random.hlsl config.h)

config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#define UP float3(0.0f, 1.0f, 0.0f)
1515
#define FOCUS 10.0f
1616
#define OOF 0.6f
17-
#define IMAGE "image.bmp"
17+
#define IMAGE "image.png"
1818
#define SKY float3(0.5f, 0.7f, 1.0f)
1919
#define HORIZON float3(1.0f, 1.0f, 1.0f)
2020
#define LAMBERTIAN 0

main.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,13 @@ static SDL_GPUBuffer* create_spheres(SDL_GPUDevice* device, uint32_t* size)
162162

163163
int main(int argc, char** argv)
164164
{
165-
SDL_SetLogPriorities(SDL_LOG_PRIORITY_TRACE);
165+
#ifndef NDEBUG
166+
bool debug = true;
167+
#else
168+
bool debug = false;
169+
#endif
170+
SDL_SetAppMetadata("RTIOW", NULL, NULL);
171+
SDL_SetLogPriorities(SDL_LOG_PRIORITY_VERBOSE);
166172
if (!SDL_Init(SDL_INIT_VIDEO))
167173
{
168174
SDL_Log("Failed to initialize SDL: %s", SDL_GetError());
@@ -174,13 +180,7 @@ int main(int argc, char** argv)
174180
SDL_Log("Failed to create window: %s", SDL_GetError());
175181
return EXIT_FAILURE;
176182
}
177-
#if SDL_PLATFORM_WIN32
178-
SDL_GPUDevice* device = SDL_CreateGPUDevice(SDL_GPU_SHADERFORMAT_DXIL, true, NULL);
179-
#elif SDL_PLATFORM_LINUX
180-
SDL_GPUDevice* device = SDL_CreateGPUDevice(SDL_GPU_SHADERFORMAT_SPIRV, true, NULL);
181-
#elif SDL_PLATFORM_APPLE
182-
SDL_GPUDevice* device = SDL_CreateGPUDevice(SDL_GPU_SHADERFORMAT_MSL, true, NULL);
183-
#endif
183+
SDL_GPUDevice* device = SDL_CreateGPUDevice(SDL_GPU_SHADERFORMAT_DXIL | SDL_GPU_SHADERFORMAT_SPIRV | SDL_GPU_SHADERFORMAT_MSL, debug, NULL);
184184
if (!device)
185185
{
186186
SDL_Log("Failed to create device: %s", SDL_GetError());
@@ -191,7 +191,7 @@ int main(int argc, char** argv)
191191
SDL_Log("Failed to create swapchain: %s", SDL_GetError());
192192
return EXIT_FAILURE;
193193
}
194-
SDL_SetWindowAlwaysOnTop(window, true);
194+
SDL_RaiseWindow(window);
195195
SDL_GPUComputePipeline* pipeline = load_compute_pipeline(device, "shader.comp");
196196
if (!pipeline)
197197
{
@@ -237,7 +237,7 @@ int main(int argc, char** argv)
237237
{
238238
char title[128] = {0};
239239
int samples = batch * SAMPLES / BATCHES;
240-
snprintf(title, sizeof(title), "%d/%d samples", samples, SAMPLES);
240+
snprintf(title, sizeof(title), "%s: %d/%d samples", SDL_GetGPUDeviceDriver(device), samples, SAMPLES);
241241
SDL_SetWindowTitle(window, title);
242242
SDL_Event event;
243243
while (SDL_PollEvent(&event))

0 commit comments

Comments
 (0)