Skip to content

Commit 55adab9

Browse files
committed
[ORO] small fix for Windows.
1 parent 0f89a0c commit 55adab9

4 files changed

Lines changed: 52 additions & 21 deletions

File tree

.clangd

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
CompileFlags:
2+
# Strip flags that premake emits for the Unix clang toolset but are invalid
3+
# in the bundled clang++ driver on Windows MSVC target:
4+
# -fPIC → "unsupported option for target x86_64-pc-windows-msvc"
5+
# /wd<id> → in clang++ driver, leading-slash args are parsed as paths
6+
# ("no such file or directory: /wd4244"); these are MSVC-only
7+
Remove:
8+
- -fPIC
9+
- /wd*
10+
# premake's compile_commands exporter ignores `externalincludedirs`, so the
11+
# UnitTest project's gtest path never appears in compile_commands.json.
12+
# Adding it globally is harmless: clangd ignores -I paths that don't resolve.
13+
# -Wno-unused-command-line-argument: quiet noise from the JSON's leftover
14+
# `-c` / `-o foo.o` that clangd doesn't actually emit object files for.
15+
# -Wno-deprecated: silence the "treating 'c-header' input as 'c++-header'"
16+
# warning that clang++ emits for every .h opened (we want .h as C++).
17+
Add:
18+
- -isystemUnitTest/contrib/gtest-1.6.0
19+
- -Wno-unused-command-line-argument
20+
- -Wno-deprecated
21+
22+
# Fallback for headers without an entry in compile_commands.json (e.g.
23+
# Test/Common.h — Test/premake5.lua only globs *.cpp, not *.h). clangd
24+
# normally guesses from a sibling .cpp; force C++20 + workspace -I when
25+
# that heuristic fails.
26+
---
27+
If:
28+
PathMatch: .*\.h$
29+
CompileFlags:
30+
Add:
31+
- -xc++-header
32+
- -std=c++20
33+
- -I.

Test/SimpleD3D12/simpleD3D12.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void RunSineWaveKernel1(oroDevice gOroDevice, size_t mesh_width, size_t mesh_hei
6666
return;
6767
}
6868
dim3 block = { 16, 16, 1 };
69-
dim3 grid = { mesh_width / 16, mesh_height / 16, 1 };
69+
dim3 grid = { (int)( mesh_width / 16 ), (int)( mesh_height / 16 ), 1 };
7070
Vertex* vertices = (Vertex*)oroDevVertptr;
7171
void* args[] = { &vertices, &mesh_width, &mesh_height, &AnimTime };
7272

@@ -396,10 +396,12 @@ void DX12OroInterop::LoadAssets() {
396396
vertBufHeight = m_height / 2;
397397
const UINT vertexBufferSize = sizeof(Vertex) * vertBufWidth * vertBufHeight;
398398

399+
auto heapProps = CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT);
400+
auto bufferDesc = CD3DX12_RESOURCE_DESC::Buffer(vertexBufferSize);
399401
ThrowIfFailed(m_device->CreateCommittedResource(
400-
&CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT),
402+
&heapProps,
401403
D3D12_HEAP_FLAG_SHARED,
402-
&CD3DX12_RESOURCE_DESC::Buffer(vertexBufferSize),
404+
&bufferDesc,
403405
D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER, nullptr,
404406
IID_PPV_ARGS(&m_vertexBuffer)));
405407

@@ -416,8 +418,9 @@ void DX12OroInterop::LoadAssets() {
416418
&sharedHandle));
417419

418420
D3D12_RESOURCE_ALLOCATION_INFO d3d12ResourceAllocationInfo;
421+
auto allocInfoDesc = CD3DX12_RESOURCE_DESC::Buffer(vertexBufferSize);
419422
d3d12ResourceAllocationInfo = m_device->GetResourceAllocationInfo(
420-
m_nodeMask, 1, &CD3DX12_RESOURCE_DESC::Buffer(vertexBufferSize));
423+
m_nodeMask, 1, &allocInfoDesc);
421424
size_t actualSize = d3d12ResourceAllocationInfo.SizeInBytes;
422425
size_t alignment = d3d12ResourceAllocationInfo.Alignment;
423426

@@ -536,10 +539,10 @@ void DX12OroInterop::PopulateCommandList() {
536539
m_commandList->RSSetScissorRects(1, &m_scissorRect);
537540

538541
// Indicate that the back buffer will be used as a render target.
539-
m_commandList->ResourceBarrier(
540-
1, &CD3DX12_RESOURCE_BARRIER::Transition(
541-
m_renderTargets[m_frameIndex].Get(), D3D12_RESOURCE_STATE_PRESENT,
542-
D3D12_RESOURCE_STATE_RENDER_TARGET));
542+
auto barrierToRT = CD3DX12_RESOURCE_BARRIER::Transition(
543+
m_renderTargets[m_frameIndex].Get(), D3D12_RESOURCE_STATE_PRESENT,
544+
D3D12_RESOURCE_STATE_RENDER_TARGET);
545+
m_commandList->ResourceBarrier(1, &barrierToRT);
543546

544547
CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle(
545548
m_rtvHeap->GetCPUDescriptorHandleForHeapStart(), m_frameIndex,
@@ -554,10 +557,10 @@ void DX12OroInterop::PopulateCommandList() {
554557
m_commandList->DrawInstanced(vertBufHeight * vertBufWidth, 1, 0, 0);
555558

556559
// Indicate that the back buffer will now be used to present.
557-
m_commandList->ResourceBarrier(
558-
1, &CD3DX12_RESOURCE_BARRIER::Transition(
559-
m_renderTargets[m_frameIndex].Get(),
560-
D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT));
560+
auto barrierToPresent = CD3DX12_RESOURCE_BARRIER::Transition(
561+
m_renderTargets[m_frameIndex].Get(),
562+
D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT);
563+
m_commandList->ResourceBarrier(1, &barrierToPresent);
561564

562565
ThrowIfFailed(m_commandList->Close());
563566
}

UnitTest/main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020
// THE SOFTWARE.
2121
//
2222

23-
2423
#include "common.h"
2524

26-
int main( int argc, char* argv[] )
25+
int main( int argc, char* argv[] )
2726
{
2827
::testing::InitGoogleTest( &argc, argv );
2928
int retCode = RUN_ALL_TESTS();

premake5.lua

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,8 @@ workspace "YamatanoOrochi"
108108
filter {}
109109

110110
if _OPTIONS["clang"] then
111-
if os.istarget("windows") then
112-
toolset "clangcl"
113-
linker "LLD"
114-
else
115-
toolset "clang"
116-
linker "LLD"
117-
end
111+
toolset "clang"
112+
linker "LLD"
118113
end
119114

120115
-- Platform-specific settings
@@ -150,6 +145,7 @@ workspace "YamatanoOrochi"
150145
targetsuffix "64"
151146
defines { "NDEBUG", "BUILD_CONFIG=\"RelWithDebInfo\"" }
152147
symbols "On"
148+
editandcontinue "Off"
153149
optimize "Debug"
154150
linktimeoptimization "Fast"
155151
runtime "Release"

0 commit comments

Comments
 (0)