Procházet zdrojové kódy

Merge branch 'master' of github.com:bkaradzic/bgfx

Branimir Karadžić před 7 roky
rodič
revize
3e6ddd1be7

+ 2 - 2
3rdparty/dear-imgui/imgui.cpp

@@ -8734,7 +8734,7 @@ static void SettingsHandlerWindow_WriteAll(ImGuiContext* imgui_ctx, ImGuiSetting
 // [SECTION] PLATFORM DEPENDENT HELPERS
 //-----------------------------------------------------------------------------
 
-#if defined(_WIN32) && !defined(_WINDOWS_) && (!defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS) || !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS))
+#if defined(_WIN32) && !defined(_WINDOWS_) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && (!defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS) || !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS))
 #ifndef WIN32_LEAN_AND_MEAN
 #define WIN32_LEAN_AND_MEAN
 #endif
@@ -8746,7 +8746,7 @@ static void SettingsHandlerWindow_WriteAll(ImGuiContext* imgui_ctx, ImGuiSetting
 #endif
 
 // Win32 API clipboard implementation
-#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS)
+#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS)
 
 #ifdef _MSC_VER
 #pragma comment(lib, "user32")

+ 9 - 2
3rdparty/dear-imgui/imgui_internal.h

@@ -63,6 +63,7 @@ typedef int ImGuiNavDirSourceFlags; // -> enum ImGuiNavDirSourceFlags_ // Flags:
 typedef int ImGuiNavMoveFlags;      // -> enum ImGuiNavMoveFlags_      // Flags: for navigation requests
 typedef int ImGuiSeparatorFlags;    // -> enum ImGuiSeparatorFlags_    // Flags: for Separator() - internal
 typedef int ImGuiSliderFlags;       // -> enum ImGuiSliderFlags_       // Flags: for SliderBehavior()
+typedef int ImGuiDragFlags;         // -> enum ImGuiDragFlags_         // Flags: for DragBehavior()
 
 //-------------------------------------------------------------------------
 // STB libraries
@@ -249,6 +250,12 @@ enum ImGuiSliderFlags_
     ImGuiSliderFlags_Vertical               = 1 << 0
 };
 
+enum ImGuiDragFlags_
+{
+    ImGuiDragFlags_None                     = 0,
+    ImGuiDragFlags_Vertical                 = 1 << 0
+};
+
 enum ImGuiColumnsFlags_
 {
     // Default: 0
@@ -1246,7 +1253,7 @@ namespace ImGui
 
     // Widgets low-level behaviors
     IMGUI_API bool          ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0);
-    IMGUI_API bool          DragBehavior(ImGuiID id, ImGuiDataType data_type, void* v, float v_speed, const void* v_min, const void* v_max, const char* format, float power);
+    IMGUI_API bool          DragBehavior(ImGuiID id, ImGuiDataType data_type, void* v, float v_speed, const void* v_min, const void* v_max, const char* format, float power, ImGuiDragFlags flags);
     IMGUI_API bool          SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb);
     IMGUI_API bool          SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* size1, float* size2, float min_size1, float min_size2, float hover_extend = 0.0f, float hover_visibility_delay = 0.0f);
     IMGUI_API bool          TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL);
@@ -1256,7 +1263,7 @@ namespace ImGui
     // Template functions are instantiated in imgui_widgets.cpp for a finite number of types. 
     // To use them externally (for custom widget) you may need an "extern template" statement in your code in order to link to existing instances and silence Clang warnings (see #2036).
     // e.g. " extern template IMGUI_API float RoundScalarWithFormatT<float, float>(const char* format, ImGuiDataType data_type, float v); "
-    template<typename T, typename SIGNED_T, typename FLOAT_T>   IMGUI_API bool  DragBehaviorT(ImGuiDataType data_type, T* v, float v_speed, const T v_min, const T v_max, const char* format, float power);
+    template<typename T, typename SIGNED_T, typename FLOAT_T>   IMGUI_API bool  DragBehaviorT(ImGuiDataType data_type, T* v, float v_speed, const T v_min, const T v_max, const char* format, float power, ImGuiDragFlags flags);
     template<typename T, typename SIGNED_T, typename FLOAT_T>   IMGUI_API bool  SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, T* v, const T v_min, const T v_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb);
     template<typename T, typename FLOAT_T>                      IMGUI_API float SliderCalcRatioFromValueT(ImGuiDataType data_type, T v, T v_min, T v_max, float power, float linear_zero_pos);
     template<typename T, typename SIGNED_T>                     IMGUI_API T     RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, T v);

+ 25 - 20
3rdparty/dear-imgui/imgui_widgets.cpp

@@ -1706,9 +1706,10 @@ TYPE ImGui::RoundScalarWithFormatT(const char* format, ImGuiDataType data_type,
 
 // This is called by DragBehavior() when the widget is active (held by mouse or being manipulated with Nav controls)
 template<typename TYPE, typename SIGNEDTYPE, typename FLOATTYPE>
-bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const TYPE v_min, const TYPE v_max, const char* format, float power)
+bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const TYPE v_min, const TYPE v_max, const char* format, float power, ImGuiDragFlags flags)
 {
     ImGuiContext& g = *GImGui;
+    const ImGuiAxis axis = (flags & ImGuiDragFlags_Vertical) ? ImGuiAxis_Y : ImGuiAxis_X;
     const bool is_decimal = (data_type == ImGuiDataType_Float) || (data_type == ImGuiDataType_Double);
     const bool has_min_max = (v_min != v_max);
 
@@ -1720,7 +1721,7 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const
     float adjust_delta = 0.0f;
     if (g.ActiveIdSource == ImGuiInputSource_Mouse && IsMousePosValid() && g.IO.MouseDragMaxDistanceSqr[0] > 1.0f*1.0f)
     {
-        adjust_delta = g.IO.MouseDelta.x;
+        adjust_delta = g.IO.MouseDelta[axis];
         if (g.IO.KeyAlt)
             adjust_delta *= 1.0f / 100.0f;
         if (g.IO.KeyShift)
@@ -1729,11 +1730,15 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const
     else if (g.ActiveIdSource == ImGuiInputSource_Nav)
     {
         int decimal_precision = is_decimal ? ImParseFormatPrecision(format, 3) : 0;
-        adjust_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard | ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_RepeatFast, 1.0f / 10.0f, 10.0f).x;
+        adjust_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard | ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_RepeatFast, 1.0f / 10.0f, 10.0f)[axis];
         v_speed = ImMax(v_speed, GetMinimumStepAtDecimalPrecision(decimal_precision));
     }
     adjust_delta *= v_speed;
 
+    // For vertical drag we currently assume that Up=higher value (like we do with vertical sliders). This may become a parameter.
+    if (axis == ImGuiAxis_Y)
+        adjust_delta = -adjust_delta;
+
     // Clear current value on activation
     // Avoid altering values and clamping when we are _already_ past the limits and heading in the same direction, so e.g. if range is 0..255, current value is 300 and we are pushing to the right side, keep the 300.
     bool is_just_activated = g.ActiveIdIsJustActivated;
@@ -1804,7 +1809,7 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const
     return true;
 }
 
-bool ImGui::DragBehavior(ImGuiID id, ImGuiDataType data_type, void* v, float v_speed, const void* v_min, const void* v_max, const char* format, float power)
+bool ImGui::DragBehavior(ImGuiID id, ImGuiDataType data_type, void* v, float v_speed, const void* v_min, const void* v_max, const char* format, float power, ImGuiDragFlags flags)
 {
     ImGuiContext& g = *GImGui;
     if (g.ActiveId == id)
@@ -1819,12 +1824,12 @@ bool ImGui::DragBehavior(ImGuiID id, ImGuiDataType data_type, void* v, float v_s
 
     switch (data_type)
     {
-    case ImGuiDataType_S32:    return DragBehaviorT<ImS32, ImS32, float >(data_type, (ImS32*)v,  v_speed, v_min ? *(const ImS32* )v_min : IM_S32_MIN, v_max ? *(const ImS32* )v_max : IM_S32_MAX, format, power);
-    case ImGuiDataType_U32:    return DragBehaviorT<ImU32, ImS32, float >(data_type, (ImU32*)v,  v_speed, v_min ? *(const ImU32* )v_min : IM_U32_MIN, v_max ? *(const ImU32* )v_max : IM_U32_MAX, format, power);
-    case ImGuiDataType_S64:    return DragBehaviorT<ImS64, ImS64, double>(data_type, (ImS64*)v,  v_speed, v_min ? *(const ImS64* )v_min : IM_S64_MIN, v_max ? *(const ImS64* )v_max : IM_S64_MAX, format, power);
-    case ImGuiDataType_U64:    return DragBehaviorT<ImU64, ImS64, double>(data_type, (ImU64*)v,  v_speed, v_min ? *(const ImU64* )v_min : IM_U64_MIN, v_max ? *(const ImU64* )v_max : IM_U64_MAX, format, power);
-    case ImGuiDataType_Float:  return DragBehaviorT<float, float, float >(data_type, (float*)v,  v_speed, v_min ? *(const float* )v_min : -FLT_MAX,   v_max ? *(const float* )v_max : FLT_MAX,    format, power);
-    case ImGuiDataType_Double: return DragBehaviorT<double,double,double>(data_type, (double*)v, v_speed, v_min ? *(const double*)v_min : -DBL_MAX,   v_max ? *(const double*)v_max : DBL_MAX,    format, power);
+    case ImGuiDataType_S32:    return DragBehaviorT<ImS32, ImS32, float >(data_type, (ImS32*)v,  v_speed, v_min ? *(const ImS32* )v_min : IM_S32_MIN, v_max ? *(const ImS32* )v_max : IM_S32_MAX, format, power, flags);
+    case ImGuiDataType_U32:    return DragBehaviorT<ImU32, ImS32, float >(data_type, (ImU32*)v,  v_speed, v_min ? *(const ImU32* )v_min : IM_U32_MIN, v_max ? *(const ImU32* )v_max : IM_U32_MAX, format, power, flags);
+    case ImGuiDataType_S64:    return DragBehaviorT<ImS64, ImS64, double>(data_type, (ImS64*)v,  v_speed, v_min ? *(const ImS64* )v_min : IM_S64_MIN, v_max ? *(const ImS64* )v_max : IM_S64_MAX, format, power, flags);
+    case ImGuiDataType_U64:    return DragBehaviorT<ImU64, ImS64, double>(data_type, (ImU64*)v,  v_speed, v_min ? *(const ImU64* )v_min : IM_U64_MIN, v_max ? *(const ImU64* )v_max : IM_U64_MAX, format, power, flags);
+    case ImGuiDataType_Float:  return DragBehaviorT<float, float, float >(data_type, (float*)v,  v_speed, v_min ? *(const float* )v_min : -FLT_MAX,   v_max ? *(const float* )v_max : FLT_MAX,    format, power, flags);
+    case ImGuiDataType_Double: return DragBehaviorT<double,double,double>(data_type, (double*)v, v_speed, v_min ? *(const double*)v_min : -DBL_MAX,   v_max ? *(const double*)v_max : DBL_MAX,    format, power, flags);
     case ImGuiDataType_COUNT:  break;
     }
     IM_ASSERT(0);
@@ -1889,7 +1894,7 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* v, floa
 
     // Actual drag behavior
     ItemSize(total_bb, style.FramePadding.y);
-    const bool value_changed = DragBehavior(id, data_type, v, v_speed, v_min, v_max, format, power);
+    const bool value_changed = DragBehavior(id, data_type, v, v_speed, v_min, v_max, format, power, ImGuiDragFlags_None);
     if (value_changed)
         MarkItemEdited(id);
 
@@ -2096,20 +2101,20 @@ bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_typ
     ImGuiContext& g = *GImGui;
     const ImGuiStyle& style = g.Style;
 
-    const bool is_horizontal = (flags & ImGuiSliderFlags_Vertical) == 0;
+    const ImGuiAxis axis = (flags & ImGuiSliderFlags_Vertical) ? ImGuiAxis_Y : ImGuiAxis_X;
     const bool is_decimal = (data_type == ImGuiDataType_Float) || (data_type == ImGuiDataType_Double);
     const bool is_power = (power != 1.0f) && is_decimal;
 
     const float grab_padding = 2.0f;
-    const float slider_sz = is_horizontal ? (bb.GetWidth() - grab_padding * 2.0f) : (bb.GetHeight() - grab_padding * 2.0f);
+    const float slider_sz = (bb.Max[axis] - bb.Min[axis]) - grab_padding * 2.0f;
     float grab_sz = style.GrabMinSize;
     SIGNEDTYPE v_range = (v_min < v_max ? v_max - v_min : v_min - v_max);
     if (!is_decimal && v_range >= 0)                                             // v_range < 0 may happen on integer overflows
         grab_sz = ImMax((float)(slider_sz / (v_range + 1)), style.GrabMinSize);  // For integer sliders: if possible have the grab size represent 1 unit
     grab_sz = ImMin(grab_sz, slider_sz);
     const float slider_usable_sz = slider_sz - grab_sz;
-    const float slider_usable_pos_min = (is_horizontal ? bb.Min.x : bb.Min.y) + grab_padding + grab_sz*0.5f;
-    const float slider_usable_pos_max = (is_horizontal ? bb.Max.x : bb.Max.y) - grab_padding - grab_sz*0.5f;
+    const float slider_usable_pos_min = bb.Min[axis] + grab_padding + grab_sz*0.5f;
+    const float slider_usable_pos_max = bb.Max[axis] - grab_padding - grab_sz*0.5f;
 
     // For power curve sliders that cross over sign boundary we want the curve to be symmetric around 0.0f
     float linear_zero_pos;   // 0.0->1.0f
@@ -2140,9 +2145,9 @@ bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_typ
             }
             else
             {
-                const float mouse_abs_pos = is_horizontal ? g.IO.MousePos.x : g.IO.MousePos.y;
+                const float mouse_abs_pos = g.IO.MousePos[axis];
                 clicked_t = (slider_usable_sz > 0.0f) ? ImClamp((mouse_abs_pos - slider_usable_pos_min) / slider_usable_sz, 0.0f, 1.0f) : 0.0f;
-                if (!is_horizontal)
+                if (axis == ImGuiAxis_Y)
                     clicked_t = 1.0f - clicked_t;
                 set_new_value = true;
             }
@@ -2150,7 +2155,7 @@ bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_typ
         else if (g.ActiveIdSource == ImGuiInputSource_Nav)
         {
             const ImVec2 delta2 = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard | ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_RepeatFast, 0.0f, 0.0f);
-            float delta = is_horizontal ? delta2.x : -delta2.y;
+            float delta = (axis == ImGuiAxis_X) ? delta2.x : -delta2.y;
             if (g.NavActivatePressedId == id && !g.ActiveIdIsJustActivated)
             {
                 ClearActiveID();
@@ -2242,10 +2247,10 @@ bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_typ
 
     // Output grab position so it can be displayed by the caller
     float grab_t = SliderCalcRatioFromValueT<TYPE,FLOATTYPE>(data_type, *v, v_min, v_max, power, linear_zero_pos);
-    if (!is_horizontal)
+    if (axis == ImGuiAxis_Y)
         grab_t = 1.0f - grab_t;
     const float grab_pos = ImLerp(slider_usable_pos_min, slider_usable_pos_max, grab_t);
-    if (is_horizontal)
+    if (axis == ImGuiAxis_X)
         *out_grab_bb = ImRect(grab_pos - grab_sz*0.5f, bb.Min.y + grab_padding, grab_pos + grab_sz*0.5f, bb.Max.y - grab_padding);
     else
         *out_grab_bb = ImRect(bb.Min.x + grab_padding, grab_pos - grab_sz*0.5f, bb.Max.x - grab_padding, grab_pos + grab_sz*0.5f);

+ 2 - 2
3rdparty/glslang/CMakeLists.txt

@@ -45,7 +45,7 @@ if(USE_CCACHE)
 endif()
 
 # Precompiled header macro. Parameters are source file list and filename for pch cpp file.
-macro(PCH SRCS PCHCPP)
+macro(glslang_pch SRCS PCHCPP)
   if(MSVC)
     if (CMAKE_GENERATOR MATCHES "^Visual Studio")
       set(PCH_NAME "$(IntDir)\\pch.pch")
@@ -58,7 +58,7 @@ macro(PCH SRCS PCHCPP)
     set_source_files_properties(${PCHCPP} PROPERTIES COMPILE_FLAGS "/Ycpch.h /Fp${PCH_NAME} /Zm300" OBJECT_OUTPUTS "${PCH_NAME}")
     list(APPEND ${SRCS} "${PCHCPP}")
   endif()
-endmacro(PCH)
+endmacro(glslang_pch)
 
 project(glslang)
 # make testing optional

+ 1 - 0
3rdparty/glslang/SPIRV/SpvTools.cpp

@@ -152,6 +152,7 @@ void SpirvToolsLegalize(const glslang::TIntermediate&, std::vector<unsigned int>
             out << std::endl;
         });
 
+    optimizer.RegisterPass(spvtools::CreateDeadBranchElimPass());
     optimizer.RegisterPass(spvtools::CreateMergeReturnPass());
     optimizer.RegisterPass(spvtools::CreateInlineExhaustivePass());
     optimizer.RegisterPass(spvtools::CreateEliminateDeadFunctionsPass());

+ 2 - 0
3rdparty/glslang/Test/baseResults/cppBad.vert.out

@@ -10,6 +10,7 @@ ERROR: 5 compilation errors.  No code generated.
 Shader version: 100
 ERROR: node is still EOpNull!
 0:?   Linker Objects
+0:?     'n' ( global highp int)
 
 
 Linked vertex stage:
@@ -19,4 +20,5 @@ ERROR: Linking vertex stage: Missing entry point: Each stage requires one entry
 Shader version: 100
 ERROR: node is still EOpNull!
 0:?   Linker Objects
+0:?     'n' ( global highp int)
 

+ 4 - 4
3rdparty/glslang/Test/baseResults/cppSimple.vert.out

@@ -35,9 +35,9 @@ ERROR: 0:155: '#else' : unexpected tokens following directive
 ERROR: 0:158: '#else' : #else after #else 
 ERROR: 0:160: '#endif' : unexpected tokens following directive 
 ERROR: 0:164: '#define' : duplicate macro parameter 
-ERROR: 0:173: '#define' : Macro redefined; different number of arguments: m4
-ERROR: 0:178: '#define' : Macro redefined; different number of arguments: m5
-ERROR: 0:182: '#define' : Macro redefined; different number of arguments: m6
+ERROR: 0:173: '#define' : Macro redefined; function-like versus object-like: m4
+ERROR: 0:177: '#define' : Macro redefined; function-like versus object-like: m5
+ERROR: 0:181: '#define' : Macro redefined; different number of arguments: m6
 ERROR: 0:185: '#define' : Macro redefined; different substitutions: m7
 ERROR: 0:192: '#define' : Macro redefined; different substitutions: m8
 ERROR: 0:196: '#define' : Macro redefined; different argument names: m9
@@ -77,7 +77,7 @@ ERROR: 12:9000: 'preprocessor evaluation' : expected ')'
 ERROR: 12:9002: '#if' : unexpected tokens following directive 
 ERROR: 12:9014: 'FOOOM' : undeclared identifier 
 ERROR: 12:9014: '=' :  cannot convert from ' temp float' to ' global int'
-ERROR: 12:9016: 'preprocessor evaluation' : can't evaluate expression 
+ERROR: 12:9015: 'preprocessor evaluation' : can't evaluate expression 
 ERROR: 12:9016: 'preprocessor evaluation' : bad expression 
 ERROR: 12:9500: 'preprocessor evaluation' : bad expression 
 ERROR: 12:9500: '#if' : unexpected tokens following directive 

+ 36 - 0
3rdparty/glslang/Test/baseResults/preprocessor.simple.vert.out

@@ -28,3 +28,39 @@ int main(){
   1.2 2E10 5u - 5l f
 }
 
+struct S {
+    int member1;
+    float member2;
+    vec4 member3;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+void foo()
+{
+    S s;
+    s . member2 + s . member1;
+    s . member3 . zyx;
+    s . member2 . xxyz;
+    s . member2 . yyz;
+    s . member2 . xxyz();
+    s . member2 . yzy;
+            vec3 a = vec3(0);vec3 b = a . zxyz;vec3 b = a . xxyz;vec3 b = a . yyz;vec3 b = a . xxyz();vec3 b = a . yzy;vec3 b = a . z;
+
+
+     yyz;
+    yzy
+
+
+}
+

+ 93 - 0
3rdparty/glslang/Test/baseResults/spv.xfbOffsetOnStructMembersAssignment.vert.out

@@ -0,0 +1,93 @@
+spv.xfbOffsetOnStructMembersAssignment.vert
+// Module Version 10000
+// Generated by (magic number): 80007
+// Id's are bound by 40
+
+                              Capability Shader
+                              Capability TransformFeedback
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint Vertex 4  "main" 9 21 34 38 39
+                              ExecutionMode 4 Xfb
+                              Source GLSL 450
+                              Name 4  "main"
+                              Name 7  "S"
+                              MemberName 7(S) 0  "x1_out"
+                              MemberName 7(S) 1  "x2_out"
+                              Name 9  "s1"
+                              Name 19  "S2"
+                              MemberName 19(S2) 0  "y1_out"
+                              MemberName 19(S2) 1  "y2_out"
+                              Name 21  "s2"
+                              Name 32  "gl_PerVertex"
+                              MemberName 32(gl_PerVertex) 0  "gl_Position"
+                              MemberName 32(gl_PerVertex) 1  "gl_PointSize"
+                              MemberName 32(gl_PerVertex) 2  "gl_ClipDistance"
+                              MemberName 32(gl_PerVertex) 3  "gl_CullDistance"
+                              Name 34  ""
+                              Name 38  "gl_VertexID"
+                              Name 39  "gl_InstanceID"
+                              MemberDecorate 7(S) 0 Offset 16
+                              MemberDecorate 7(S) 1 Offset 20
+                              Decorate 9(s1) Location 0
+                              Decorate 9(s1) XfbBuffer 2
+                              Decorate 9(s1) XfbStride 24
+                              MemberDecorate 19(S2) 0 Offset 8
+                              MemberDecorate 19(S2) 1 Offset 12
+                              Decorate 21(s2) Location 5
+                              Decorate 21(s2) XfbBuffer 1
+                              Decorate 21(s2) XfbStride 28
+                              MemberDecorate 32(gl_PerVertex) 0 BuiltIn Position
+                              MemberDecorate 32(gl_PerVertex) 1 BuiltIn PointSize
+                              MemberDecorate 32(gl_PerVertex) 2 BuiltIn ClipDistance
+                              MemberDecorate 32(gl_PerVertex) 3 BuiltIn CullDistance
+                              Decorate 32(gl_PerVertex) Block
+                              Decorate 34 XfbBuffer 0
+                              Decorate 34 XfbStride 0
+                              Decorate 38(gl_VertexID) BuiltIn VertexId
+                              Decorate 39(gl_InstanceID) BuiltIn InstanceId
+               2:             TypeVoid
+               3:             TypeFunction 2
+               6:             TypeFloat 32
+            7(S):             TypeStruct 6(float) 6(float)
+               8:             TypePointer Output 7(S)
+           9(s1):      8(ptr) Variable Output
+              10:             TypeInt 32 1
+              11:     10(int) Constant 0
+              12:    6(float) Constant 1084227584
+              13:             TypePointer Output 6(float)
+              15:     10(int) Constant 1
+              16:    6(float) Constant 1086324736
+              18:             TypeVector 6(float) 4
+          19(S2):             TypeStruct 6(float) 18(fvec4)
+              20:             TypePointer Output 19(S2)
+          21(s2):     20(ptr) Variable Output
+              22:    6(float) Constant 1088421888
+              24:    6(float) Constant 1065353216
+              25:    6(float) Constant 0
+              26:   18(fvec4) ConstantComposite 24 25 25 24
+              27:             TypePointer Output 18(fvec4)
+              29:             TypeInt 32 0
+              30:     29(int) Constant 1
+              31:             TypeArray 6(float) 30
+32(gl_PerVertex):             TypeStruct 18(fvec4) 6(float) 31 31
+              33:             TypePointer Output 32(gl_PerVertex)
+              34:     33(ptr) Variable Output
+              35:   18(fvec4) ConstantComposite 25 25 25 25
+              37:             TypePointer Input 10(int)
+ 38(gl_VertexID):     37(ptr) Variable Input
+39(gl_InstanceID):     37(ptr) Variable Input
+         4(main):           2 Function None 3
+               5:             Label
+              14:     13(ptr) AccessChain 9(s1) 11
+                              Store 14 12
+              17:     13(ptr) AccessChain 9(s1) 15
+                              Store 17 16
+              23:     13(ptr) AccessChain 21(s2) 11
+                              Store 23 22
+              28:     27(ptr) AccessChain 21(s2) 15
+                              Store 28 26
+              36:     27(ptr) AccessChain 34 11
+                              Store 36 35
+                              Return
+                              FunctionEnd

+ 2 - 2
3rdparty/glslang/Test/cppSimple.vert

@@ -170,7 +170,7 @@ int a = length("aoenatuh");  // ERROR
 
 // ERROR
 #define m4(b)
-#define m4 (b)
+#define m4
 
 // ERROR
 #define m5 (b)
@@ -178,7 +178,7 @@ int a = length("aoenatuh");  // ERROR
 
 // ERROR
 #define m6(a)
-#define m6
+#define m6(a,b)
 
 // ERROR (whitespace)
 #define m7 (a)

+ 36 - 0
3rdparty/glslang/Test/preprocessor.simple.vert

@@ -27,3 +27,39 @@ int main() {
   += -= *= /= %= <<= >>= &= |= ^=
   1.2 2E10 5u -5lf
 }
+
+struct S {
+    int member1;
+    float member2;
+    vec4 member3;
+};
+
+#define xyz xxyz
+#define yzy() yyz
+
+#define FUN_MAC() \
+	vec3 a = vec3(0); \
+	vec3 b = a.zxyz;  \
+	vec3 b = a.xyz;   \
+	vec3 b = a.yzy();   \
+	vec3 b = a.xyz();   \
+	vec3 b = a.yzy;   \
+	vec3 b = a.z;
+
+void foo()
+{
+    S s;
+    s.member2 + s.member1;
+    s.member3.zyx;
+    s.member2.xyz;
+    s.member2.yzy();
+    s.member2.xyz();
+    s.member2.yzy;
+    FUN_MAC()
+    yzy
+
+    ();
+    yzy
+
+
+}

+ 23 - 0
3rdparty/glslang/Test/spv.xfbOffsetOnStructMembersAssignment.vert

@@ -0,0 +1,23 @@
+#version 450
+
+layout(xfb_buffer=2) out;
+
+struct S {
+   float x1_out;
+   float x2_out;
+};
+
+layout(location=0, xfb_offset = 16) out S s1;
+
+layout(location=5, xfb_buffer=1, xfb_offset=8) out struct S2 {
+   float y1_out;
+   vec4 y2_out;
+}s2;
+
+void main() {
+   s1.x1_out = 5.0;
+   s1.x2_out = 6.0;
+   s2.y1_out = 7.0;
+   s2.y2_out = vec4(1.0, 0.0, 0.0, 1.0);
+   gl_Position = vec4(0.0);
+}

+ 1 - 1
3rdparty/glslang/glslang/CMakeLists.txt

@@ -80,7 +80,7 @@ set(HEADERS
 #                    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
 # set(BISON_GLSLParser_OUTPUT_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/MachineIndependent/glslang_tab.cpp)
 
-PCH(SOURCES MachineIndependent/pch.cpp)
+glslang_pch(SOURCES MachineIndependent/pch.cpp)
 
 add_library(glslang ${LIB_TYPE} ${BISON_GLSLParser_OUTPUT_SOURCE} ${SOURCES} ${HEADERS})
 set_property(TARGET glslang PROPERTY FOLDER glslang)

+ 8 - 3
3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp

@@ -4041,7 +4041,7 @@ void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newT
     if (currentBlockQualifier.storage == EvqVaryingOut && globalOutputDefaults.hasXfbBuffer()) {
         if (!currentBlockQualifier.hasXfbBuffer())
             currentBlockQualifier.layoutXfbBuffer = globalOutputDefaults.layoutXfbBuffer;
-        fixBlockXfbOffsets(currentBlockQualifier, newTypeList);
+        fixXfbOffsets(currentBlockQualifier, newTypeList);
     }
 
     // Edit and error check the container against the redeclaration
@@ -6116,6 +6116,11 @@ TIntermNode* TParseContext::declareVariable(const TSourceLoc& loc, TString& iden
     // fix up
     fixOffset(loc, *symbol);
 
+    if (symbol->getType().getBasicType() == EbtStruct) {
+       fixXfbOffsets(symbol->getWritableType().getQualifier(),
+                     *(symbol->getWritableType().getWritableStruct()));
+    }
+
     return initNode;
 }
 
@@ -6840,7 +6845,7 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con
 
     // Process the members
     fixBlockLocations(loc, currentBlockQualifier, typeList, memberWithLocation, memberWithoutLocation);
-    fixBlockXfbOffsets(currentBlockQualifier, typeList);
+    fixXfbOffsets(currentBlockQualifier, typeList);
     fixBlockUniformOffsets(currentBlockQualifier, typeList);
     for (unsigned int member = 0; member < typeList.size(); ++member)
         layoutTypeCheck(typeList[member].loc, *typeList[member].type);
@@ -7091,7 +7096,7 @@ void TParseContext::fixBlockLocations(const TSourceLoc& loc, TQualifier& qualifi
     }
 }
 
-void TParseContext::fixBlockXfbOffsets(TQualifier& qualifier, TTypeList& typeList)
+void TParseContext::fixXfbOffsets(TQualifier& qualifier, TTypeList& typeList)
 {
     // "If a block is qualified with xfb_offset, all its
     // members are assigned transform feedback buffer offsets. If a block is not qualified with xfb_offset, any

+ 1 - 1
3rdparty/glslang/glslang/MachineIndependent/ParseHelper.h

@@ -403,7 +403,7 @@ public:
     void blockStageIoCheck(const TSourceLoc&, const TQualifier&);
     void blockQualifierCheck(const TSourceLoc&, const TQualifier&, bool instanceName);
     void fixBlockLocations(const TSourceLoc&, TQualifier&, TTypeList&, bool memberWithLocation, bool memberWithoutLocation);
-    void fixBlockXfbOffsets(TQualifier&, TTypeList&);
+    void fixXfbOffsets(TQualifier&, TTypeList&);
     void fixBlockUniformOffsets(TQualifier&, TTypeList&);
     void addQualifierToExisting(const TSourceLoc&, TQualifier, const TString& identifier);
     void addQualifierToExisting(const TSourceLoc&, TQualifier, TIdentifierList&);

+ 16 - 9
3rdparty/glslang/glslang/MachineIndependent/preprocessor/Pp.cpp

@@ -109,11 +109,12 @@ int TPpContext::CPPdefine(TPpToken* ppToken)
 
     // save the macro name
     const int defAtom = atomStrings.getAddAtom(ppToken->name);
+    TSourceLoc defineLoc = ppToken->loc; // because ppToken might go to the next line before we report errors
 
     // gather parameters to the macro, between (...)
     token = scanToken(ppToken);
-    if (token == '(' && ! ppToken->space) {
-        mac.emptyArgs = 1;
+    if (token == '(' && !ppToken->space) {
+        mac.functionLike = 1;
         do {
             token = scanToken(ppToken);
             if (mac.args.size() == 0 && token == ')')
@@ -123,7 +124,6 @@ int TPpContext::CPPdefine(TPpToken* ppToken)
 
                 return token;
             }
-            mac.emptyArgs = 0;
             const int argAtom = atomStrings.getAddAtom(ppToken->name);
 
             // check for duplication of parameter name
@@ -149,7 +149,6 @@ int TPpContext::CPPdefine(TPpToken* ppToken)
     }
 
     // record the definition of the macro
-    TSourceLoc defineLoc = ppToken->loc; // because ppToken is going to go to the next line before we report errors
     while (token != '\n' && token != EndOfInput) {
         mac.body.putToken(token, ppToken);
         token = scanToken(ppToken);
@@ -164,7 +163,9 @@ int TPpContext::CPPdefine(TPpToken* ppToken)
             // Already defined -- need to make sure they are identical:
             // "Two replacement lists are identical if and only if the preprocessing tokens in both have the same number,
             // ordering, spelling, and white-space separation, where all white-space separations are considered identical."
-            if (existing->args.size() != mac.args.size() || existing->emptyArgs != mac.emptyArgs)
+            if (existing->functionLike != mac.functionLike)
+                parseContext.ppError(defineLoc, "Macro redefined; function-like versus object-like:", "#define", atomStrings.getString(defAtom));
+            else if (existing->args.size() != mac.args.size())
                 parseContext.ppError(defineLoc, "Macro redefined; different number of arguments:", "#define", atomStrings.getString(defAtom));
             else {
                 if (existing->args != mac.args)
@@ -1190,14 +1191,20 @@ MacroExpandResult TPpContext::MacroExpand(TPpToken* ppToken, bool expandUndef, b
 
     TSourceLoc loc = ppToken->loc;  // in case we go to the next line before discovering the error
     in->mac = macro;
-    if (macro->args.size() > 0 || macro->emptyArgs) {
-        int token = scanToken(ppToken);
+    if (macro->functionLike) {
+        // We don't know yet if this will be a successful call of a
+        // function-like macro; need to look for a '(', but without trashing
+        // the passed in ppToken, until we know we are no longer speculative.
+        TPpToken parenToken;
+        int token = scanToken(&parenToken);
         if (newLineOkay) {
             while (token == '\n')
-                token = scanToken(ppToken);
+                token = scanToken(&parenToken);
         }
         if (token != '(') {
-            UngetToken(token, ppToken);
+            // Function-like macro called with object-like syntax: okay, don't expand.
+            // (We ate exactly one token that might not be white space; put it back.
+            UngetToken(token, &parenToken);
             delete in;
             return MacroExpandNotStarted;
         }

+ 4 - 4
3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpContext.h

@@ -267,12 +267,12 @@ public:
     //
 
     struct MacroSymbol {
-        MacroSymbol() : emptyArgs(0), busy(0), undef(0) { }
+        MacroSymbol() : functionLike(0), busy(0), undef(0) { }
         TVector<int> args;
         TokenStream body;
-        unsigned emptyArgs : 1;
-        unsigned busy      : 1;
-        unsigned undef     : 1;
+        unsigned functionLike : 1;  // 0 means object-like, 1 means function-like
+        unsigned busy         : 1;
+        unsigned undef        : 1;
     };
 
     typedef TMap<int, MacroSymbol> TSymbolMap;

+ 1 - 1
3rdparty/glslang/gtests/CMakeLists.txt

@@ -25,7 +25,7 @@ if(BUILD_TESTING)
             # -- Remapper tests
             ${CMAKE_CURRENT_SOURCE_DIR}/Remap.FromFile.cpp)
 
-        PCH(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/pch.cpp)
+        glslang_pch(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/pch.cpp)
 
         add_executable(glslangtests ${TEST_SOURCES})
         set_property(TARGET glslangtests PROPERTY FOLDER tests)

+ 1 - 0
3rdparty/glslang/gtests/Spv.FromFile.cpp

@@ -440,6 +440,7 @@ INSTANTIATE_TEST_CASE_P(
         "spv.rankShift.comp",
         "spv.specConst.vert",
         "spv.OVR_multiview.vert",
+        "spv.xfbOffsetOnStructMembersAssignment.vert",
     })),
     FileNameAsCustomTestSuffix
 );

+ 1 - 1
3rdparty/glslang/hlsl/CMakeLists.txt

@@ -17,7 +17,7 @@ set(HEADERS
     hlslGrammar.h
     hlslParseables.h)
 
-PCH(SOURCES pch.cpp)
+glslang_pch(SOURCES pch.cpp)
 
 add_library(HLSL ${LIB_TYPE} ${SOURCES} ${HEADERS})
 set_property(TARGET HLSL PROPERTY FOLDER hlsl)

+ 2 - 2
3rdparty/glslang/hlsl/hlslParseHelper.cpp

@@ -8555,7 +8555,7 @@ void HlslParseContext::declareBlock(const TSourceLoc& loc, TType& type, const TS
 
     // Process the members
     fixBlockLocations(loc, type.getQualifier(), typeList, memberWithLocation, memberWithoutLocation);
-    fixBlockXfbOffsets(type.getQualifier(), typeList);
+    fixXfbOffsets(type.getQualifier(), typeList);
     fixBlockUniformOffsets(type.getQualifier(), typeList);
 
     // reverse merge, so that currentBlockQualifier now has all layout information
@@ -8638,7 +8638,7 @@ void HlslParseContext::fixBlockLocations(const TSourceLoc& loc, TQualifier& qual
     }
 }
 
-void HlslParseContext::fixBlockXfbOffsets(TQualifier& qualifier, TTypeList& typeList)
+void HlslParseContext::fixXfbOffsets(TQualifier& qualifier, TTypeList& typeList)
 {
     // "If a block is qualified with xfb_offset, all its
     // members are assigned transform feedback buffer offsets. If a block is not qualified with xfb_offset, any

+ 1 - 1
3rdparty/glslang/hlsl/hlslParseHelper.h

@@ -155,7 +155,7 @@ public:
     void declareBlock(const TSourceLoc&, TType&, const TString* instanceName = 0);
     void declareStructBufferCounter(const TSourceLoc& loc, const TType& bufferType, const TString& name);
     void fixBlockLocations(const TSourceLoc&, TQualifier&, TTypeList&, bool memberWithLocation, bool memberWithoutLocation);
-    void fixBlockXfbOffsets(TQualifier&, TTypeList&);
+    void fixXfbOffsets(TQualifier&, TTypeList&);
     void fixBlockUniformOffsets(const TQualifier&, TTypeList&);
     void addQualifierToExisting(const TSourceLoc&, TQualifier, const TString& identifier);
     void addQualifierToExisting(const TSourceLoc&, TQualifier, TIdentifierList&);

+ 1 - 1
3rdparty/glslang/known_good.json

@@ -5,7 +5,7 @@
       "site" : "github",
       "subrepo" : "KhronosGroup/SPIRV-Tools",
       "subdir" : "External/spirv-tools",
-      "commit" : "fb996dce752507132c40c255898154cce6c072c5"
+      "commit" : "9d699f6d4038f432c55310d5d0b4a6d507c1b686"
     },
     {
       "name" : "spirv-tools/external/spirv-headers",

+ 5 - 0
README.md

@@ -315,6 +315,11 @@ target="_blank"><img src="http://img.youtube.com/vi/IUmxqAWdXvk/0.jpg"
 alt="Off The Road"
 width="640" height="480" border="0" /></a>
 
+## Coal Burnout
+
+https://beardsvibe.com/ - Multiplayer PVP rhythm game.
+![coal-burnout](https://beardsvibe.com/scr/0l.png)
+
 [License (BSD 2-clause)](https://bkaradzic.github.io/bgfx/license.html)
 -----------------------------------------------------------------------
 

+ 2 - 1
src/renderer_gl.cpp

@@ -2276,7 +2276,8 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
 					: 0
 					;
 
-				if (NULL == glPolygonMode)
+				if (BX_ENABLED(BX_PLATFORM_EMSCRIPTEN)
+				||  NULL == glPolygonMode)
 				{
 					glPolygonMode = stubPolygonMode;
 				}