Clean up crlf and mixed line ending issues. (#391)

This commit is contained in:
Young Kim 2017-06-29 16:26:20 -07:00 коммит произвёл GitHub
Родитель fe1e5ccc61
Коммит 7f65e0f0d6
11 изменённых файлов: 11615 добавлений и 11615 удалений

Просмотреть файл

@ -1,365 +1,365 @@
{
// See https://go.microsoft.com//fwlink//?linkid=834763 for more information about this file.
"configurations": [
{
"name": "x64-Debug",
"generator": "Visual Studio 15 2017 Win64",
"configurationType" : "Debug",
"buildRoot": "${projectDir}\\..\\hlsl.bin",
"cmakeCommandArgs": "",
"buildCommandArgs": "-m -v:minimal",
"variables": [
{
"name": "DXC_BUILD_ARCH",
"value": "x64"
},
{
"name": "CLANG_ENABLE_ARCMT:BOOL",
"value": "OFF"
},
{
"name": "CLANG_ENABLE_STATIC_ANALYZER:BOOL",
"value": "OFF"
},
{
"name": "CLANG_INCLUDE_TESTS:BOOL",
"value": "OFF"
},
{
"name": "LLVM_INCLUDE_TESTS:BOOL",
"value": "OFF"
},
{
"name": "HLSL_INCLUDE_TESTS:BOOL",
"value": "ON"
},
{
"name": "LLVM_TARGETS_TO_BUILD:STRING",
"value": "None"
},
{
"name": "LLVM_INCLUDE_DOCS:BOOL",
"value": "OFF"
},
{
"name": "LLVM_INCLUDE_EXAMPLES:BOOL",
"value": "OFF"
},
{
"name": "LIBCLANG_BUILD_STATIC:BOOL",
"value": "ON"
},
{
"name": "LLVM_OPTIMIZED_TABLEGEN:BOOL",
"value": "OFF"
},
{
"name": "LLVM_REQUIRES_EH:BOOL",
"value": "ON"
},
{
"name": "LLVM_APPEND_VC_REV:BOOL",
"value": "ON"
},
{
"name": "LLVM_ENABLE_RTTI:BOOL",
"value": "ON"
},
{
"name": "LLVM_ENABLE_EH:BOOL",
"value": "ON"
},
{
"name": "LLVM_DEFAULT_TARGET_TRIPLE:STRING",
"value": "dxil-ms-dx"
},
{
"name": "CLANG_BUILD_EXAMPLES:BOOL",
"value": "OFF"
},
{
"name": "-DLLVM_REQUIRES_RTTI:BOOL",
"value": "ON"
},
{
"name": "-DCLANG_CL:BOOL",
"value": "OFF"
},
{
"name": "-DCMAKE_SYSTEM_VERSION",
"value": "10.0.14393.0"
}
]
},
{
"name": "x86-Debug",
"generator": "Visual Studio 15 2017",
"configurationType" : "Debug",
"buildRoot": "${projectDir}\\..\\hlsl.bin.${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-m -v:minimal",
"variables": [
{
"name": "DXC_BUILD_ARCH",
"value": "Win32"
},
{
"name": "CLANG_ENABLE_ARCMT:BOOL",
"value": "OFF"
},
{
"name": "CLANG_ENABLE_STATIC_ANALYZER:BOOL",
"value": "OFF"
},
{
"name": "CLANG_INCLUDE_TESTS:BOOL",
"value": "OFF"
},
{
"name": "LLVM_INCLUDE_TESTS:BOOL",
"value": "OFF"
},
{
"name": "HLSL_INCLUDE_TESTS:BOOL",
"value": "ON"
},
{
"name": "LLVM_TARGETS_TO_BUILD:STRING",
"value": "None"
},
{
"name": "LLVM_INCLUDE_DOCS:BOOL",
"value": "OFF"
},
{
"name": "LLVM_INCLUDE_EXAMPLES:BOOL",
"value": "OFF"
},
{
"name": "LIBCLANG_BUILD_STATIC:BOOL",
"value": "ON"
},
{
"name": "LLVM_OPTIMIZED_TABLEGEN:BOOL",
"value": "OFF"
},
{
"name": "LLVM_REQUIRES_EH:BOOL",
"value": "ON"
},
{
"name": "LLVM_APPEND_VC_REV:BOOL",
"value": "ON"
},
{
"name": "LLVM_ENABLE_RTTI:BOOL",
"value": "ON"
},
{
"name": "LLVM_ENABLE_EH:BOOL",
"value": "ON"
},
{
"name": "LLVM_DEFAULT_TARGET_TRIPLE:STRING",
"value": "dxil-ms-dx"
},
{
"name": "CLANG_BUILD_EXAMPLES:BOOL",
"value": "OFF"
},
{
"name": "-DLLVM_REQUIRES_RTTI:BOOL",
"value": "ON"
},
{
"name": "-DCLANG_CL:BOOL",
"value": "OFF"
},
{
"name": "-DCMAKE_SYSTEM_VERSION",
"value": "10.0.14393.0"
}
]
},
{
"name": "x86-Release",
"generator": "Visual Studio 15 2017",
"configurationType" : "Release",
"buildRoot": "${projectDir}\\..\\hlsl.bin.${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-m -v:minimal",
"variables": [
{
"name": "DXC_BUILD_ARCH",
"value": "Win32"
},
{
"name": "CLANG_ENABLE_ARCMT:BOOL",
"value": "OFF"
},
{
"name": "CLANG_ENABLE_STATIC_ANALYZER:BOOL",
"value": "OFF"
},
{
"name": "CLANG_INCLUDE_TESTS:BOOL",
"value": "OFF"
},
{
"name": "LLVM_INCLUDE_TESTS:BOOL",
"value": "OFF"
},
{
"name": "HLSL_INCLUDE_TESTS:BOOL",
"value": "ON"
},
{
"name": "LLVM_TARGETS_TO_BUILD:STRING",
"value": "None"
},
{
"name": "LLVM_INCLUDE_DOCS:BOOL",
"value": "OFF"
},
{
"name": "LLVM_INCLUDE_EXAMPLES:BOOL",
"value": "OFF"
},
{
"name": "LIBCLANG_BUILD_STATIC:BOOL",
"value": "ON"
},
{
"name": "LLVM_OPTIMIZED_TABLEGEN:BOOL",
"value": "OFF"
},
{
"name": "LLVM_REQUIRES_EH:BOOL",
"value": "ON"
},
{
"name": "LLVM_APPEND_VC_REV:BOOL",
"value": "ON"
},
{
"name": "LLVM_ENABLE_RTTI:BOOL",
"value": "ON"
},
{
"name": "LLVM_ENABLE_EH:BOOL",
"value": "ON"
},
{
"name": "LLVM_DEFAULT_TARGET_TRIPLE:STRING",
"value": "dxil-ms-dx"
},
{
"name": "CLANG_BUILD_EXAMPLES:BOOL",
"value": "OFF"
},
{
"name": "-DLLVM_REQUIRES_RTTI:BOOL",
"value": "ON"
},
{
"name": "-DCLANG_CL:BOOL",
"value": "OFF"
},
{
"name": "-DCMAKE_SYSTEM_VERSION",
"value": "10.0.14393.0"
}
]
},
{
"name": "x64-Release",
"generator": "Visual Studio 15 2017 Win64",
"configurationType" : "Release",
"buildRoot": "${projectDir}\\..\\hlsl.bin.${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-m -v:minimal",
"variables": [
{
"name": "DXC_BUILD_ARCH",
"value": "x64"
},
{
"name": "CLANG_ENABLE_ARCMT:BOOL",
"value": "OFF"
},
{
"name": "CLANG_ENABLE_STATIC_ANALYZER:BOOL",
"value": "OFF"
},
{
"name": "CLANG_INCLUDE_TESTS:BOOL",
"value": "OFF"
},
{
"name": "LLVM_INCLUDE_TESTS:BOOL",
"value": "OFF"
},
{
"name": "HLSL_INCLUDE_TESTS:BOOL",
"value": "ON"
},
{
"name": "LLVM_TARGETS_TO_BUILD:STRING",
"value": "None"
},
{
"name": "LLVM_INCLUDE_DOCS:BOOL",
"value": "OFF"
},
{
"name": "LLVM_INCLUDE_EXAMPLES:BOOL",
"value": "OFF"
},
{
"name": "LIBCLANG_BUILD_STATIC:BOOL",
"value": "ON"
},
{
"name": "LLVM_OPTIMIZED_TABLEGEN:BOOL",
"value": "OFF"
},
{
"name": "LLVM_REQUIRES_EH:BOOL",
"value": "ON"
},
{
"name": "LLVM_APPEND_VC_REV:BOOL",
"value": "ON"
},
{
"name": "LLVM_ENABLE_RTTI:BOOL",
"value": "ON"
},
{
"name": "LLVM_ENABLE_EH:BOOL",
"value": "ON"
},
{
"name": "LLVM_DEFAULT_TARGET_TRIPLE:STRING",
"value": "dxil-ms-dx"
},
{
"name": "CLANG_BUILD_EXAMPLES:BOOL",
"value": "OFF"
},
{
"name": "-DLLVM_REQUIRES_RTTI:BOOL",
"value": "ON"
},
{
"name": "-DCLANG_CL:BOOL",
"value": "OFF"
},
{
"name": "-DCMAKE_SYSTEM_VERSION",
"value": "10.0.14393.0"
}
]
}
]
{
// See https://go.microsoft.com//fwlink//?linkid=834763 for more information about this file.
"configurations": [
{
"name": "x64-Debug",
"generator": "Visual Studio 15 2017 Win64",
"configurationType" : "Debug",
"buildRoot": "${projectDir}\\..\\hlsl.bin",
"cmakeCommandArgs": "",
"buildCommandArgs": "-m -v:minimal",
"variables": [
{
"name": "DXC_BUILD_ARCH",
"value": "x64"
},
{
"name": "CLANG_ENABLE_ARCMT:BOOL",
"value": "OFF"
},
{
"name": "CLANG_ENABLE_STATIC_ANALYZER:BOOL",
"value": "OFF"
},
{
"name": "CLANG_INCLUDE_TESTS:BOOL",
"value": "OFF"
},
{
"name": "LLVM_INCLUDE_TESTS:BOOL",
"value": "OFF"
},
{
"name": "HLSL_INCLUDE_TESTS:BOOL",
"value": "ON"
},
{
"name": "LLVM_TARGETS_TO_BUILD:STRING",
"value": "None"
},
{
"name": "LLVM_INCLUDE_DOCS:BOOL",
"value": "OFF"
},
{
"name": "LLVM_INCLUDE_EXAMPLES:BOOL",
"value": "OFF"
},
{
"name": "LIBCLANG_BUILD_STATIC:BOOL",
"value": "ON"
},
{
"name": "LLVM_OPTIMIZED_TABLEGEN:BOOL",
"value": "OFF"
},
{
"name": "LLVM_REQUIRES_EH:BOOL",
"value": "ON"
},
{
"name": "LLVM_APPEND_VC_REV:BOOL",
"value": "ON"
},
{
"name": "LLVM_ENABLE_RTTI:BOOL",
"value": "ON"
},
{
"name": "LLVM_ENABLE_EH:BOOL",
"value": "ON"
},
{
"name": "LLVM_DEFAULT_TARGET_TRIPLE:STRING",
"value": "dxil-ms-dx"
},
{
"name": "CLANG_BUILD_EXAMPLES:BOOL",
"value": "OFF"
},
{
"name": "-DLLVM_REQUIRES_RTTI:BOOL",
"value": "ON"
},
{
"name": "-DCLANG_CL:BOOL",
"value": "OFF"
},
{
"name": "-DCMAKE_SYSTEM_VERSION",
"value": "10.0.14393.0"
}
]
},
{
"name": "x86-Debug",
"generator": "Visual Studio 15 2017",
"configurationType" : "Debug",
"buildRoot": "${projectDir}\\..\\hlsl.bin.${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-m -v:minimal",
"variables": [
{
"name": "DXC_BUILD_ARCH",
"value": "Win32"
},
{
"name": "CLANG_ENABLE_ARCMT:BOOL",
"value": "OFF"
},
{
"name": "CLANG_ENABLE_STATIC_ANALYZER:BOOL",
"value": "OFF"
},
{
"name": "CLANG_INCLUDE_TESTS:BOOL",
"value": "OFF"
},
{
"name": "LLVM_INCLUDE_TESTS:BOOL",
"value": "OFF"
},
{
"name": "HLSL_INCLUDE_TESTS:BOOL",
"value": "ON"
},
{
"name": "LLVM_TARGETS_TO_BUILD:STRING",
"value": "None"
},
{
"name": "LLVM_INCLUDE_DOCS:BOOL",
"value": "OFF"
},
{
"name": "LLVM_INCLUDE_EXAMPLES:BOOL",
"value": "OFF"
},
{
"name": "LIBCLANG_BUILD_STATIC:BOOL",
"value": "ON"
},
{
"name": "LLVM_OPTIMIZED_TABLEGEN:BOOL",
"value": "OFF"
},
{
"name": "LLVM_REQUIRES_EH:BOOL",
"value": "ON"
},
{
"name": "LLVM_APPEND_VC_REV:BOOL",
"value": "ON"
},
{
"name": "LLVM_ENABLE_RTTI:BOOL",
"value": "ON"
},
{
"name": "LLVM_ENABLE_EH:BOOL",
"value": "ON"
},
{
"name": "LLVM_DEFAULT_TARGET_TRIPLE:STRING",
"value": "dxil-ms-dx"
},
{
"name": "CLANG_BUILD_EXAMPLES:BOOL",
"value": "OFF"
},
{
"name": "-DLLVM_REQUIRES_RTTI:BOOL",
"value": "ON"
},
{
"name": "-DCLANG_CL:BOOL",
"value": "OFF"
},
{
"name": "-DCMAKE_SYSTEM_VERSION",
"value": "10.0.14393.0"
}
]
},
{
"name": "x86-Release",
"generator": "Visual Studio 15 2017",
"configurationType" : "Release",
"buildRoot": "${projectDir}\\..\\hlsl.bin.${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-m -v:minimal",
"variables": [
{
"name": "DXC_BUILD_ARCH",
"value": "Win32"
},
{
"name": "CLANG_ENABLE_ARCMT:BOOL",
"value": "OFF"
},
{
"name": "CLANG_ENABLE_STATIC_ANALYZER:BOOL",
"value": "OFF"
},
{
"name": "CLANG_INCLUDE_TESTS:BOOL",
"value": "OFF"
},
{
"name": "LLVM_INCLUDE_TESTS:BOOL",
"value": "OFF"
},
{
"name": "HLSL_INCLUDE_TESTS:BOOL",
"value": "ON"
},
{
"name": "LLVM_TARGETS_TO_BUILD:STRING",
"value": "None"
},
{
"name": "LLVM_INCLUDE_DOCS:BOOL",
"value": "OFF"
},
{
"name": "LLVM_INCLUDE_EXAMPLES:BOOL",
"value": "OFF"
},
{
"name": "LIBCLANG_BUILD_STATIC:BOOL",
"value": "ON"
},
{
"name": "LLVM_OPTIMIZED_TABLEGEN:BOOL",
"value": "OFF"
},
{
"name": "LLVM_REQUIRES_EH:BOOL",
"value": "ON"
},
{
"name": "LLVM_APPEND_VC_REV:BOOL",
"value": "ON"
},
{
"name": "LLVM_ENABLE_RTTI:BOOL",
"value": "ON"
},
{
"name": "LLVM_ENABLE_EH:BOOL",
"value": "ON"
},
{
"name": "LLVM_DEFAULT_TARGET_TRIPLE:STRING",
"value": "dxil-ms-dx"
},
{
"name": "CLANG_BUILD_EXAMPLES:BOOL",
"value": "OFF"
},
{
"name": "-DLLVM_REQUIRES_RTTI:BOOL",
"value": "ON"
},
{
"name": "-DCLANG_CL:BOOL",
"value": "OFF"
},
{
"name": "-DCMAKE_SYSTEM_VERSION",
"value": "10.0.14393.0"
}
]
},
{
"name": "x64-Release",
"generator": "Visual Studio 15 2017 Win64",
"configurationType" : "Release",
"buildRoot": "${projectDir}\\..\\hlsl.bin.${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-m -v:minimal",
"variables": [
{
"name": "DXC_BUILD_ARCH",
"value": "x64"
},
{
"name": "CLANG_ENABLE_ARCMT:BOOL",
"value": "OFF"
},
{
"name": "CLANG_ENABLE_STATIC_ANALYZER:BOOL",
"value": "OFF"
},
{
"name": "CLANG_INCLUDE_TESTS:BOOL",
"value": "OFF"
},
{
"name": "LLVM_INCLUDE_TESTS:BOOL",
"value": "OFF"
},
{
"name": "HLSL_INCLUDE_TESTS:BOOL",
"value": "ON"
},
{
"name": "LLVM_TARGETS_TO_BUILD:STRING",
"value": "None"
},
{
"name": "LLVM_INCLUDE_DOCS:BOOL",
"value": "OFF"
},
{
"name": "LLVM_INCLUDE_EXAMPLES:BOOL",
"value": "OFF"
},
{
"name": "LIBCLANG_BUILD_STATIC:BOOL",
"value": "ON"
},
{
"name": "LLVM_OPTIMIZED_TABLEGEN:BOOL",
"value": "OFF"
},
{
"name": "LLVM_REQUIRES_EH:BOOL",
"value": "ON"
},
{
"name": "LLVM_APPEND_VC_REV:BOOL",
"value": "ON"
},
{
"name": "LLVM_ENABLE_RTTI:BOOL",
"value": "ON"
},
{
"name": "LLVM_ENABLE_EH:BOOL",
"value": "ON"
},
{
"name": "LLVM_DEFAULT_TARGET_TRIPLE:STRING",
"value": "dxil-ms-dx"
},
{
"name": "CLANG_BUILD_EXAMPLES:BOOL",
"value": "OFF"
},
{
"name": "-DLLVM_REQUIRES_RTTI:BOOL",
"value": "ON"
},
{
"name": "-DCLANG_CL:BOOL",
"value": "OFF"
},
{
"name": "-DCMAKE_SYSTEM_VERSION",
"value": "10.0.14393.0"
}
]
}
]
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,176 +1,176 @@
///////////////////////////////////////////////////////////////////////////////
// //
// DxilOutputColorBecomesConstant.cpp //
// Copyright (C) Microsoft Corporation. All rights reserved. //
// This file is distributed under the University of Illinois Open Source //
// License. See LICENSE.TXT for details. //
// //
// Provides a pass to stomp a pixel shader's output color to a given //
// constant value //
// //
///////////////////////////////////////////////////////////////////////////////
#include "dxc/HLSL/DxilGenerationPass.h"
#include "dxc/HLSL/DxilOperations.h"
#include "dxc/HLSL/DxilSignatureElement.h"
#include "dxc/HLSL/DxilModule.h"
#include "dxc/Support/Global.h"
#include "dxc/HLSL/DxilTypeSystem.h"
#include "dxc/HLSL/DxilInstructions.h"
#include "dxc/HLSL/DxilSpanAllocator.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/Pass.h"
#include "llvm/Transforms/Utils/Local.h"
#include <memory>
#include <unordered_set>
using namespace llvm;
using namespace hlsl;
class DxilOutputColorBecomesConstant : public ModulePass {
enum VisualizerInstrumentationMode
{
PRESERVE_ORIGINAL_INSTRUCTIONS,
REMOVE_DISCARDS_AND_OPTIONALLY_OTHER_INSTRUCTIONS
};
float Red = 1.f;
float Green = 1.f;
float Blue = 1.f;
float Alpha = 1.f;
VisualizerInstrumentationMode Mode;
bool convertTarget0ToConstantValue(Function * OutputFunction, const hlsl::DxilSignature &OutputSignature, OP * HlslOP, float * color);
public:
static char ID; // Pass identification, replacement for typeid
explicit DxilOutputColorBecomesConstant() : ModulePass(ID) {}
const char *getPassName() const override { return "DXIL Constant Color Mod"; }
void applyOptions(PassOptions O) override;
bool runOnModule(Module &M) override;
};
void DxilOutputColorBecomesConstant::applyOptions(PassOptions O)
{
for (const auto & option : O)
{
if (0 == option.first.compare("constant-red"))
{
Red = atof(option.second.data());
}
else if (0 == option.first.compare("constant-green"))
{
Green = atof(option.second.data());
}
else if (0 == option.first.compare("constant-blue"))
{
Blue = atof(option.second.data());
}
else if (0 == option.first.compare("constant-alpha"))
{
Alpha = atof(option.second.data());
}
else if (0 == option.first.compare("mod-mode"))
{
Mode = static_cast<VisualizerInstrumentationMode>(atoi(option.second.data()));
}
}
}
bool DxilOutputColorBecomesConstant::convertTarget0ToConstantValue(
Function * OutputFunction,
const hlsl::DxilSignature &OutputSignature,
OP * HlslOP,
float * color) {
bool Modified = false;
auto OutputFunctionUses = OutputFunction->uses();
for (Use &FunctionUse : OutputFunctionUses) {
iterator_range<Value::user_iterator> FunctionUsers = FunctionUse->users();
for (User * FunctionUser : FunctionUsers) {
if (isa<Instruction>(FunctionUser)) {
auto CallInstruction = cast<CallInst>(FunctionUser);
// Check if the instruction writes to a render target (as opposed to a system-value, such as RenderTargetArrayIndex)
///////////////////////////////////////////////////////////////////////////////
// //
// DxilOutputColorBecomesConstant.cpp //
// Copyright (C) Microsoft Corporation. All rights reserved. //
// This file is distributed under the University of Illinois Open Source //
// License. See LICENSE.TXT for details. //
// //
// Provides a pass to stomp a pixel shader's output color to a given //
// constant value //
// //
///////////////////////////////////////////////////////////////////////////////
#include "dxc/HLSL/DxilGenerationPass.h"
#include "dxc/HLSL/DxilOperations.h"
#include "dxc/HLSL/DxilSignatureElement.h"
#include "dxc/HLSL/DxilModule.h"
#include "dxc/Support/Global.h"
#include "dxc/HLSL/DxilTypeSystem.h"
#include "dxc/HLSL/DxilInstructions.h"
#include "dxc/HLSL/DxilSpanAllocator.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/Pass.h"
#include "llvm/Transforms/Utils/Local.h"
#include <memory>
#include <unordered_set>
using namespace llvm;
using namespace hlsl;
class DxilOutputColorBecomesConstant : public ModulePass {
enum VisualizerInstrumentationMode
{
PRESERVE_ORIGINAL_INSTRUCTIONS,
REMOVE_DISCARDS_AND_OPTIONALLY_OTHER_INSTRUCTIONS
};
float Red = 1.f;
float Green = 1.f;
float Blue = 1.f;
float Alpha = 1.f;
VisualizerInstrumentationMode Mode;
bool convertTarget0ToConstantValue(Function * OutputFunction, const hlsl::DxilSignature &OutputSignature, OP * HlslOP, float * color);
public:
static char ID; // Pass identification, replacement for typeid
explicit DxilOutputColorBecomesConstant() : ModulePass(ID) {}
const char *getPassName() const override { return "DXIL Constant Color Mod"; }
void applyOptions(PassOptions O) override;
bool runOnModule(Module &M) override;
};
void DxilOutputColorBecomesConstant::applyOptions(PassOptions O)
{
for (const auto & option : O)
{
if (0 == option.first.compare("constant-red"))
{
Red = atof(option.second.data());
}
else if (0 == option.first.compare("constant-green"))
{
Green = atof(option.second.data());
}
else if (0 == option.first.compare("constant-blue"))
{
Blue = atof(option.second.data());
}
else if (0 == option.first.compare("constant-alpha"))
{
Alpha = atof(option.second.data());
}
else if (0 == option.first.compare("mod-mode"))
{
Mode = static_cast<VisualizerInstrumentationMode>(atoi(option.second.data()));
}
}
}
bool DxilOutputColorBecomesConstant::convertTarget0ToConstantValue(
Function * OutputFunction,
const hlsl::DxilSignature &OutputSignature,
OP * HlslOP,
float * color) {
bool Modified = false;
auto OutputFunctionUses = OutputFunction->uses();
for (Use &FunctionUse : OutputFunctionUses) {
iterator_range<Value::user_iterator> FunctionUsers = FunctionUse->users();
for (User * FunctionUser : FunctionUsers) {
if (isa<Instruction>(FunctionUser)) {
auto CallInstruction = cast<CallInst>(FunctionUser);
// Check if the instruction writes to a render target (as opposed to a system-value, such as RenderTargetArrayIndex)
Value *OutputID = CallInstruction->getArgOperand(DXIL::OperandIndex::kStoreOutputIDOpIdx);
unsigned SignatureElementIndex = cast<ConstantInt>(OutputID)->getLimitedValue();
unsigned SignatureElementIndex = cast<ConstantInt>(OutputID)->getLimitedValue();
const DxilSignatureElement &SignatureElement = OutputSignature.GetElement(SignatureElementIndex);
// We only modify the output color for RTV0
if (SignatureElement.GetSemantic()->GetKind() == DXIL::SemanticKind::Target &&
SignatureElement.GetSemanticStartIndex() == 0)
{
// The output column is the channel (red, green, blue or alpha) within the output pixel
Value * OutputColumnOperand = CallInstruction->getOperand(hlsl::DXIL::OperandIndex::kStoreOutputColOpIdx);
ConstantInt * OutputColumnConstant = cast<ConstantInt>(OutputColumnOperand);
APInt OutputColumn = OutputColumnConstant->getValue();
Value * OutputValueOperand = CallInstruction->getOperand(hlsl::DXIL::OperandIndex::kStoreOutputValOpIdx);
// Replace the source operand with the appropriate constant literal value
if (OutputValueOperand->getType()->isFloatingPointTy())
{
Modified = true;
Constant * FloatConstant = HlslOP->GetFloatConst(color[*OutputColumn.getRawData()]);
CallInstruction->setOperand(hlsl::DXIL::OperandIndex::kStoreOutputValOpIdx, FloatConstant);
}
else if (OutputValueOperand->getType()->isIntegerTy())
{
Modified = true;
Constant * pIntegerConstant = HlslOP->GetI32Const(static_cast<int>(color[*OutputColumn.getRawData()]));
CallInstruction->setOperand(hlsl::DXIL::OperandIndex::kStoreOutputValOpIdx, pIntegerConstant);
}
}
}
}
}
return Modified;
}
bool DxilOutputColorBecomesConstant::runOnModule(Module &M)
{
// This pass finds all users of the "StoreOutput" function, and replaces their source operands with a constant
// value.
float color[4] = { Red, Green, Blue, Alpha };
DxilModule &DM = M.GetOrCreateDxilModule();
LLVMContext & Ctx = M.getContext();
OP *HlslOP = DM.GetOP();
const hlsl::DxilSignature & OutputSignature = DM.GetOutputSignature();
bool Modified = false;
// The StoreOutput function can store either a float or an integer, depending on the intended output
// render-target resource view.
Function * FloatOutputFunction = HlslOP->GetOpFunc(DXIL::OpCode::StoreOutput, Type::getFloatTy(Ctx));
if (FloatOutputFunction->getNumUses() != 0) {
Modified = convertTarget0ToConstantValue(FloatOutputFunction, OutputSignature, HlslOP, color);
}
Function * IntOutputFunction = HlslOP->GetOpFunc(DXIL::OpCode::StoreOutput, Type::getInt32Ty(Ctx));
if (IntOutputFunction->getNumUses() != 0) {
Modified = convertTarget0ToConstantValue(IntOutputFunction, OutputSignature, HlslOP, color);
}
return Modified;
}
char DxilOutputColorBecomesConstant::ID = 0;
ModulePass *llvm::createDxilOutputColorBecomesConstantPass() {
return new DxilOutputColorBecomesConstant();
}
INITIALIZE_PASS(DxilOutputColorBecomesConstant, "hlsl-dxil-constantColor", "DXIL Constant Color Mod", false, false)
// We only modify the output color for RTV0
if (SignatureElement.GetSemantic()->GetKind() == DXIL::SemanticKind::Target &&
SignatureElement.GetSemanticStartIndex() == 0)
{
// The output column is the channel (red, green, blue or alpha) within the output pixel
Value * OutputColumnOperand = CallInstruction->getOperand(hlsl::DXIL::OperandIndex::kStoreOutputColOpIdx);
ConstantInt * OutputColumnConstant = cast<ConstantInt>(OutputColumnOperand);
APInt OutputColumn = OutputColumnConstant->getValue();
Value * OutputValueOperand = CallInstruction->getOperand(hlsl::DXIL::OperandIndex::kStoreOutputValOpIdx);
// Replace the source operand with the appropriate constant literal value
if (OutputValueOperand->getType()->isFloatingPointTy())
{
Modified = true;
Constant * FloatConstant = HlslOP->GetFloatConst(color[*OutputColumn.getRawData()]);
CallInstruction->setOperand(hlsl::DXIL::OperandIndex::kStoreOutputValOpIdx, FloatConstant);
}
else if (OutputValueOperand->getType()->isIntegerTy())
{
Modified = true;
Constant * pIntegerConstant = HlslOP->GetI32Const(static_cast<int>(color[*OutputColumn.getRawData()]));
CallInstruction->setOperand(hlsl::DXIL::OperandIndex::kStoreOutputValOpIdx, pIntegerConstant);
}
}
}
}
}
return Modified;
}
bool DxilOutputColorBecomesConstant::runOnModule(Module &M)
{
// This pass finds all users of the "StoreOutput" function, and replaces their source operands with a constant
// value.
float color[4] = { Red, Green, Blue, Alpha };
DxilModule &DM = M.GetOrCreateDxilModule();
LLVMContext & Ctx = M.getContext();
OP *HlslOP = DM.GetOP();
const hlsl::DxilSignature & OutputSignature = DM.GetOutputSignature();
bool Modified = false;
// The StoreOutput function can store either a float or an integer, depending on the intended output
// render-target resource view.
Function * FloatOutputFunction = HlslOP->GetOpFunc(DXIL::OpCode::StoreOutput, Type::getFloatTy(Ctx));
if (FloatOutputFunction->getNumUses() != 0) {
Modified = convertTarget0ToConstantValue(FloatOutputFunction, OutputSignature, HlslOP, color);
}
Function * IntOutputFunction = HlslOP->GetOpFunc(DXIL::OpCode::StoreOutput, Type::getInt32Ty(Ctx));
if (IntOutputFunction->getNumUses() != 0) {
Modified = convertTarget0ToConstantValue(IntOutputFunction, OutputSignature, HlslOP, color);
}
return Modified;
}
char DxilOutputColorBecomesConstant::ID = 0;
ModulePass *llvm::createDxilOutputColorBecomesConstantPass() {
return new DxilOutputColorBecomesConstant();
}
INITIALIZE_PASS(DxilOutputColorBecomesConstant, "hlsl-dxil-constantColor", "DXIL Constant Color Mod", false, false)

Просмотреть файл

@ -1,13 +1,13 @@
// RUN: %dxc -Emain -Tps_6_0 %s | %opt -S -hlsl-dxil-constantColor | %FileCheck %s
// Check the write to the integer part was replaced (since it is RTV0):
// CHECK: call void @dx.op.storeOutput.i32(i32 5, i32 0, i32 0, i8 0, i32 1)
// Check the write to the integer part was replaced (since it is RTV0):
// CHECK: call void @dx.op.storeOutput.i32(i32 5, i32 0, i32 0, i8 0, i32 1)
// Check color in RTV1 is unaffected:
// CHECK: call void @dx.op.storeOutput.f32(i32 5, i32 1, i32 0, i8 0, float 0.000000e+00)
// CHECK: call void @dx.op.storeOutput.f32(i32 5, i32 1, i32 0, i8 1, float 0.000000e+00)
// CHECK: call void @dx.op.storeOutput.f32(i32 5, i32 1, i32 0, i8 2, float 0.000000e+00)
// CHECK: call void @dx.op.storeOutput.f32(i32 5, i32 1, i32 0, i8 3, float 0.000000e+00)
// CHECK: call void @dx.op.storeOutput.f32(i32 5, i32 1, i32 0, i8 0, float 0.000000e+00)
// CHECK: call void @dx.op.storeOutput.f32(i32 5, i32 1, i32 0, i8 1, float 0.000000e+00)
// CHECK: call void @dx.op.storeOutput.f32(i32 5, i32 1, i32 0, i8 2, float 0.000000e+00)
// CHECK: call void @dx.op.storeOutput.f32(i32 5, i32 1, i32 0, i8 3, float 0.000000e+00)
struct RTOut
{
@ -17,8 +17,8 @@ struct RTOut
[RootSignature("")]
RTOut main() {
RTOut rtOut;
rtOut.i = 8;
rtOut.c = float4(0.f, 0.f, 0.f, 0.f);
RTOut rtOut;
rtOut.i = 8;
rtOut.c = float4(0.f, 0.f, 0.f, 0.f);
return rtOut;
}

Просмотреть файл

@ -1,7 +1,7 @@
// RUN: %dxc -Emain -Tps_6_0 %s | %opt -S -hlsl-dxil-constantColor,constant-red=1 | %FileCheck %s
// Check that we overrode output color (0.0 becomes 1.0):
// CHECK: call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 0, float 1.000000e+00)
// CHECK: call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 0, float 1.000000e+00)
// Check output depth wasn't affected (0.0 stays 0.0):
// CHECK: call void @dx.op.storeOutput.f32(i32 5, i32 1, i32 0, i8 0, float 0.000000e+00)

Просмотреть файл

@ -1,22 +1,22 @@
// RUN: %dxc -Emain -Tps_6_0 %s | %opt -S -hlsl-dxil-constantColor | %FileCheck %s
// Check the write to the UAVs were unaffected:
// CHECK: %floatRWUAV_UAV_structbuf = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 1, i32 1, i32 1, i1 false)
// CHECK: %uav0_UAV_2d = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 1, i32 0, i32 0, i1 false)
// CHECK: call void @dx.op.textureStore.f32(i32 67, %dx.types.Handle %uav0_UAV_2d, i32 0, i32 0, i32 undef, float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00, i8 15)
// Check the write to the UAVs were unaffected:
// CHECK: %floatRWUAV_UAV_structbuf = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 1, i32 1, i32 1, i1 false)
// CHECK: %uav0_UAV_2d = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 1, i32 0, i32 0, i1 false)
// CHECK: call void @dx.op.textureStore.f32(i32 67, %dx.types.Handle %uav0_UAV_2d, i32 0, i32 0, i32 undef, float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00, i8 15)
// Added override output color:
// CHECK: call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 0, float 1.000000e+00)
// CHECK: call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 0, float 1.000000e+00)
RWTexture2D<float4> uav0 : register(u0);
RWStructuredBuffer<float> floatRWUAV: register(u1);
RWTexture2D<float4> uav0 : register(u0);
RWStructuredBuffer<float> floatRWUAV: register(u1);
[RootSignature(
[RootSignature(
"DescriptorTable(UAV(u0, numDescriptors = 1, space = 0, offset = DESCRIPTOR_RANGE_OFFSET_APPEND)), "
"UAV(u1)"
)]
float main() : SV_Target {
floatRWUAV[0] = 3.5;
uav0[uint2(0,0)] = float4(1,2,3,4);
uav0[uint2(0,0)] = float4(1,2,3,4);
return 2.5;
}

Просмотреть файл

@ -1,7 +1,7 @@
// RUN: %dxc -Emain -Tps_6_0 %s | %opt -S -hlsl-dxil-constantColor,constant-red=2.5,constant-green=8,constant-blue=7,constant-alpha=6 | %FileCheck %s
// Added override output color:
// CHECK: call void @dx.op.storeOutput.i32(i32 5, i32 0, i32 0, i8 0, i32 2)
// CHECK: call void @dx.op.storeOutput.i32(i32 5, i32 0, i32 0, i8 0, i32 2)
[RootSignature("")]
unsigned int main() : SV_Target {

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,333 +1,333 @@
///////////////////////////////////////////////////////////////////////////////
// //
// HlslTestUtils.h //
// Copyright (C) Microsoft Corporation. All rights reserved. //
// This file is distributed under the University of Illinois Open Source //
// License. See LICENSE.TXT for details. //
// //
// Provides utility functions for HLSL tests. //
// //
///////////////////////////////////////////////////////////////////////////////
#include <string>
#include <sstream>
#include <fstream>
#include "dxc/Support/Unicode.h"
#include <dxgiformat.h>
// If TAEF verify macros are available, use them to alias other legacy
// comparison macros that don't have a direct translation.
//
// Other common replacements are as follows.
//
// EXPECT_EQ -> VERIFY_ARE_EQUAL
// ASSERT_EQ -> VERIFY_ARE_EQUAL
//
// Note that whether verification throws or continues depends on
// preprocessor settings.
#ifdef VERIFY_ARE_EQUAL
#define EXPECT_STREQ(a, b) VERIFY_ARE_EQUAL(0, strcmp(a, b))
#define EXPECT_STREQW(a, b) VERIFY_ARE_EQUAL(0, wcscmp(a, b))
#define VERIFY_ARE_EQUAL_CMP(a, b, ...) VERIFY_IS_TRUE(a == b, __VA_ARGS__)
#define VERIFY_ARE_EQUAL_STR(a, b, ...) { \
const char *pTmpA = (a);\
const char *pTmpB = (b);\
if (0 != strcmp(pTmpA, pTmpB)) {\
CA2W conv(pTmpB, CP_UTF8); WEX::Logging::Log::Comment(conv);\
const char *pA = pTmpA; const char *pB = pTmpB; \
while(*pA == *pB) { pA++; pB++; } \
wchar_t diffMsg[32]; swprintf_s(diffMsg, _countof(diffMsg), L"diff at %u", (unsigned)(pA-pTmpA)); \
WEX::Logging::Log::Comment(diffMsg); \
} \
VERIFY_ARE_EQUAL(0, strcmp(pTmpA, pTmpB), __VA_ARGS__); \
}
#define VERIFY_ARE_EQUAL_WSTR(a, b, ...) { \
if (0 != wcscmp(a, b)) { WEX::Logging::Log::Comment(b);} \
VERIFY_ARE_EQUAL(0, wcscmp(a, b), __VA_ARGS__); \
}
#define ASSERT_EQ(expected, actual) VERIFY_ARE_EQUAL(expected, actual)
#define ASSERT_NE(expected, actual) VERIFY_ARE_NOT_EQUAL(expected, actual)
#define TEST_F(typeName, functionName) void typeName::functionName()
#define ASSERT_HRESULT_SUCCEEDED VERIFY_SUCCEEDED
#define EXPECT_EQ(expected, actual) VERIFY_ARE_EQUAL(expected, actual)
#endif
namespace hlsl_test {
inline std::wstring
vFormatToWString(_In_z_ _Printf_format_string_ const wchar_t *fmt, va_list argptr) {
std::wstring result;
int len = _vscwprintf(fmt, argptr);
result.resize(len + 1);
vswprintf_s((wchar_t *)result.data(), len + 1, fmt, argptr);
return result;
}
inline std::wstring
FormatToWString(_In_z_ _Printf_format_string_ const wchar_t *fmt, ...) {
va_list args;
va_start(args, fmt);
std::wstring result(vFormatToWString(fmt, args));
va_end(args);
return result;
}
inline void LogCommentFmt(_In_z_ _Printf_format_string_ const wchar_t *fmt, ...) {
va_list args;
va_start(args, fmt);
std::wstring buf(vFormatToWString(fmt, args));
va_end(args);
WEX::Logging::Log::Comment(buf.data());
}
inline void LogErrorFmt(_In_z_ _Printf_format_string_ const wchar_t *fmt, ...) {
va_list args;
va_start(args, fmt);
std::wstring buf(vFormatToWString(fmt, args));
va_end(args);
WEX::Logging::Log::Error(buf.data());
}
inline std::wstring GetPathToHlslDataFile(const wchar_t* relative) {
WEX::TestExecution::SetVerifyOutput verifySettings(WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
WEX::Common::String HlslDataDirValue;
ASSERT_HRESULT_SUCCEEDED(WEX::TestExecution::RuntimeParameters::TryGetValue(L"HlslDataDir", HlslDataDirValue));
wchar_t envPath[MAX_PATH];
wchar_t expanded[MAX_PATH];
swprintf_s(envPath, _countof(envPath), L"%s\\%s", reinterpret_cast<wchar_t*>(HlslDataDirValue.GetBuffer()), relative);
VERIFY_WIN32_BOOL_SUCCEEDED(ExpandEnvironmentStringsW(envPath, expanded, _countof(expanded)));
return std::wstring(expanded);
}
inline bool PathLooksAbsolute(LPCWSTR name) {
// Very simplified, only for the cases we care about in the test suite.
return name && *name && ((*name == L'\\') || (name[1] == L':'));
}
inline std::string GetFirstLine(LPCWSTR name) {
char firstLine[300];
memset(firstLine, 0, sizeof(firstLine));
const std::wstring path = PathLooksAbsolute(name)
? std::wstring(name)
: hlsl_test::GetPathToHlslDataFile(name);
std::ifstream infile(path);
if (infile.bad()) {
std::wstring errMsg(L"Unable to read file ");
errMsg += path;
WEX::Logging::Log::Error(errMsg.c_str());
VERIFY_FAIL();
}
infile.getline(firstLine, _countof(firstLine));
return firstLine;
}
inline HANDLE CreateFileForReading(LPCWSTR path) {
HANDLE sourceHandle = CreateFileW(path, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
if (sourceHandle == INVALID_HANDLE_VALUE) {
DWORD err = GetLastError();
std::wstring errorMessage(FormatToWString(L"Unable to open file '%s', err=%u", path, err).c_str());
VERIFY_SUCCEEDED(HRESULT_FROM_WIN32(err), errorMessage.c_str());
}
return sourceHandle;
}
inline HANDLE CreateNewFileForReadWrite(LPCWSTR path) {
HANDLE sourceHandle = CreateFileW(path, GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
if (sourceHandle == INVALID_HANDLE_VALUE) {
DWORD err = GetLastError();
std::wstring errorMessage(FormatToWString(L"Unable to create file '%s', err=%u", path, err).c_str());
VERIFY_SUCCEEDED(HRESULT_FROM_WIN32(err), errorMessage.c_str());
}
return sourceHandle;
}
inline bool GetTestParamBool(LPCWSTR name) {
WEX::Common::String ParamValue;
WEX::Common::String NameValue;
if (FAILED(WEX::TestExecution::RuntimeParameters::TryGetValue(name,
ParamValue))) {
return false;
}
if (ParamValue.IsEmpty()) {
return false;
}
if (0 == wcscmp(ParamValue, L"*")) {
return true;
}
VERIFY_SUCCEEDED(WEX::TestExecution::RuntimeParameters::TryGetValue(
L"TestName", NameValue));
if (NameValue.IsEmpty()) {
return false;
}
return Unicode::IsStarMatchUTF16(ParamValue, ParamValue.GetLength(),
NameValue, NameValue.GetLength());
}
inline bool GetTestParamUseWARP(bool defaultVal) {
WEX::Common::String AdapterValue;
if (FAILED(WEX::TestExecution::RuntimeParameters::TryGetValue(
L"Adapter", AdapterValue))) {
return defaultVal;
}
if (defaultVal && AdapterValue.IsEmpty() ||
AdapterValue.CompareNoCase(L"WARP") == 0) {
return true;
}
return false;
}
}
inline bool isdenorm(float f) {
return FP_SUBNORMAL == fpclassify(f);
}
inline bool isdenorm(double d) {
return FP_SUBNORMAL == fpclassify(d);
}
inline float ifdenorm_flushf(float a) {
return isdenorm(a) ? copysign(0.0f, a) : a;
}
inline bool ifdenorm_flushf_eq(float a, float b) {
return ifdenorm_flushf(a) == ifdenorm_flushf(b);
}
inline bool ifdenorm_flushf_eq_or_nans(float a, float b) {
if (isnan(a) && isnan(b)) return true;
return ifdenorm_flushf(a) == ifdenorm_flushf(b);
}
inline bool CompareFloatULP(const float &fsrc, const float &fref, int ULPTolerance) {
if (isnan(fsrc)) {
return isnan(fref);
}
if (isdenorm(fref)) { // Arithmetic operations of denorm may flush to sign-preserved zero
return (isdenorm(fsrc) || fsrc == 0) && (signbit(fsrc) == signbit(fref));
}
if (fsrc == fref) {
return true;
}
int diff = *((DWORD *)&fsrc) - *((DWORD *)&fref);
unsigned int uDiff = diff < 0 ? -diff : diff;
return uDiff <= (unsigned int)ULPTolerance;
}
inline bool CompareFloatEpsilon(const float &fsrc, const float &fref, float epsilon) {
if (isnan(fsrc)) {
return isnan(fref);
}
if (isdenorm(fref)) { // Arithmetic operations of denorm may flush to sign-preserved zero
return (isdenorm(fsrc) || fsrc == 0) && (signbit(fsrc) == signbit(fref));
}
return fsrc == fref || fabsf(fsrc - fref) < epsilon;
}
// Compare using relative error (relative error < 2^{nRelativeExp})
inline bool CompareFloatRelativeEpsilon(const float &fsrc, const float &fref, int nRelativeExp) {
return CompareFloatULP(fsrc, fref, 23 - nRelativeExp);
}
// returns the number of bytes per pixel for a given dxgi format
// add more cases if different format needed to copy back resources
inline UINT GetByteSizeForFormat(DXGI_FORMAT value) {
switch (value) {
case DXGI_FORMAT_R32G32B32A32_TYPELESS: return 16;
case DXGI_FORMAT_R32G32B32A32_FLOAT: return 16;
case DXGI_FORMAT_R32G32B32A32_UINT: return 16;
case DXGI_FORMAT_R32G32B32A32_SINT: return 16;
case DXGI_FORMAT_R32G32B32_TYPELESS: return 12;
case DXGI_FORMAT_R32G32B32_FLOAT: return 12;
case DXGI_FORMAT_R32G32B32_UINT: return 12;
case DXGI_FORMAT_R32G32B32_SINT: return 12;
case DXGI_FORMAT_R16G16B16A16_TYPELESS: return 8;
case DXGI_FORMAT_R16G16B16A16_FLOAT: return 8;
case DXGI_FORMAT_R16G16B16A16_UNORM: return 8;
case DXGI_FORMAT_R16G16B16A16_UINT: return 8;
case DXGI_FORMAT_R16G16B16A16_SNORM: return 8;
case DXGI_FORMAT_R16G16B16A16_SINT: return 8;
case DXGI_FORMAT_R32G32_TYPELESS: return 8;
case DXGI_FORMAT_R32G32_FLOAT: return 8;
case DXGI_FORMAT_R32G32_UINT: return 8;
case DXGI_FORMAT_R32G32_SINT: return 8;
case DXGI_FORMAT_R32G8X24_TYPELESS: return 8;
case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: return 4;
case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: return 4;
case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: return 4;
case DXGI_FORMAT_R10G10B10A2_TYPELESS: return 4;
case DXGI_FORMAT_R10G10B10A2_UNORM: return 4;
case DXGI_FORMAT_R10G10B10A2_UINT: return 4;
case DXGI_FORMAT_R11G11B10_FLOAT: return 4;
case DXGI_FORMAT_R8G8B8A8_TYPELESS: return 4;
case DXGI_FORMAT_R8G8B8A8_UNORM: return 4;
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: return 4;
case DXGI_FORMAT_R8G8B8A8_UINT: return 4;
case DXGI_FORMAT_R8G8B8A8_SNORM: return 4;
case DXGI_FORMAT_R8G8B8A8_SINT: return 4;
case DXGI_FORMAT_R16G16_TYPELESS: return 4;
case DXGI_FORMAT_R16G16_FLOAT: return 4;
case DXGI_FORMAT_R16G16_UNORM: return 4;
case DXGI_FORMAT_R16G16_UINT: return 4;
case DXGI_FORMAT_R16G16_SNORM: return 4;
case DXGI_FORMAT_R16G16_SINT: return 4;
case DXGI_FORMAT_R32_TYPELESS: return 4;
case DXGI_FORMAT_D32_FLOAT: return 4;
case DXGI_FORMAT_R32_FLOAT: return 4;
case DXGI_FORMAT_R32_UINT: return 4;
case DXGI_FORMAT_R32_SINT: return 4;
case DXGI_FORMAT_R24G8_TYPELESS: return 4;
case DXGI_FORMAT_D24_UNORM_S8_UINT: return 4;
case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: return 4;
case DXGI_FORMAT_X24_TYPELESS_G8_UINT: return 4;
case DXGI_FORMAT_R8G8_TYPELESS: return 2;
case DXGI_FORMAT_R8G8_UNORM: return 2;
case DXGI_FORMAT_R8G8_UINT: return 2;
case DXGI_FORMAT_R8G8_SNORM: return 2;
case DXGI_FORMAT_R8G8_SINT: return 2;
case DXGI_FORMAT_R16_TYPELESS: return 2;
case DXGI_FORMAT_R16_FLOAT: return 2;
case DXGI_FORMAT_D16_UNORM: return 2;
case DXGI_FORMAT_R16_UNORM: return 2;
case DXGI_FORMAT_R16_UINT: return 2;
case DXGI_FORMAT_R16_SNORM: return 2;
case DXGI_FORMAT_R16_SINT: return 2;
case DXGI_FORMAT_R8_TYPELESS: return 1;
case DXGI_FORMAT_R8_UNORM: return 1;
case DXGI_FORMAT_R8_UINT: return 1;
case DXGI_FORMAT_R8_SNORM: return 1;
case DXGI_FORMAT_R8_SINT: return 1;
case DXGI_FORMAT_A8_UNORM: return 1;
case DXGI_FORMAT_R1_UNORM: return 1;
default:
VERIFY_FAILED(E_INVALIDARG);
return 0;
}
}
#define SIMPLE_IUNKNOWN_IMPL1(_IFACE_) \
private: volatile ULONG m_dwRef; \
public:\
ULONG STDMETHODCALLTYPE AddRef() { return InterlockedIncrement(&m_dwRef); } \
ULONG STDMETHODCALLTYPE Release() { \
ULONG result = InterlockedDecrement(&m_dwRef); \
if (result == 0) delete this; \
return result; \
} \
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void** ppvObject) { \
if (ppvObject == nullptr) return E_POINTER; \
if (IsEqualIID(iid, __uuidof(IUnknown)) || \
IsEqualIID(iid, __uuidof(INoMarshal)) || \
IsEqualIID(iid, __uuidof(_IFACE_))) { \
*ppvObject = reinterpret_cast<_IFACE_*>(this); \
reinterpret_cast<_IFACE_*>(this)->AddRef(); \
return S_OK; \
} \
return E_NOINTERFACE; \
}
///////////////////////////////////////////////////////////////////////////////
// //
// HlslTestUtils.h //
// Copyright (C) Microsoft Corporation. All rights reserved. //
// This file is distributed under the University of Illinois Open Source //
// License. See LICENSE.TXT for details. //
// //
// Provides utility functions for HLSL tests. //
// //
///////////////////////////////////////////////////////////////////////////////
#include <string>
#include <sstream>
#include <fstream>
#include "dxc/Support/Unicode.h"
#include <dxgiformat.h>
// If TAEF verify macros are available, use them to alias other legacy
// comparison macros that don't have a direct translation.
//
// Other common replacements are as follows.
//
// EXPECT_EQ -> VERIFY_ARE_EQUAL
// ASSERT_EQ -> VERIFY_ARE_EQUAL
//
// Note that whether verification throws or continues depends on
// preprocessor settings.
#ifdef VERIFY_ARE_EQUAL
#define EXPECT_STREQ(a, b) VERIFY_ARE_EQUAL(0, strcmp(a, b))
#define EXPECT_STREQW(a, b) VERIFY_ARE_EQUAL(0, wcscmp(a, b))
#define VERIFY_ARE_EQUAL_CMP(a, b, ...) VERIFY_IS_TRUE(a == b, __VA_ARGS__)
#define VERIFY_ARE_EQUAL_STR(a, b, ...) { \
const char *pTmpA = (a);\
const char *pTmpB = (b);\
if (0 != strcmp(pTmpA, pTmpB)) {\
CA2W conv(pTmpB, CP_UTF8); WEX::Logging::Log::Comment(conv);\
const char *pA = pTmpA; const char *pB = pTmpB; \
while(*pA == *pB) { pA++; pB++; } \
wchar_t diffMsg[32]; swprintf_s(diffMsg, _countof(diffMsg), L"diff at %u", (unsigned)(pA-pTmpA)); \
WEX::Logging::Log::Comment(diffMsg); \
} \
VERIFY_ARE_EQUAL(0, strcmp(pTmpA, pTmpB), __VA_ARGS__); \
}
#define VERIFY_ARE_EQUAL_WSTR(a, b, ...) { \
if (0 != wcscmp(a, b)) { WEX::Logging::Log::Comment(b);} \
VERIFY_ARE_EQUAL(0, wcscmp(a, b), __VA_ARGS__); \
}
#define ASSERT_EQ(expected, actual) VERIFY_ARE_EQUAL(expected, actual)
#define ASSERT_NE(expected, actual) VERIFY_ARE_NOT_EQUAL(expected, actual)
#define TEST_F(typeName, functionName) void typeName::functionName()
#define ASSERT_HRESULT_SUCCEEDED VERIFY_SUCCEEDED
#define EXPECT_EQ(expected, actual) VERIFY_ARE_EQUAL(expected, actual)
#endif
namespace hlsl_test {
inline std::wstring
vFormatToWString(_In_z_ _Printf_format_string_ const wchar_t *fmt, va_list argptr) {
std::wstring result;
int len = _vscwprintf(fmt, argptr);
result.resize(len + 1);
vswprintf_s((wchar_t *)result.data(), len + 1, fmt, argptr);
return result;
}
inline std::wstring
FormatToWString(_In_z_ _Printf_format_string_ const wchar_t *fmt, ...) {
va_list args;
va_start(args, fmt);
std::wstring result(vFormatToWString(fmt, args));
va_end(args);
return result;
}
inline void LogCommentFmt(_In_z_ _Printf_format_string_ const wchar_t *fmt, ...) {
va_list args;
va_start(args, fmt);
std::wstring buf(vFormatToWString(fmt, args));
va_end(args);
WEX::Logging::Log::Comment(buf.data());
}
inline void LogErrorFmt(_In_z_ _Printf_format_string_ const wchar_t *fmt, ...) {
va_list args;
va_start(args, fmt);
std::wstring buf(vFormatToWString(fmt, args));
va_end(args);
WEX::Logging::Log::Error(buf.data());
}
inline std::wstring GetPathToHlslDataFile(const wchar_t* relative) {
WEX::TestExecution::SetVerifyOutput verifySettings(WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
WEX::Common::String HlslDataDirValue;
ASSERT_HRESULT_SUCCEEDED(WEX::TestExecution::RuntimeParameters::TryGetValue(L"HlslDataDir", HlslDataDirValue));
wchar_t envPath[MAX_PATH];
wchar_t expanded[MAX_PATH];
swprintf_s(envPath, _countof(envPath), L"%s\\%s", reinterpret_cast<wchar_t*>(HlslDataDirValue.GetBuffer()), relative);
VERIFY_WIN32_BOOL_SUCCEEDED(ExpandEnvironmentStringsW(envPath, expanded, _countof(expanded)));
return std::wstring(expanded);
}
inline bool PathLooksAbsolute(LPCWSTR name) {
// Very simplified, only for the cases we care about in the test suite.
return name && *name && ((*name == L'\\') || (name[1] == L':'));
}
inline std::string GetFirstLine(LPCWSTR name) {
char firstLine[300];
memset(firstLine, 0, sizeof(firstLine));
const std::wstring path = PathLooksAbsolute(name)
? std::wstring(name)
: hlsl_test::GetPathToHlslDataFile(name);
std::ifstream infile(path);
if (infile.bad()) {
std::wstring errMsg(L"Unable to read file ");
errMsg += path;
WEX::Logging::Log::Error(errMsg.c_str());
VERIFY_FAIL();
}
infile.getline(firstLine, _countof(firstLine));
return firstLine;
}
inline HANDLE CreateFileForReading(LPCWSTR path) {
HANDLE sourceHandle = CreateFileW(path, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
if (sourceHandle == INVALID_HANDLE_VALUE) {
DWORD err = GetLastError();
std::wstring errorMessage(FormatToWString(L"Unable to open file '%s', err=%u", path, err).c_str());
VERIFY_SUCCEEDED(HRESULT_FROM_WIN32(err), errorMessage.c_str());
}
return sourceHandle;
}
inline HANDLE CreateNewFileForReadWrite(LPCWSTR path) {
HANDLE sourceHandle = CreateFileW(path, GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
if (sourceHandle == INVALID_HANDLE_VALUE) {
DWORD err = GetLastError();
std::wstring errorMessage(FormatToWString(L"Unable to create file '%s', err=%u", path, err).c_str());
VERIFY_SUCCEEDED(HRESULT_FROM_WIN32(err), errorMessage.c_str());
}
return sourceHandle;
}
inline bool GetTestParamBool(LPCWSTR name) {
WEX::Common::String ParamValue;
WEX::Common::String NameValue;
if (FAILED(WEX::TestExecution::RuntimeParameters::TryGetValue(name,
ParamValue))) {
return false;
}
if (ParamValue.IsEmpty()) {
return false;
}
if (0 == wcscmp(ParamValue, L"*")) {
return true;
}
VERIFY_SUCCEEDED(WEX::TestExecution::RuntimeParameters::TryGetValue(
L"TestName", NameValue));
if (NameValue.IsEmpty()) {
return false;
}
return Unicode::IsStarMatchUTF16(ParamValue, ParamValue.GetLength(),
NameValue, NameValue.GetLength());
}
inline bool GetTestParamUseWARP(bool defaultVal) {
WEX::Common::String AdapterValue;
if (FAILED(WEX::TestExecution::RuntimeParameters::TryGetValue(
L"Adapter", AdapterValue))) {
return defaultVal;
}
if (defaultVal && AdapterValue.IsEmpty() ||
AdapterValue.CompareNoCase(L"WARP") == 0) {
return true;
}
return false;
}
}
inline bool isdenorm(float f) {
return FP_SUBNORMAL == fpclassify(f);
}
inline bool isdenorm(double d) {
return FP_SUBNORMAL == fpclassify(d);
}
inline float ifdenorm_flushf(float a) {
return isdenorm(a) ? copysign(0.0f, a) : a;
}
inline bool ifdenorm_flushf_eq(float a, float b) {
return ifdenorm_flushf(a) == ifdenorm_flushf(b);
}
inline bool ifdenorm_flushf_eq_or_nans(float a, float b) {
if (isnan(a) && isnan(b)) return true;
return ifdenorm_flushf(a) == ifdenorm_flushf(b);
}
inline bool CompareFloatULP(const float &fsrc, const float &fref, int ULPTolerance) {
if (isnan(fsrc)) {
return isnan(fref);
}
if (isdenorm(fref)) { // Arithmetic operations of denorm may flush to sign-preserved zero
return (isdenorm(fsrc) || fsrc == 0) && (signbit(fsrc) == signbit(fref));
}
if (fsrc == fref) {
return true;
}
int diff = *((DWORD *)&fsrc) - *((DWORD *)&fref);
unsigned int uDiff = diff < 0 ? -diff : diff;
return uDiff <= (unsigned int)ULPTolerance;
}
inline bool CompareFloatEpsilon(const float &fsrc, const float &fref, float epsilon) {
if (isnan(fsrc)) {
return isnan(fref);
}
if (isdenorm(fref)) { // Arithmetic operations of denorm may flush to sign-preserved zero
return (isdenorm(fsrc) || fsrc == 0) && (signbit(fsrc) == signbit(fref));
}
return fsrc == fref || fabsf(fsrc - fref) < epsilon;
}
// Compare using relative error (relative error < 2^{nRelativeExp})
inline bool CompareFloatRelativeEpsilon(const float &fsrc, const float &fref, int nRelativeExp) {
return CompareFloatULP(fsrc, fref, 23 - nRelativeExp);
}
// returns the number of bytes per pixel for a given dxgi format
// add more cases if different format needed to copy back resources
inline UINT GetByteSizeForFormat(DXGI_FORMAT value) {
switch (value) {
case DXGI_FORMAT_R32G32B32A32_TYPELESS: return 16;
case DXGI_FORMAT_R32G32B32A32_FLOAT: return 16;
case DXGI_FORMAT_R32G32B32A32_UINT: return 16;
case DXGI_FORMAT_R32G32B32A32_SINT: return 16;
case DXGI_FORMAT_R32G32B32_TYPELESS: return 12;
case DXGI_FORMAT_R32G32B32_FLOAT: return 12;
case DXGI_FORMAT_R32G32B32_UINT: return 12;
case DXGI_FORMAT_R32G32B32_SINT: return 12;
case DXGI_FORMAT_R16G16B16A16_TYPELESS: return 8;
case DXGI_FORMAT_R16G16B16A16_FLOAT: return 8;
case DXGI_FORMAT_R16G16B16A16_UNORM: return 8;
case DXGI_FORMAT_R16G16B16A16_UINT: return 8;
case DXGI_FORMAT_R16G16B16A16_SNORM: return 8;
case DXGI_FORMAT_R16G16B16A16_SINT: return 8;
case DXGI_FORMAT_R32G32_TYPELESS: return 8;
case DXGI_FORMAT_R32G32_FLOAT: return 8;
case DXGI_FORMAT_R32G32_UINT: return 8;
case DXGI_FORMAT_R32G32_SINT: return 8;
case DXGI_FORMAT_R32G8X24_TYPELESS: return 8;
case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: return 4;
case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: return 4;
case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: return 4;
case DXGI_FORMAT_R10G10B10A2_TYPELESS: return 4;
case DXGI_FORMAT_R10G10B10A2_UNORM: return 4;
case DXGI_FORMAT_R10G10B10A2_UINT: return 4;
case DXGI_FORMAT_R11G11B10_FLOAT: return 4;
case DXGI_FORMAT_R8G8B8A8_TYPELESS: return 4;
case DXGI_FORMAT_R8G8B8A8_UNORM: return 4;
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: return 4;
case DXGI_FORMAT_R8G8B8A8_UINT: return 4;
case DXGI_FORMAT_R8G8B8A8_SNORM: return 4;
case DXGI_FORMAT_R8G8B8A8_SINT: return 4;
case DXGI_FORMAT_R16G16_TYPELESS: return 4;
case DXGI_FORMAT_R16G16_FLOAT: return 4;
case DXGI_FORMAT_R16G16_UNORM: return 4;
case DXGI_FORMAT_R16G16_UINT: return 4;
case DXGI_FORMAT_R16G16_SNORM: return 4;
case DXGI_FORMAT_R16G16_SINT: return 4;
case DXGI_FORMAT_R32_TYPELESS: return 4;
case DXGI_FORMAT_D32_FLOAT: return 4;
case DXGI_FORMAT_R32_FLOAT: return 4;
case DXGI_FORMAT_R32_UINT: return 4;
case DXGI_FORMAT_R32_SINT: return 4;
case DXGI_FORMAT_R24G8_TYPELESS: return 4;
case DXGI_FORMAT_D24_UNORM_S8_UINT: return 4;
case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: return 4;
case DXGI_FORMAT_X24_TYPELESS_G8_UINT: return 4;
case DXGI_FORMAT_R8G8_TYPELESS: return 2;
case DXGI_FORMAT_R8G8_UNORM: return 2;
case DXGI_FORMAT_R8G8_UINT: return 2;
case DXGI_FORMAT_R8G8_SNORM: return 2;
case DXGI_FORMAT_R8G8_SINT: return 2;
case DXGI_FORMAT_R16_TYPELESS: return 2;
case DXGI_FORMAT_R16_FLOAT: return 2;
case DXGI_FORMAT_D16_UNORM: return 2;
case DXGI_FORMAT_R16_UNORM: return 2;
case DXGI_FORMAT_R16_UINT: return 2;
case DXGI_FORMAT_R16_SNORM: return 2;
case DXGI_FORMAT_R16_SINT: return 2;
case DXGI_FORMAT_R8_TYPELESS: return 1;
case DXGI_FORMAT_R8_UNORM: return 1;
case DXGI_FORMAT_R8_UINT: return 1;
case DXGI_FORMAT_R8_SNORM: return 1;
case DXGI_FORMAT_R8_SINT: return 1;
case DXGI_FORMAT_A8_UNORM: return 1;
case DXGI_FORMAT_R1_UNORM: return 1;
default:
VERIFY_FAILED(E_INVALIDARG);
return 0;
}
}
#define SIMPLE_IUNKNOWN_IMPL1(_IFACE_) \
private: volatile ULONG m_dwRef; \
public:\
ULONG STDMETHODCALLTYPE AddRef() { return InterlockedIncrement(&m_dwRef); } \
ULONG STDMETHODCALLTYPE Release() { \
ULONG result = InterlockedDecrement(&m_dwRef); \
if (result == 0) delete this; \
return result; \
} \
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void** ppvObject) { \
if (ppvObject == nullptr) return E_POINTER; \
if (IsEqualIID(iid, __uuidof(IUnknown)) || \
IsEqualIID(iid, __uuidof(INoMarshal)) || \
IsEqualIID(iid, __uuidof(_IFACE_))) { \
*ppvObject = reinterpret_cast<_IFACE_*>(this); \
reinterpret_cast<_IFACE_*>(this)->AddRef(); \
return S_OK; \
} \
return E_NOINTERFACE; \
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,3 +1,3 @@
#include <windows.h>
#include <windows.h>
ShaderOpArithTable.xml DATASOURCE_XML "ShaderOpArithTable.xml"