Skip to content

Commit

Permalink
Merge branch 'main' into footprint
Browse files Browse the repository at this point in the history
  • Loading branch information
expipiplus1 authored Dec 18, 2024
2 parents 2b315c2 + 1a84052 commit 6c7bec8
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 12 deletions.
6 changes: 3 additions & 3 deletions kokoro/scripts/linux/build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ if [ $TOOL != "cmake-smoketest" ]; then
fi

if [ $TOOL = "cmake" ]; then
using cmake-3.17.2
using cmake-3.31.2
using ninja-1.10.0

# Possible configurations are:
Expand Down Expand Up @@ -116,7 +116,7 @@ if [ $TOOL = "cmake" ]; then
cd $KOKORO_ARTIFACTS_DIR
tar czf install.tgz install
elif [ $TOOL = "cmake-smoketest" ]; then
using cmake-3.17.2
using cmake-3.31.2
using ninja-1.10.0

# Get shaderc.
Expand Down Expand Up @@ -157,7 +157,7 @@ elif [ $TOOL = "cmake-smoketest" ]; then
ctest --output-on-failure -j4
echo $(date): ctest completed.
elif [ $TOOL = "cmake-android-ndk" ]; then
using cmake-3.17.2
using cmake-3.31.2
using ndk-r25c
using ninja-1.10.0

Expand Down
5 changes: 3 additions & 2 deletions kokoro/scripts/windows/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ set SRC=%cd%\github\SPIRV-Tools
set BUILD_TYPE=%1
set VS_VERSION=%2

:: Force usage of python 3.6
set PATH=C:\python36;"C:\Program Files\cmake-3.23.1-windows-x86_64\bin";%PATH%
:: Force usage of python 3.6, cmake 3.31.2
set PATH=C:\python36;c:\cmake-3.31.2\bin;%PATH%

:: #########################################
:: set up msvc build env
Expand Down Expand Up @@ -63,6 +63,7 @@ if "%BUILD_TESTS%" == "NO" (
set CMAKE_FLAGS=-DSPIRV_SKIP_TESTS=ON %CMAKE_FLAGS%
)

cmake --version
cmake %CMAKE_FLAGS% ..

if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL%
Expand Down
3 changes: 3 additions & 0 deletions source/enum_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <stddef.h>

#include <algorithm>
#include <cassert>
#include <cstdint>
#include <functional>
#include <initializer_list>
#include <iterator>
#include <limits>
#include <type_traits>
#include <vector>
Expand Down
1 change: 1 addition & 0 deletions source/opt/aggressive_dead_code_elim_pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ void AggressiveDCEPass::InitializeModuleScopeLiveInstructions() {
auto op = dbg.GetShader100DebugOpcode();
if (op == NonSemanticShaderDebugInfo100DebugCompilationUnit ||
op == NonSemanticShaderDebugInfo100DebugEntryPoint ||
op == NonSemanticShaderDebugInfo100DebugSource ||
op == NonSemanticShaderDebugInfo100DebugSourceContinued) {
AddToWorklist(&dbg);
}
Expand Down
1 change: 1 addition & 0 deletions source/opt/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <charconv>
#include <memory>
#include <string>
#include <system_error>
#include <unordered_map>
#include <utility>
#include <vector>
Expand Down
2 changes: 1 addition & 1 deletion source/spirv_target_env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ bool spvReadEnvironmentFromText(const std::vector<char>& text,
// If no match, determine whether the header has ended (in which case,
// assumption has failed.)
// Skip until the next line.
i = j;
i += j;
for (; i < text.size(); ++i) {
if (text[i] == '\n') break;
}
Expand Down
1 change: 1 addition & 0 deletions source/val/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <map>
#include <set>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
Expand Down
5 changes: 3 additions & 2 deletions source/val/validate_extensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3208,10 +3208,11 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) {
return _.diag(SPV_ERROR_INVALID_DATA, inst)
<< ext_inst_name() << ": operand Line End (" << line_end
<< ") is less than Line Start (" << line_start << ")";
} else if (column_end < column_start) {
} else if (line_start == line_end && column_end < column_start) {
return _.diag(SPV_ERROR_INVALID_DATA, inst)
<< ext_inst_name() << ": operand Column End (" << column_end
<< ") is less than Column Start (" << column_start << ")";
<< ") is less than Column Start (" << column_start
<< ") when Line Start equals Line End";
}
break;
}
Expand Down
64 changes: 64 additions & 0 deletions test/opt/aggressive_dead_code_elim_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <string>
#include <vector>

#include "gmock/gmock.h"
#include "test/opt/assembly_builder.h"
#include "test/opt/pass_fixture.h"
#include "test/opt/pass_utils.h"
Expand All @@ -26,6 +27,8 @@ namespace {

using AggressiveDCETest = PassTest<::testing::Test>;

using ::testing::HasSubstr;

TEST_F(AggressiveDCETest, EliminateExtendedInst) {
// #version 140
//
Expand Down Expand Up @@ -8233,6 +8236,67 @@ OpFunctionEnd
SinglePassRunAndCheck<AggressiveDCEPass>(spirv, spirv, true, false);
}

TEST_F(AggressiveDCETest, NoEliminateOpSource) {
// Should not eliminate OpSource

const std::string text =
R"(OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %in_var_COLOR %out_var_SV_TARGET
OpExecutionMode %main OriginUpperLeft
%4 = OpString "D:\\directxshadercompiler\\tools\\clang\\test\\CodeGenSPIRV\\spirv.debug.opsource.include.hlsl"
%5 = OpString "D:\\directxshadercompiler\\tools\\clang\\test\\CodeGenSPIRV/spirv.debug.opsource.include-file.hlsli"
OpSource HLSL 600 %4 "// RUN: %dxc -T ps_6_0 -E main -Zi %s -spirv | FileCheck %s
#include \"spirv.debug.opsource.include-file.hlsli\"
struct ColorType
{
float4 position : SV_POSITION;
float4 color : COLOR;
};
float4 main(UBER_TYPE(Color) input) : SV_TARGET
{
return input.color;
}
"
OpSource HLSL 600 %5 "#define UBER_TYPE(x) x ## Type
"
OpName %in_var_COLOR "in.var.COLOR"
OpName %out_var_SV_TARGET "out.var.SV_TARGET"
OpName %main "main"
OpDecorate %in_var_COLOR Location 0
OpDecorate %out_var_SV_TARGET Location 0
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Input_v4float = OpTypePointer Input %v4float
%_ptr_Output_v4float = OpTypePointer Output %v4float
%void = OpTypeVoid
%11 = OpTypeFunction %void
%in_var_COLOR = OpVariable %_ptr_Input_v4float Input
%out_var_SV_TARGET = OpVariable %_ptr_Output_v4float Output
OpLine %4 22 1
%main = OpFunction %void None %11
OpNoLine
%12 = OpLabel
OpLine %4 22 1
%13 = OpLoad %v4float %in_var_COLOR
OpStore %out_var_SV_TARGET %13
OpLine %4 25 1
OpReturn
OpFunctionEnd
)";

auto result = SinglePassRunAndDisassemble<AggressiveDCEPass>(
text, /* skip_nop = */ true, /* skip_validation = */ false);

EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
const std::string& output = std::get<0>(result);
EXPECT_THAT(
output,
HasSubstr("OpSource HLSL 600 %5 \"#define UBER_TYPE(x) x ## Type"));
}

} // namespace
} // namespace opt
} // namespace spvtools
1 change: 1 addition & 0 deletions test/target_env_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ INSTANTIATE_TEST_SUITE_P(
{" \t ; Version: 1.1", true, SPV_ENV_UNIVERSAL_1_1},
// Previous lines
{"; SPIR-V\n; Version: 1.1", true, SPV_ENV_UNIVERSAL_1_1},
{"; -\n; SPIR-V\n; Version: 1.1", true, SPV_ENV_UNIVERSAL_1_1},

// After a non-header line
{"OpCapability Shader\n; Version: 1.1", false, kSentinelEnv}}));
Expand Down
26 changes: 22 additions & 4 deletions test/val/val_ext_inst_debug_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5023,10 +5023,28 @@ TEST_F(ValidateVulkan100DebugInfo, DebugLineColumnEndSmaller) {
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
src, "", dbg_inst_header, body, shader_extension, "Vertex"));
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
EXPECT_THAT(
getDiagnosticString(),
HasSubstr(
"DebugLine: operand Column End (0) is less than Column Start (1)"));
EXPECT_THAT(getDiagnosticString(),
HasSubstr("DebugLine: operand Column End (0) is less than Column "
"Start (1) when Line Start equals Line End"));
}

TEST_F(ValidateVulkan100DebugInfo, DebugLineColumnEndSmallerMultiline) {
const std::string src = R"(
%src = OpString "simple.hlsl"
%code = OpString "int main() { }"
)";

const std::string dbg_inst_header = R"(
%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
)";

const std::string body = R"(
%line1 = OpExtInst %void %DbgExt DebugLine %dbg_src %u32_1 %u32_2 %u32_1 %u32_0
)";

CompileSuccessfully(GenerateShaderCodeForDebugInfo(
src, "", dbg_inst_header, body, shader_extension, "Vertex"));
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
}

} // namespace
Expand Down

0 comments on commit 6c7bec8

Please sign in to comment.