Skip to content

Commit 078b50d

Browse files
Fixed NO_GLSLANG Android build configuration. Added CI build configs for NO_GLSLANG and NO_HLSL
1 parent 118065e commit 078b50d

File tree

10 files changed

+231
-78
lines changed

10 files changed

+231
-78
lines changed

.github/workflows/linux.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,76 @@ jobs:
118118
!${{runner.workspace}}/build/install/**/*.a
119119
retention-days: 90
120120

121+
122+
build-clang-10-no-glslang:
123+
strategy:
124+
matrix:
125+
config: [Debug]
126+
127+
runs-on: ubuntu-latest
128+
name: Linux x64, Clang 10 NO_GLSLANG, ${{ matrix.config }}
129+
130+
steps:
131+
- name: Clone repository
132+
uses: actions/checkout@v2
133+
with:
134+
submodules: recursive
135+
136+
- name: Configure dependencies
137+
if: success()
138+
run: |
139+
sudo apt-get install build-essential libx11-dev libgl1-mesa-dev
140+
141+
- name: Configure CMake
142+
if: success()
143+
env:
144+
CC: clang-10
145+
CXX: clang++-10
146+
shell: bash
147+
run: |
148+
cd $GITHUB_WORKSPACE/BuildTools/Scripts/github_actions
149+
chmod +x configure_cmake.sh
150+
./configure_cmake.sh "linux" "${{runner.workspace}}" ${{ matrix.config }} "-DDILIGENT_NO_OPENGL=ON -DDILIGENT_NO_GLSLANG=ON"
151+
152+
- name: Build
153+
if: success()
154+
working-directory: ${{runner.workspace}}/build
155+
shell: bash
156+
run: cmake --build . --config ${{ matrix.config }} --target install -j2
157+
158+
159+
build-clang-10-no-glslang-no-hlsl:
160+
strategy:
161+
matrix:
162+
config: [Release]
163+
164+
runs-on: ubuntu-latest
165+
name: Linux x64, Clang 10 NO_GLSLANG NO_HLSL, ${{ matrix.config }}
166+
167+
steps:
168+
- name: Clone repository
169+
uses: actions/checkout@v2
170+
with:
171+
submodules: recursive
172+
173+
- name: Configure dependencies
174+
if: success()
175+
run: |
176+
sudo apt-get install build-essential libx11-dev libgl1-mesa-dev
177+
178+
- name: Configure CMake
179+
if: success()
180+
env:
181+
CC: clang-10
182+
CXX: clang++-10
183+
shell: bash
184+
run: |
185+
cd $GITHUB_WORKSPACE/BuildTools/Scripts/github_actions
186+
chmod +x configure_cmake.sh
187+
./configure_cmake.sh "linux" "${{runner.workspace}}" ${{ matrix.config }} "-DDILIGENT_NO_GLSLANG=ON -DDILIGENT_NO_HLSL=ON"
188+
189+
- name: Build
190+
if: success()
191+
working-directory: ${{runner.workspace}}/build
192+
shell: bash
193+
run: cmake --build . --config ${{ matrix.config }} --target install -j2

BuildTools/Scripts/github_actions/configure_cmake.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ if [ "$1" = "ios" ]; then
3232
fi
3333

3434
if [ "$1" = "linux" ]; then
35-
cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$3 -DDILIGENT_BUILD_TESTS=ON -DDILIGENT_NO_FORMAT_VALIDATION=ON -DCMAKE_INSTALL_PREFIX=install ..
35+
cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$3 -DDILIGENT_BUILD_TESTS=ON -DDILIGENT_NO_FORMAT_VALIDATION=ON $4 -DCMAKE_INSTALL_PREFIX=install ..
3636
fi

Graphics/GraphicsEngineVulkan/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ set(PRIVATE_DEPENDENCIES
194194
)
195195

196196
if (${DILIGENT_NO_HLSL})
197-
message("HLSL support is disabled. Vulkan backend may not be able to consume SPIRV bytecode generated from HLSL.")
197+
message("HLSL support is disabled. Vulkan backend will not be able to consume SPIRV bytecode generated from HLSL.")
198198
else()
199199
list(APPEND PRIVATE_DEPENDENCIES SPIRV-Tools-opt)
200200
endif()

Graphics/GraphicsEngineVulkan/include/GenerateMipsVkHelper.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ class GenerateMipsVkHelper
6666
VkImageLayout GenerateMipsCS(TextureViewVkImpl& TexView, DeviceContextVkImpl& Ctx, IShaderResourceBinding& SRB, VkImageSubresourceRange& SubresRange);
6767
VkImageLayout GenerateMipsBlit(TextureViewVkImpl& TexView, DeviceContextVkImpl& Ctx, VkImageSubresourceRange& SubresRange) const;
6868

69+
#if !DILIGENT_NO_GLSLANG
6970
RenderDeviceVkImpl& m_DeviceVkImpl;
71+
#endif
7072

7173
std::mutex m_PSOMutex;
7274
std::unordered_map<TEXTURE_FORMAT, std::array<RefCntAutoPtr<IPipelineState>, 4>> m_PSOHash;

Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@
4242
#include "../../GraphicsTools/interface/CommonlyUsedStates.h"
4343
#include "../../GraphicsTools/interface/MapHelper.hpp"
4444

45-
45+
#if !DILIGENT_NO_GLSLANG
4646
// clang-format off
4747
static const char* g_GenerateMipsCSSource =
4848
{
4949
#include "../shaders/GenerateMipsCS_inc.h"
5050
};
5151
// clang-format on
52+
#endif
5253

5354
namespace Diligent
5455
{
@@ -182,8 +183,12 @@ std::array<RefCntAutoPtr<IPipelineState>, 4> GenerateMipsVkHelper::CreatePSOs(TE
182183
return PSOs;
183184
}
184185

185-
GenerateMipsVkHelper::GenerateMipsVkHelper(RenderDeviceVkImpl& DeviceVkImpl) :
186-
m_DeviceVkImpl(DeviceVkImpl)
186+
GenerateMipsVkHelper::GenerateMipsVkHelper(RenderDeviceVkImpl& DeviceVkImpl)
187+
#if !DILIGENT_NO_GLSLANG
188+
// clang-format off
189+
: m_DeviceVkImpl{DeviceVkImpl}
190+
// clang-format on
191+
#endif
187192
{
188193
#if !DILIGENT_NO_GLSLANG
189194
BufferDesc ConstantsCBDesc;

Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,12 @@
4545

4646
#if !DILIGENT_NO_HLSL
4747
# include "spirv-tools/optimizer.hpp"
48+
# include "SPIRVTools.hpp"
4849
#endif
4950

5051
namespace Diligent
5152
{
5253

53-
#if !DILIGENT_NO_HLSL
54-
namespace GLSLangUtils
55-
{
56-
void SpvOptimizerMessageConsumer(
57-
spv_message_level_t level,
58-
const char* /* source */,
59-
const spv_position_t& /* position */,
60-
const char* message);
61-
}
62-
#endif
63-
6454
namespace
6555
{
6656

@@ -80,7 +70,7 @@ bool StripReflection(const VulkanUtilities::VulkanLogicalDevice& LogicalDevice,
8070
}
8171

8272
spvtools::Optimizer SpirvOptimizer{Target};
83-
SpirvOptimizer.SetMessageConsumer(GLSLangUtils::SpvOptimizerMessageConsumer);
73+
SpirvOptimizer.SetMessageConsumer(SpvOptimizerMessageConsumer);
8474
// Decorations defined in SPV_GOOGLE_hlsl_functionality1 are the only instructions
8575
// removed by strip-reflect-info pass. SPIRV offsets become INVALID after this operation.
8676
SpirvOptimizer.RegisterPass(spvtools::CreateStripReflectInfoPass());

Graphics/ShaderTools/CMakeLists.txt

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,24 +72,27 @@ endif()
7272

7373
if(VULKAN_SUPPORTED OR METAL_SUPPORTED)
7474
set(ENABLE_SPIRV TRUE)
75+
if (NOT ${DILIGENT_NO_GLSLANG})
76+
set(USE_GLSLANG TRUE)
77+
set(USE_SPIRV_TOOLS TRUE)
78+
endif()
79+
if (NOT ${DILIGENT_NO_HLSL})
80+
set(USE_SPIRV_TOOLS TRUE)
81+
endif()
7582
endif()
7683

7784
if(ENABLE_SPIRV)
7885
list(APPEND SOURCE src/SPIRVShaderResources.cpp)
7986
list(APPEND INCLUDE include/SPIRVShaderResources.hpp)
8087

81-
if (NOT ${DILIGENT_NO_GLSLANG})
88+
if (${USE_SPIRV_TOOLS})
89+
list(APPEND SOURCE src/SPIRVTools.cpp)
90+
list(APPEND INCLUDE include/SPIRVTools.hpp)
91+
endif()
92+
93+
if (${USE_GLSLANG})
8294
list(APPEND SOURCE src/GLSLangUtils.cpp)
8395
list(APPEND INCLUDE include/GLSLangUtils.hpp)
84-
85-
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
86-
# Disable the following warning:
87-
# moving a local object in a return statement prevents copy elision [-Wpessimizing-move]
88-
set_source_files_properties(src/SPIRVUtils.cpp
89-
PROPERTIES
90-
COMPILE_FLAGS -Wno-pessimizing-move
91-
)
92-
endif()
9396
endif()
9497
endif()
9598

@@ -133,13 +136,19 @@ if(ENABLE_SPIRV)
133136
spirv-cross-core
134137
)
135138

136-
if (NOT ${DILIGENT_NO_GLSLANG})
139+
if (${USE_SPIRV_TOOLS})
137140
target_link_libraries(Diligent-ShaderTools
138141
PRIVATE
139-
glslang
140-
SPIRV
141142
SPIRV-Tools-opt
142143
)
144+
endif()
145+
146+
if (${USE_GLSLANG})
147+
target_link_libraries(Diligent-ShaderTools
148+
PRIVATE
149+
SPIRV
150+
glslang
151+
)
143152

144153
target_include_directories(Diligent-ShaderTools
145154
PRIVATE
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2019-2021 Diligent Graphics LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* In no event and under no legal theory, whether in tort (including negligence),
17+
* contract, or otherwise, unless required by applicable law (such as deliberate
18+
* and grossly negligent acts) or agreed to in writing, shall any Contributor be
19+
* liable for any damages, including any direct, indirect, special, incidental,
20+
* or consequential damages of any character arising as a result of this License or
21+
* out of the use or inability to use the software (including but not limited to damages
22+
* for loss of goodwill, work stoppage, computer failure or malfunction, or any and
23+
* all other commercial damages or losses), even if such Contributor has been advised
24+
* of the possibility of such damages.
25+
*/
26+
27+
#pragma once
28+
29+
#include "spirv-tools/libspirv.h"
30+
31+
namespace Diligent
32+
{
33+
34+
void SpvOptimizerMessageConsumer(
35+
spv_message_level_t level,
36+
const char* source,
37+
const spv_position_t& position,
38+
const char* message);
39+
40+
} // namespace Diligent

Graphics/ShaderTools/src/GLSLangUtils.cpp

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "DataBlobImpl.hpp"
4343
#include "RefCntAutoPtr.hpp"
4444
#include "ShaderToolsCommon.hpp"
45+
#include "SPIRVTools.hpp"
4546

4647
#include "spirv-tools/optimizer.hpp"
4748

@@ -335,54 +336,6 @@ class IncluderImpl : public ::glslang::TShader::Includer
335336

336337
} // namespace
337338

338-
void SpvOptimizerMessageConsumer(
339-
spv_message_level_t level,
340-
const char* /* source */,
341-
const spv_position_t& /* position */,
342-
const char* message)
343-
{
344-
const char* LevelText = "message";
345-
DEBUG_MESSAGE_SEVERITY MsgSeverity = DEBUG_MESSAGE_SEVERITY_INFO;
346-
switch (level)
347-
{
348-
case SPV_MSG_FATAL:
349-
// Unrecoverable error due to environment (e.g. out of memory)
350-
LevelText = "fatal error";
351-
MsgSeverity = DEBUG_MESSAGE_SEVERITY_FATAL_ERROR;
352-
break;
353-
354-
case SPV_MSG_INTERNAL_ERROR:
355-
// Unrecoverable error due to SPIRV-Tools internals (e.g. unimplemented feature)
356-
LevelText = "internal error";
357-
MsgSeverity = DEBUG_MESSAGE_SEVERITY_ERROR;
358-
break;
359-
360-
case SPV_MSG_ERROR:
361-
// Normal error due to user input.
362-
LevelText = "error";
363-
MsgSeverity = DEBUG_MESSAGE_SEVERITY_ERROR;
364-
break;
365-
366-
case SPV_MSG_WARNING:
367-
LevelText = "warning";
368-
MsgSeverity = DEBUG_MESSAGE_SEVERITY_WARNING;
369-
break;
370-
371-
case SPV_MSG_INFO:
372-
LevelText = "info";
373-
MsgSeverity = DEBUG_MESSAGE_SEVERITY_INFO;
374-
break;
375-
376-
case SPV_MSG_DEBUG:
377-
LevelText = "debug";
378-
MsgSeverity = DEBUG_MESSAGE_SEVERITY_INFO;
379-
break;
380-
}
381-
382-
if (level == SPV_MSG_FATAL || level == SPV_MSG_INTERNAL_ERROR || level == SPV_MSG_ERROR || level == SPV_MSG_WARNING)
383-
LOG_DEBUG_MESSAGE(MsgSeverity, "Spirv optimizer ", LevelText, ": ", message);
384-
}
385-
386339
std::vector<unsigned int> HLSLtoSPIRV(const ShaderCreateInfo& ShaderCI,
387340
const char* ExtraDefinitions,
388341
IDataBlob** ppCompilerOutput)

0 commit comments

Comments
 (0)