Commit 68237fe5 authored by Jordi Mallach's avatar Jordi Mallach 🐗

Merge tag 'upstream/0.185'

Upstream version 0.185
parents ff3c5b17 a32c1b65

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

......@@ -3045,10 +3045,12 @@ process_initializer(ir_variable *var, ast_declaration *decl,
/* Propagate precision qualifier for constant value */
if (type->qualifier.flags.q.constant) {
ir_constant *constant_value = rhs->constant_expression_value();
constant_value->set_precision((glsl_precision)type->qualifier.precision);
if (constant_value->type->is_array()) {
for (unsigned i = 0; i < constant_value->type->length; i++) {
constant_value->get_array_element(i)->set_precision((glsl_precision)type->qualifier.precision);
if (NULL != constant_value) {
constant_value->set_precision((glsl_precision)type->qualifier.precision);
if (constant_value->type->is_array()) {
for (unsigned i = 0; i < constant_value->type->length; i++) {
constant_value->get_array_element(i)->set_precision((glsl_precision)type->qualifier.precision);
}
}
}
}
......
......@@ -280,6 +280,14 @@ static void propagate_precision_texture(ir_instruction *ir, void *data)
((precision_ctx*)data)->res = true;
}
static void propagate_precision_texture_metal(ir_instruction* ir, void* data)
{
// There are no precision specifiers in Metal
ir_texture* tex = ir->as_texture();
if (tex)
tex->set_precision(glsl_precision_undefined);
}
struct undefined_ass_ctx
{
ir_variable* var;
......@@ -386,7 +394,7 @@ static void propagate_precision_call(ir_instruction *ir, void *data)
}
}
static bool propagate_precision(exec_list* list, bool assign_high_to_undefined)
static bool propagate_precision(exec_list* list, bool metal_target)
{
bool anyProgress = false;
precision_ctx ctx;
......@@ -396,7 +404,11 @@ static bool propagate_precision(exec_list* list, bool assign_high_to_undefined)
ctx.root_ir = list;
foreach_in_list(ir_instruction, ir, list)
{
visit_tree (ir, propagate_precision_texture, &ctx);
if (metal_target)
visit_tree (ir, propagate_precision_texture_metal, &ctx);
else
visit_tree (ir, propagate_precision_texture, &ctx);
visit_tree (ir, propagate_precision_deref, &ctx);
bool hadProgress = ctx.res;
ctx.res = false;
......@@ -417,7 +429,7 @@ static bool propagate_precision(exec_list* list, bool assign_high_to_undefined)
anyProgress |= ctx.res;
// for globals that have undefined precision, set it to highp
if (assign_high_to_undefined)
if (metal_target)
{
foreach_in_list(ir_instruction, ir, list)
{
......
......@@ -1282,6 +1282,12 @@ void ir_print_metal_visitor::visit(ir_texture *ir)
sampler_uv_dim += 1;
const bool is_proj = (uv_dim > sampler_uv_dim) && !is_array;
// Construct as the expected return type of shadow2D as sample_compare returns a scalar
if (is_shadow)
{
buffer.asprintf_append("float4(");
}
// texture name & call to sample
ir->sampler->accept(this);
if (is_shadow)
......@@ -1345,6 +1351,12 @@ void ir_print_metal_visitor::visit(ir_texture *ir)
//@TODO: pixel offsets
buffer.asprintf_append (")");
// Close float4 cast
if (is_shadow)
{
buffer.asprintf_append(")");
}
}
......
......@@ -28,7 +28,9 @@ endif(ENABLE_HLSL)
if(WIN32)
set(CMAKE_DEBUG_POSTFIX "d")
include(ChooseMSVCCRT.cmake)
if(MSVC)
include(ChooseMSVCCRT.cmake)
endif(MSVC)
add_definitions(-DGLSLANG_OSINCLUDE_WIN32)
elseif(UNIX)
add_definitions(-fPIC)
......
......@@ -27,10 +27,17 @@
#ifndef GLSLextKHR_H
#define GLSLextKHR_H
// SPV_KHR_shader_ballot
static const char* const E_SPV_KHR_shader_ballot = "SPV_KHR_shader_ballot";
enum BuiltIn;
enum Op;
enum Capability;
static const int GLSLextKHRVersion = 100;
static const int GLSLextKHRRevision = 1;
static const char* const E_SPV_KHR_shader_ballot = "SPV_KHR_shader_ballot";
static const char* const E_SPV_KHR_subgroup_vote = "SPV_KHR_subgroup_vote";
static const char* const E_SPV_KHR_device_group = "SPV_KHR_device_group";
static const char* const E_SPV_KHR_multiview = "SPV_KHR_multiview";
static const char* const E_SPV_KHR_shader_draw_parameters = "SPV_KHR_shader_draw_parameters";
// SPV_KHR_shader_draw_parameters
static const char* const E_SPV_KHR_shader_draw_parameters = "SPV_KHR_shader_draw_parameters";
static const char* const E_SPV_KHR_subgroup_vote = "SPV_KHR_subgroup_vote";
#endif // #ifndef GLSLextKHR_H
/*
** Copyright (c) 2014-2016 The Khronos Group Inc.
** Copyright (c) 2014-2017 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and/or associated documentation files (the "Materials"),
......@@ -33,42 +33,22 @@ enum Op;
enum Capability;
static const int GLSLextNVVersion = 100;
static const int GLSLextNVRevision = 4;
static const int GLSLextNVRevision = 5;
//SPV_NV_sample_mask_override_coverage
const char* const E_SPV_NV_sample_mask_override_coverage = "SPV_NV_sample_mask_override_coverage";
static const Decoration DecorationOverrideCoverageNV = static_cast<Decoration>(5248);
//SPV_NV_geometry_shader_passthrough
const char* const E_SPV_NV_geometry_shader_passthrough = "SPV_NV_geometry_shader_passthrough";
static const Decoration DecorationPassthroughNV = static_cast<Decoration>(5250);
static const Capability CapabilityGeometryShaderPassthroughNV = static_cast<Capability>(5251);
//SPV_NV_viewport_array2
const char* const E_SPV_NV_viewport_array2 = "SPV_NV_viewport_array2";
const char* const E_ARB_shader_viewport_layer_array = "SPV_ARB_shader_viewport_layer_array";
static const Decoration DecorationViewportRelativeNV = static_cast<Decoration>(5252);
static const BuiltIn BuiltInViewportMaskNV = static_cast<BuiltIn>(5253);
static const Capability CapabilityShaderViewportIndexLayerNV = static_cast<Capability>(5254);
static const Capability CapabilityShaderViewportMaskNV = static_cast<Capability>(5255);
//SPV_NV_stereo_view_rendering
const char* const E_SPV_NV_stereo_view_rendering = "SPV_NV_stereo_view_rendering";
static const Decoration DecorationSecondaryViewportRelativeNV = static_cast<Decoration>(5256);
static const BuiltIn BuiltInSecondaryPositionNV = static_cast<BuiltIn>(5257);
static const BuiltIn BuiltInSecondaryViewportMaskNV = static_cast<BuiltIn>(5258);
static const Capability CapabilityShaderStereoViewNV = static_cast<Capability>(5259);
//SPV_NVX_multiview_per_view_attributes
const char* const E_SPV_NVX_multiview_per_view_attributes = "SPV_NVX_multiview_per_view_attributes";
#endif // #ifndef GLSLextNV_H
\ No newline at end of file
......@@ -49,6 +49,6 @@ void GetSpirvVersion(std::string&);
void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv);
void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv, spv::SpvBuildLogger* logger);
void OutputSpvBin(const std::vector<unsigned int>& spirv, const char* baseName);
void OutputSpvHex(const std::vector<unsigned int>& spirv, const char* baseName);
void OutputSpvHex(const std::vector<unsigned int>& spirv, const char* baseName, const char* varName);
}
......@@ -1125,7 +1125,8 @@ Id Builder::createAccessChain(StorageClass storageClass, Id base, const std::vec
Id Builder::createArrayLength(Id base, unsigned int member)
{
Instruction* length = new Instruction(getUniqueId(), makeIntType(32), OpArrayLength);
spv::Id intType = makeIntType(32);
Instruction* length = new Instruction(getUniqueId(), intType, OpArrayLength);
length->addIdOperand(base);
length->addImmediateOperand(member);
buildPoint->addInstruction(std::unique_ptr<Instruction>(length));
......@@ -1661,7 +1662,7 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse,
}
// Comments in header
Id Builder::createTextureQueryCall(Op opCode, const TextureParameters& parameters)
Id Builder::createTextureQueryCall(Op opCode, const TextureParameters& parameters, bool isUnsignedResult)
{
// All these need a capability
addCapability(CapabilityImageQuery);
......@@ -1694,10 +1695,12 @@ Id Builder::createTextureQueryCall(Op opCode, const TextureParameters& parameter
}
if (isArrayedImageType(getImageType(parameters.sampler)))
++numComponents;
Id intType = isUnsignedResult ? makeUintType(32) : makeIntType(32);
if (numComponents == 1)
resultType = makeIntType(32);
resultType = intType;