mirror of
https://github.com/KhronosGroup/SPIRV-Cross.git
synced 2024-11-09 22:00:05 +00:00
MSVC maintenance.
This commit is contained in:
parent
b50513c03a
commit
ce3fe29557
@ -88,10 +88,12 @@ target_compile_definitions(spirv-cross PRIVATE ${spirv-compiler-defines})
|
||||
# - Get cycle counts from malisc
|
||||
# - Keep failing outputs
|
||||
find_package(PythonInterp)
|
||||
if(${PYTHONINTERP_FOUND} AND ${PYTHON_VERSION_MAJOR} GREATER 2)
|
||||
add_test(NAME spirv-cross-test
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders)
|
||||
if (${PYTHONINTERP_FOUND})
|
||||
if (${PYTHON_VERSION_MAJOR} GREATER 2)
|
||||
add_test(NAME spirv-cross-test
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders)
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "Testing disabled. Could not find python3. If you have python3 installed try running "
|
||||
"cmake with -DPYTHON_EXECUTABLE:FILEPATH=/path/to/python3 to help it find the executable")
|
||||
|
4
main.cpp
4
main.cpp
@ -26,6 +26,10 @@
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4996)
|
||||
#endif
|
||||
|
||||
using namespace spv;
|
||||
using namespace spirv_cross;
|
||||
using namespace std;
|
||||
|
@ -103,6 +103,11 @@ inline std::string convert_to_string(T &&t)
|
||||
#define SPIRV_CROSS_FLT_FMT "%.32g"
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4996)
|
||||
#endif
|
||||
|
||||
inline std::string convert_to_string(float t)
|
||||
{
|
||||
// std::to_string for floating point values is broken.
|
||||
@ -127,6 +132,10 @@ inline std::string convert_to_string(double t)
|
||||
return buf;
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
struct Instruction
|
||||
{
|
||||
Instruction(const std::vector<uint32_t> &spirv, uint32_t &index);
|
||||
|
@ -2907,14 +2907,14 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry)
|
||||
{
|
||||
DominatorBuilder builder(cfg);
|
||||
auto &blocks = var.second;
|
||||
auto &type = expression_type(var.first);
|
||||
auto &type = this->expression_type(var.first);
|
||||
|
||||
// Figure out which block is dominating all accesses of those variables.
|
||||
for (auto &block : blocks)
|
||||
{
|
||||
// If we're accessing a variable inside a continue block, this variable might be a loop variable.
|
||||
// We can only use loop variables with scalars, as we cannot track static expressions for vectors.
|
||||
if (is_continue(block) && type.vecsize == 1 && type.columns == 1)
|
||||
if (this->is_continue(block) && type.vecsize == 1 && type.columns == 1)
|
||||
{
|
||||
// The variable is used in multiple continue blocks, this is not a loop
|
||||
// candidate, signal that by setting block to -1u.
|
||||
@ -2938,14 +2938,14 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry)
|
||||
{
|
||||
auto &block = this->get<SPIRBlock>(dominating_block);
|
||||
block.dominated_variables.push_back(var.first);
|
||||
get<SPIRVariable>(var.first).dominator = dominating_block;
|
||||
this->get<SPIRVariable>(var.first).dominator = dominating_block;
|
||||
}
|
||||
}
|
||||
|
||||
// Now, try to analyze whether or not these variables are actually loop variables.
|
||||
for (auto &loop_variable : potential_loop_variables)
|
||||
{
|
||||
auto &var = get<SPIRVariable>(loop_variable.first);
|
||||
auto &var = this->get<SPIRVariable>(loop_variable.first);
|
||||
auto dominator = var.dominator;
|
||||
auto block = loop_variable.second;
|
||||
|
||||
@ -2960,9 +2960,9 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry)
|
||||
uint32_t header = 0;
|
||||
|
||||
// Find the loop header for this block.
|
||||
for (auto b : loop_blocks)
|
||||
for (auto b : this->loop_blocks)
|
||||
{
|
||||
auto &potential_header = get<SPIRBlock>(b);
|
||||
auto &potential_header = this->get<SPIRBlock>(b);
|
||||
if (potential_header.continue_block == block)
|
||||
{
|
||||
header = b;
|
||||
@ -2971,7 +2971,7 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry)
|
||||
}
|
||||
|
||||
assert(header);
|
||||
auto &header_block = get<SPIRBlock>(header);
|
||||
auto &header_block = this->get<SPIRBlock>(header);
|
||||
|
||||
// Now, there are two conditions we need to meet for the variable to be a loop variable.
|
||||
// 1. The dominating block must have a branch-free path to the loop header,
|
||||
@ -3019,6 +3019,6 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry)
|
||||
// Need to sort here as variables come from an unordered container, and pushing stuff in wrong order
|
||||
// will break reproducability in regression runs.
|
||||
sort(begin(header_block.loop_variables), end(header_block.loop_variables));
|
||||
get<SPIRVariable>(loop_variable.first).loop_variable = true;
|
||||
this->get<SPIRVariable>(loop_variable.first).loop_variable = true;
|
||||
}
|
||||
}
|
||||
|
@ -2549,8 +2549,8 @@ void CompilerGLSL::emit_texture_op(const Instruction &i)
|
||||
|
||||
string expr;
|
||||
bool forward = false;
|
||||
expr += to_function_name(img, imgtype, fetch, gather, proj, coffsets, (coffset || offset), (grad_x || grad_y), lod,
|
||||
dref);
|
||||
expr += to_function_name(img, imgtype, !!fetch, !!gather, !!proj, !!coffsets, (!!coffset || !!offset), (!!grad_x || !!grad_y), !!lod,
|
||||
!!dref);
|
||||
expr += "(";
|
||||
expr += to_function_args(img, imgtype, fetch, gather, proj, coord, coord_components, dref, grad_x, grad_y, lod,
|
||||
coffset, offset, bias, comp, sample, &forward);
|
||||
|
Loading…
Reference in New Issue
Block a user