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

This commit is contained in:
Бранимир Караџић
2019-05-23 17:56:34 -07:00
194 changed files with 13206 additions and 2193 deletions

View File

@@ -997,7 +997,7 @@ CODE
#endif
// Clang/GCC warnings with -Weverything
#ifdef __clang__
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning : unknown warning group '-Wformat-pedantic *' // not all warnings are known by all clang versions.. so ignoring warnings triggers new warnings on some configuration. great!
#pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse.
#pragma clang diagnostic ignored "-Wfloat-equal" // warning : comparing floating point with == or != is unsafe // storing and comparing against same constants (typically 0.0f) is ok.
@@ -2833,9 +2833,13 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg)
{
// Navigation processing runs prior to clipping early-out
// (a) So that NavInitRequest can be honored, for newly opened windows to select a default widget
// (b) So that we can scroll up/down past clipped items. This adds a small O(N) cost to regular navigation requests unfortunately, but it is still limited to one window.
// it may not scale very well for windows with ten of thousands of item, but at least NavMoveRequest is only set on user interaction, aka maximum once a frame.
// We could early out with "if (is_clipped && !g.NavInitRequest) return false;" but when we wouldn't be able to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick)
// (b) So that we can scroll up/down past clipped items. This adds a small O(N) cost to regular navigation requests
// unfortunately, but it is still limited to one window. It may not scale very well for windows with ten of
// thousands of item, but at least NavMoveRequest is only set on user interaction, aka maximum once a frame.
// We could early out with "if (is_clipped && !g.NavInitRequest) return false;" but when we wouldn't be able
// to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick).
// We intentionally don't check if g.NavWindow != NULL because g.NavAnyRequest should only be set when it is non null.
// If we crash on a NULL g.NavWindow we need to fix the bug elsewhere.
window->DC.NavLayerActiveMaskNext |= window->DC.NavLayerCurrentMask;
if (g.NavId == id || g.NavAnyRequest)
if (g.NavWindow->RootWindowForNav == window->RootWindowForNav)
@@ -5461,10 +5465,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
window->ContentsRegionRect.Max.x = window->Pos.x - window->Scroll.x - window->WindowPadding.x + (window->SizeContentsExplicit.x != 0.0f ? window->SizeContentsExplicit.x : (window->Size.x - window->ScrollbarSizes.x + ImMin(window->ScrollbarSizes.x, window->WindowBorderSize)));
window->ContentsRegionRect.Max.y = window->Pos.y - window->Scroll.y - window->WindowPadding.y + (window->SizeContentsExplicit.y != 0.0f ? window->SizeContentsExplicit.y : (window->Size.y - window->ScrollbarSizes.y + ImMin(window->ScrollbarSizes.y, window->WindowBorderSize)));
// Save clipped aabb so we can access it in constant-time in FindHoveredWindow()
window->OuterRectClipped = window->Rect();
window->OuterRectClipped.ClipWith(window->ClipRect);
// Inner rectangle
// We set this up after processing the resize grip so that our clip rectangle doesn't lag by a frame
// Note that if our window is collapsed we will end up with an inverted (~null) clipping rectangle which is the correct behavior.
@@ -5474,13 +5474,22 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
window->InnerMainRect.Max.x = window->Pos.x + window->Size.x - ImMax(window->ScrollbarSizes.x, window->WindowBorderSize);
window->InnerMainRect.Max.y = window->Pos.y + window->Size.y - ImMax(window->ScrollbarSizes.y, window->WindowBorderSize);
// Inner clipping rectangle will extend a little bit outside the work region.
// Outer host rectangle for drawing background and borders
ImRect host_rect = ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup) && !window_is_child_tooltip) ? parent_window->ClipRect : viewport_rect;
// Save clipped aabb so we can access it in constant-time in FindHoveredWindow()
window->OuterRectClipped = window->Rect();
window->OuterRectClipped.ClipWith(host_rect);
// Inner work/clipping rectangle will extend a little bit outside the work region.
// This is to allow e.g. Selectable or CollapsingHeader or some separators to cover that space.
// Force round operator last to ensure that e.g. (int)(max.x-min.x) in user's render code produce correct result.
window->InnerClipRect.Min.x = ImFloor(0.5f + window->InnerMainRect.Min.x + ImMax(0.0f, ImFloor(window->WindowPadding.x * 0.5f - window->WindowBorderSize)));
window->InnerClipRect.Min.y = ImFloor(0.5f + window->InnerMainRect.Min.y);
window->InnerClipRect.Max.x = ImFloor(0.5f + window->InnerMainRect.Max.x - ImMax(0.0f, ImFloor(window->WindowPadding.x * 0.5f - window->WindowBorderSize)));
window->InnerClipRect.Max.y = ImFloor(0.5f + window->InnerMainRect.Max.y);
window->InnerWorkRect.Min.x = ImFloor(0.5f + window->InnerMainRect.Min.x + ImMax(0.0f, ImFloor(window->WindowPadding.x * 0.5f - window->WindowBorderSize)));
window->InnerWorkRect.Min.y = ImFloor(0.5f + window->InnerMainRect.Min.y);
window->InnerWorkRect.Max.x = ImFloor(0.5f + window->InnerMainRect.Max.x - ImMax(0.0f, ImFloor(window->WindowPadding.x * 0.5f - window->WindowBorderSize)));
window->InnerWorkRect.Max.y = ImFloor(0.5f + window->InnerMainRect.Max.y);
window->InnerWorkRectClipped = window->InnerWorkRect;
window->InnerWorkRectClipped.ClipWithFull(host_rect);
// DRAWING
@@ -5488,10 +5497,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
window->DrawList->Clear();
window->DrawList->Flags = (g.Style.AntiAliasedLines ? ImDrawListFlags_AntiAliasedLines : 0) | (g.Style.AntiAliasedFill ? ImDrawListFlags_AntiAliasedFill : 0);
window->DrawList->PushTextureID(g.Font->ContainerAtlas->TexID);
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup) && !window_is_child_tooltip)
PushClipRect(parent_window->ClipRect.Min, parent_window->ClipRect.Max, true);
else
PushClipRect(viewport_rect.Min, viewport_rect.Max, true);
PushClipRect(host_rect.Min, host_rect.Max, false);
// Draw modal window background (darkens what is behind them, all viewports)
const bool dim_bg_for_modal = (flags & ImGuiWindowFlags_Modal) && window == GetFrontMostPopupModal() && window->HiddenFramesCannotSkipItems <= 0;
@@ -5609,7 +5615,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
SetCurrentWindow(window);
}
PushClipRect(window->InnerClipRect.Min, window->InnerClipRect.Max, true);
PushClipRect(window->InnerWorkRectClipped.Min, window->InnerWorkRectClipped.Max, true);
// Clear 'accessed' flag last thing (After PushClipRect which will set the flag. We want the flag to stay false when the default "Debug" window is unused)
if (first_begin_of_the_frame)
@@ -7231,6 +7237,8 @@ void ImGui::EndPopup()
bool ImGui::BeginPopupContextItem(const char* str_id, int mouse_button)
{
ImGuiWindow* window = GImGui->CurrentWindow;
if (window->SkipItems)
return false;
ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
@@ -8437,7 +8445,8 @@ void ImGui::NextColumn()
columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y);
if (++columns->Current < columns->Count)
{
// New column (columns 1+ cancels out IndentX)
// Columns 1+ cancel out IndentX
// FIXME-COLUMNS: Unnecessary, could be locked?
window->DC.ColumnsOffset.x = GetColumnOffset(columns->Current) - window->DC.Indent.x + g.Style.ItemSpacing.x;
window->DrawList->ChannelsSetCurrent(columns->Current + 1);
}
@@ -8454,7 +8463,7 @@ void ImGui::NextColumn()
window->DC.CurrLineSize = ImVec2(0.0f, 0.0f);
window->DC.CurrLineTextBaseOffset = 0.0f;
PushColumnClipRect(columns->Current);
PushColumnClipRect(columns->Current); // FIXME-COLUMNS: Could it be an overwrite?
PushItemWidth(GetColumnWidth() * 0.65f); // FIXME-COLUMNS: Move on columns setup
}
@@ -8645,7 +8654,7 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
window->DC.CurrentColumns = columns;
// Set state for first column
const float content_region_width = (window->SizeContentsExplicit.x != 0.0f) ? (window->SizeContentsExplicit.x) : (window->InnerClipRect.Max.x - window->Pos.x);
const float content_region_width = (window->SizeContentsExplicit.x != 0.0f) ? (window->SizeContentsExplicit.x) : (window->InnerWorkRect.Max.x - window->Pos.x);
columns->OffMinX = window->DC.Indent.x - g.Style.ItemSpacing.x; // Lock our horizontal range
columns->OffMaxX = ImMax(content_region_width - window->Scroll.x, columns->OffMinX + 1.0f);
columns->HostCursorPosY = window->DC.CursorPos.y;
@@ -9526,15 +9535,17 @@ static void SettingsHandlerWindow_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandl
#else
#include <windows.h>
#endif
#elif defined(__APPLE__)
#include <TargetConditionals.h>
#endif
// Win32 API clipboard implementation
#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS)
#ifdef _MSC_VER
#pragma comment(lib, "user32")
#endif
// Win32 clipboard implementation
static const char* GetClipboardTextFn_DefaultImpl(void*)
{
static ImVector<char> buf_local;
@@ -9578,16 +9589,66 @@ static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
::CloseClipboard();
}
#elif defined(__APPLE__) && TARGET_OS_OSX && !defined(IMGUI_DISABLE_OSX_FUNCTIONS)
#include <Carbon/Carbon.h> // Use old API to avoid need for separate .mm file
static PasteboardRef main_clipboard = 0;
// OSX clipboard implementation
static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
{
if (!main_clipboard)
PasteboardCreate(kPasteboardClipboard, &main_clipboard);
PasteboardClear(main_clipboard);
CFDataRef cf_data = CFDataCreate(kCFAllocatorDefault, (const UInt8*)text, strlen(text));
if (cf_data)
{
PasteboardPutItemFlavor(main_clipboard, (PasteboardItemID)1, CFSTR("public.utf8-plain-text"), cf_data, 0);
CFRelease(cf_data);
}
}
static const char* GetClipboardTextFn_DefaultImpl(void*)
{
if (!main_clipboard)
PasteboardCreate(kPasteboardClipboard, &main_clipboard);
PasteboardSynchronize(main_clipboard);
ItemCount item_count = 0;
PasteboardGetItemCount(main_clipboard, &item_count);
for (int i = 0; i < item_count; i++)
{
PasteboardItemID item_id = 0;
PasteboardGetItemIdentifier(main_clipboard, i + 1, &item_id);
CFArrayRef flavor_type_array = 0;
PasteboardCopyItemFlavors(main_clipboard, item_id, &flavor_type_array);
for (CFIndex j = 0, nj = CFArrayGetCount(flavor_type_array); j < nj; j++)
{
CFDataRef cf_data;
if (PasteboardCopyItemFlavorData(main_clipboard, item_id, CFSTR("public.utf8-plain-text"), &cf_data) == noErr)
{
static ImVector<char> clipboard_text;
int length = (int)CFDataGetLength(cf_data);
clipboard_text.resize(length + 1);
CFDataGetBytes(cf_data, CFRangeMake(0, length), (UInt8*)clipboard_text.Data);
clipboard_text[length] = 0;
CFRelease(cf_data);
return clipboard_text.Data;
}
}
}
return NULL;
}
#else
// Local ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers
// Local Dear ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers.
static const char* GetClipboardTextFn_DefaultImpl(void*)
{
ImGuiContext& g = *GImGui;
return g.PrivateClipboard.empty() ? NULL : g.PrivateClipboard.begin();
}
// Local ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers
static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
{
ImGuiContext& g = *GImGui;
@@ -9601,7 +9662,7 @@ static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
#endif
// Win32 API IME support (for Asian languages, etc.)
#if defined(_WIN32) && !defined(__GNUC__) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS)
#if defined(_WIN32) && !defined(__GNUC__) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS)
#include <imm.h>
#ifdef _MSC_VER
@@ -9641,10 +9702,10 @@ void ImGui::ShowMetricsWindow(bool* p_open)
return;
}
enum { RT_OuterRect, RT_OuterRectClipped, RT_InnerMainRect, RT_InnerClipRect, RT_ContentsRegionRect, RT_ContentsFullRect };
enum { RT_OuterRect, RT_OuterRectClipped, RT_InnerMainRect, RT_InnerWorkRect, RT_InnerWorkRectClipped, RT_ContentsRegionRect, RT_ContentsFullRect };
static bool show_windows_begin_order = false;
static bool show_windows_rects = false;
static int show_windows_rect_type = RT_ContentsRegionRect;
static int show_windows_rect_type = RT_InnerWorkRect;
static bool show_drawcmd_clip_rects = true;
ImGuiIO& io = ImGui::GetIO();
@@ -9858,7 +9919,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
ImGui::Checkbox("Show windows rectangles", &show_windows_rects);
ImGui::SameLine();
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 12);
show_windows_rects |= ImGui::Combo("##rects_type", &show_windows_rect_type, "OuterRect\0" "OuterRectClipped\0" "InnerMainRect\0" "InnerClipRect\0" "ContentsRegionRect\0");
show_windows_rects |= ImGui::Combo("##rects_type", &show_windows_rect_type, "OuterRect\0" "OuterRectClipped\0" "InnerMainRect\0" "InnerWorkRect\0" "InnerWorkRectClipped\0" "ContentsRegionRect\0");
ImGui::Checkbox("Show clipping rectangle when hovering ImDrawCmd node", &show_drawcmd_clip_rects);
ImGui::TreePop();
}
@@ -9877,7 +9938,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
if (show_windows_rect_type == RT_OuterRect) { r = window->Rect(); }
else if (show_windows_rect_type == RT_OuterRectClipped) { r = window->OuterRectClipped; }
else if (show_windows_rect_type == RT_InnerMainRect) { r = window->InnerMainRect; }
else if (show_windows_rect_type == RT_InnerClipRect) { r = window->InnerClipRect; }
else if (show_windows_rect_type == RT_InnerWorkRect) { r = window->InnerWorkRect; }
else if (show_windows_rect_type == RT_InnerWorkRectClipped) { r = window->InnerWorkRectClipped; }
else if (show_windows_rect_type == RT_ContentsRegionRect) { r = window->ContentsRegionRect; }
draw_list->AddRect(r.Min, r.Max, IM_COL32(255, 0, 128, 255));
}

View File

@@ -46,8 +46,8 @@ Index of this file:
// Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
#define IMGUI_VERSION "1.71"
#define IMGUI_VERSION_NUM 17001
#define IMGUI_VERSION "1.71 WIP"
#define IMGUI_VERSION_NUM 17002
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
// Define attributes of all API symbols declarations (e.g. for DLL under Windows)
@@ -1998,12 +1998,13 @@ struct ImFontGlyph
// This is essentially a tightly packed of vector of 64k booleans = 8KB storage.
struct ImFontGlyphRangesBuilder
{
ImVector<int> UsedChars; // Store 1-bit per Unicode code point (0=unused, 1=used)
ImVector<ImU32> UsedChars; // Store 1-bit per Unicode code point (0=unused, 1=used)
ImFontGlyphRangesBuilder() { UsedChars.resize(0x10000 / sizeof(int)); memset(UsedChars.Data, 0, 0x10000 / sizeof(int)); }
bool GetBit(int n) const { int off = (n >> 5); int mask = 1 << (n & 31); return (UsedChars[off] & mask) != 0; } // Get bit n in the array
void SetBit(int n) { int off = (n >> 5); int mask = 1 << (n & 31); UsedChars[off] |= mask; } // Set bit n in the array
void AddChar(ImWchar c) { SetBit(c); } // Add character
ImFontGlyphRangesBuilder() { Clear(); }
inline void Clear() { int size_in_bytes = 0x10000 / 8; UsedChars.resize(size_in_bytes / (int)sizeof(ImU32)); memset(UsedChars.Data, 0, (size_t)size_in_bytes); }
inline bool GetBit(int n) const { int off = (n >> 5); ImU32 mask = 1u << (n & 31); return (UsedChars[off] & mask) != 0; } // Get bit n in the array
inline void SetBit(int n) { int off = (n >> 5); ImU32 mask = 1u << (n & 31); UsedChars[off] |= mask; } // Set bit n in the array
inline void AddChar(ImWchar c) { SetBit(c); } // Add character
IMGUI_API void AddText(const char* text, const char* text_end = NULL); // Add string (each character of the UTF-8 string are added)
IMGUI_API void AddRanges(const ImWchar* ranges); // Add ranges, e.g. builder.AddRanges(ImFontAtlas::GetGlyphRangesDefault()) to force add all of ASCII/Latin+Ext
IMGUI_API void BuildRanges(ImVector<ImWchar>* out_ranges); // Output new ranges

View File

@@ -63,7 +63,7 @@ Index of this file:
#ifdef _MSC_VER
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
#endif
#ifdef __clang__
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse.
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // warning : 'xx' is deprecated: The POSIX name for this item.. // for strdup used in demo code (so user can copy & paste the code)
#pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning : cast to 'void *' from smaller integer type 'int'
@@ -2056,14 +2056,17 @@ static void ShowDemoWindowLayout()
bool scroll_to = ImGui::Button("Scroll To Pos");
ImGui::SameLine(130); scroll_to |= ImGui::DragInt("##pos_y", &scroll_to_px, 1.00f, 0, 9999, "Y = %d px");
ImGui::PopItemWidth();
if (scroll_to) track = false;
if (scroll_to)
track = false;
ImGuiStyle& style = ImGui::GetStyle();
float child_w = (ImGui::GetContentRegionAvail().x - 4 * style.ItemSpacing.x) / 5;
for (int i = 0; i < 5; i++)
{
if (i > 0) ImGui::SameLine();
ImGui::BeginGroup();
ImGui::Text("%s", i == 0 ? "Top" : i == 1 ? "25%" : i == 2 ? "Center" : i == 3 ? "75%" : "Bottom");
ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(ImGui::GetWindowWidth() * 0.17f, 200.0f), true);
ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(child_w, 200.0f), true);
if (scroll_to)
ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + scroll_to_px, i * 0.25f);
for (int line = 0; line < 100; line++)
@@ -2078,7 +2081,8 @@ static void ShowDemoWindowLayout()
ImGui::Text("Line %d", line);
}
}
float scroll_y = ImGui::GetScrollY(), scroll_max_y = ImGui::GetScrollMaxY();
float scroll_y = ImGui::GetScrollY();
float scroll_max_y = ImGui::GetScrollMaxY();
ImGui::EndChild();
ImGui::Text("%.0f/%0.f", scroll_y, scroll_max_y);
ImGui::EndGroup();

View File

@@ -52,7 +52,7 @@ Index of this file:
#endif
// Clang/GCC warnings with -Weverything
#ifdef __clang__
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse.
#pragma clang diagnostic ignored "-Wfloat-equal" // warning : comparing floating point with == or != is unsafe // storing and comparing against same constants ok.
#pragma clang diagnostic ignored "-Wglobal-constructors" // warning : declaration requires a global destructor // similar to above, not sure what the exact difference is.
@@ -100,7 +100,7 @@ namespace IMGUI_STB_NAMESPACE
#pragma warning (disable: 4456) // declaration of 'xx' hides previous local declaration
#endif
#ifdef __clang__
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-function"
#pragma clang diagnostic ignored "-Wmissing-prototypes"
@@ -108,7 +108,7 @@ namespace IMGUI_STB_NAMESPACE
#pragma clang diagnostic ignored "-Wcast-qual" // warning : cast from 'const xxxx *' to 'xxx *' drops const qualifier //
#endif
#ifdef __GNUC__
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wtype-limits" // warning: comparison is always true due to limited range of data type [-Wtype-limits]
#pragma GCC diagnostic ignored "-Wcast-qual" // warning: cast from type 'const xxxx *' to type 'xxxx *' casts away qualifiers
@@ -151,15 +151,15 @@ namespace IMGUI_STB_NAMESPACE
#endif
#endif
#ifdef __GNUC__
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
#ifdef __clang__
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
#ifdef _MSC_VER
#if defined(_MSC_VER)
#pragma warning (pop)
#endif
@@ -1779,7 +1779,7 @@ static void UnpackBoolVectorToFlatIndexList(const ImBoolVector* in, ImVector<int
for (const int* it = it_begin; it < it_end; it++)
if (int entries_32 = *it)
for (int bit_n = 0; bit_n < 32; bit_n++)
if (entries_32 & (1 << bit_n))
if (entries_32 & (1u << bit_n))
out->push_back((int)((it - it_begin) << 5) + bit_n);
}
@@ -2391,11 +2391,12 @@ void ImFontGlyphRangesBuilder::AddRanges(const ImWchar* ranges)
void ImFontGlyphRangesBuilder::BuildRanges(ImVector<ImWchar>* out_ranges)
{
for (int n = 0; n < 0x10000; n++)
int max_codepoint = 0x10000;
for (int n = 0; n < max_codepoint; n++)
if (GetBit(n))
{
out_ranges->push_back((ImWchar)n);
while (n < 0x10000 && GetBit(n + 1))
while (n < max_codepoint - 1 && GetBit(n + 1))
n++;
out_ranges->push_back((ImWchar)n);
}

View File

@@ -36,15 +36,17 @@ Index of this file:
#include <math.h> // sqrtf, fabsf, fmodf, powf, floorf, ceilf, cosf, sinf
#include <limits.h> // INT_MIN, INT_MAX
// Visual Studio warnings
#ifdef _MSC_VER
#pragma warning (push)
#pragma warning (disable: 4251) // class 'xxx' needs to have dll-interface to be used by clients of struct 'xxx' // when IMGUI_API is set to__declspec(dllexport)
#endif
#ifdef __clang__
// Clang/GCC warnings with -Weverything
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-function" // for stb_textedit.h
#pragma clang diagnostic ignored "-Wmissing-prototypes" // for stb_textedit.h
#pragma clang diagnostic ignored "-Wunused-function" // for stb_textedit.h
#pragma clang diagnostic ignored "-Wmissing-prototypes" // for stb_textedit.h
#pragma clang diagnostic ignored "-Wold-style-cast"
#if __has_warning("-Wzero-as-null-pointer-constant")
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
@@ -52,6 +54,11 @@ Index of this file:
#if __has_warning("-Wdouble-promotion")
#pragma clang diagnostic ignored "-Wdouble-promotion"
#endif
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#if __GNUC__ >= 8
#pragma GCC diagnostic ignored "-Wclass-memaccess" // warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
#endif
#endif
//-----------------------------------------------------------------------------
@@ -1283,8 +1290,10 @@ struct IMGUI_API ImGuiWindow
ImGuiWindowTempData DC; // Temporary per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the "DC" variable name.
ImVector<ImGuiID> IDStack; // ID stack. ID are hashes seeded with the value at the top of the stack
ImRect ClipRect; // Current clipping rectangle. = DrawList->clip_rect_stack.back(). Scissoring / clipping rectangle. x1, y1, x2, y2.
ImRect OuterRectClipped; // = WindowRect just after setup in Begin(). == window->Rect() for root window.
ImRect InnerMainRect, InnerClipRect;
ImRect OuterRectClipped; // == WindowRect just after setup in Begin(). == window->Rect() for root window.
ImRect InnerMainRect; //
ImRect InnerWorkRect; // == InnerMainRect minus WindowPadding.x
ImRect InnerWorkRectClipped; // == InnerMainRect minus WindowPadding.x, clipped within viewport or parent clip rect.
ImRect ContentsRegionRect; // FIXME: This is currently confusing/misleading. Maximum visible content position ~~ Pos + (SizeContentsExplicit ? SizeContentsExplicit : Size - ScrollbarSizes) - CursorStartPos, per axis
int LastFrameActive; // Last frame number the window was Active.
float ItemWidthDefault;
@@ -1645,8 +1654,10 @@ extern void ImGuiTestEngineHook_ItemInfo(ImGuiContext* ctx, ImGu
#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID, _LABEL, _FLAGS) do { } while (0)
#endif
#ifdef __clang__
#if defined(__clang__)
#pragma clang diagnostic pop
#elif defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
#ifdef _MSC_VER

View File

@@ -51,7 +51,7 @@ Index of this file:
#endif
// Clang/GCC warnings with -Weverything
#ifdef __clang__
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse.
#pragma clang diagnostic ignored "-Wfloat-equal" // warning : comparing floating point with == or != is unsafe // storing and comparing against same constants (typically 0.0f) is ok.
#pragma clang diagnostic ignored "-Wformat-nonliteral" // warning : format string is not a string literal // passing non-literal to vsnformat(). yes, user passing incorrect format strings can crash the code.
@@ -2790,7 +2790,7 @@ bool ImGui::TempInputTextScalar(const ImRect& bb, ImGuiID id, const char* label,
if (value_changed)
MarkItemEdited(id);
}
return false;
return value_changed;
}
bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* data_ptr, const void* step, const void* step_fast, const char* format, ImGuiInputTextFlags flags)
@@ -5865,7 +5865,7 @@ void ImGui::EndMainMenuBar()
// When the user has left the menu layer (typically: closed menus through activation of an item), we restore focus to the previous window
// FIXME: With this strategy we won't be able to restore a NULL focus.
ImGuiContext& g = *GImGui;
if (g.CurrentWindow == g.NavWindow && g.NavLayer == 0)
if (g.CurrentWindow == g.NavWindow && g.NavLayer == 0 && !g.NavAnyRequest)
FocusTopMostWindowUnderOne(g.NavWindow, NULL);
End();
@@ -6242,7 +6242,7 @@ bool ImGui::BeginTabBar(const char* str_id, ImGuiTabBarFlags flags)
ImGuiID id = window->GetID(str_id);
ImGuiTabBar* tab_bar = g.TabBars.GetOrAddByKey(id);
ImRect tab_bar_bb = ImRect(window->DC.CursorPos.x, window->DC.CursorPos.y, window->InnerClipRect.Max.x, window->DC.CursorPos.y + g.FontSize + g.Style.FramePadding.y * 2);
ImRect tab_bar_bb = ImRect(window->DC.CursorPos.x, window->DC.CursorPos.y, window->InnerWorkRect.Max.x, window->DC.CursorPos.y + g.FontSize + g.Style.FramePadding.y * 2);
tab_bar->ID = id;
return BeginTabBarEx(tab_bar, tab_bar_bb, flags | ImGuiTabBarFlags_IsFocused);
}

View File

@@ -11,43 +11,62 @@ matrix:
compiler: gcc
env:
- GENERATOR="Unix Makefiles"
- ARTIFACT=gcc-trusty-64bit
- os: linux
dist: trusty
compiler: clang
env:
- GENERATOR="Unix Makefiles"
- ARTIFACT=clang-trusty-64bit
- os: osx
compiler: clang
osx_image: xcode10
env:
- GENERATOR="Unix Makefiles"
- ARTIFACT=clang-macos-64bit
- os: windows
before_install:
- choco install python3
- choco install python2
- export PATH="/c/Python27:/c/Python27/Scripts:$PATH"
- export PATH="/c/Python37:/c/Python37/Scripts:$PATH"
env:
- GENERATOR="Visual Studio 15 2017"
- ARTIFACT=vs2017-32bit
- os: windows
before_install:
- choco install python3
- choco install python2
- export PATH="/c/Python27:/c/Python27/Scripts:$PATH"
- export PATH="/c/Python37:/c/Python37/Scripts:$PATH"
env:
- GENERATOR="Visual Studio 15 2017 Win64"
- ARTIFACT=vs2017-64bit
before_script:
- ./checkout_glslang_spirv_tools.sh
- "./checkout_glslang_spirv_tools.sh"
script:
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then PYTHON3=$(which python); fi
- if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then PYTHON3=$(which python3); fi
- ./build_glslang_spirv_tools.sh Release
- "./build_glslang_spirv_tools.sh Release"
- mkdir build
- cd build
- cmake .. -DSPIRV_CROSS_SHARED=ON -DCMAKE_INSTALL_PREFIX=output -DCMAKE_BUILD_TYPE=Release -G "${GENERATOR}" -DPYTHON_EXECUTABLE:FILEPATH="${PYTHON3}" -DSPIRV_CROSS_ENABLE_TESTS=ON
- cmake --build . --config Release
- cmake --build . --config Release --target install
- ctest --verbose -C Release
- cd ..
before_deploy:
- REV=${ARTIFACT}-$(git rev-parse --short=10 HEAD)
- cd build/output
- tar cf spirv-cross-${REV}.tar *
- gzip spirv-cross-${REV}.tar
- cd ../..
- export FILE_TO_UPLOAD=build/output/spirv-cross-${REV}.tar.gz
deploy:
provider: releases
api_key:
secure: c7YEOyzhE19TFo76UnbLWk/kikRQxsHsOxzkOqN6Q2aL8joNRw5kmcG84rGd+Rf6isX62cykCzA6qHkyJCv9QTIzcyXnLju17rLvgib7cXDcseaq8x4mFvet2yUxCglthDpFY2M2LB0Aqws71lPeYIrKXa6hCFEh8jO3AWxnaor7O3RYfNZylM9d33HgH6KLT3sDx/cukwBstmKeg7EG9OUnrSvairkPW0W2+jlq3SXPlq/WeVhf8hQs3Yg0BluExGbmLOwe9EaeUpeGuJMyHRxXypnToQv1/KwoScKpap5tYxdNWiwRGZ4lYcmKrjAYVvilTioh654oX5LQpn34mE/oe8Ko9AaATkSaoiisRFp6meWtnB39oFBoL5Yn15DqLQpRXPr1AJsnBXSGAac3aDBO1j4MIqTHmYlYlfRw3n2ZsBaFaTZnv++438SNQ54nkivyoDTIWjoOmYa9+K4mQc3415RDdQmjZTJM+lu+GAlMmNBTVbfNvrbU55Usu9Lo6BZJKKdUMvdBB78kJ5FHvcBlL+eMgmk1pABQY0IZROCt7NztHcv1UmAxoWNxveSFs5glydPNNjNS8bogc4dzBGYG0KMmILbBHihVbY2toA1M9CMdDHdp+LucfDMmzECmYSEmlx0h8win+Jjb74/qpOhaXuUZ0NnzVgCOyeUYuMQ=
file: "${FILE_TO_UPLOAD}"
skip_cleanup: true
on:
tags: true

View File

@@ -265,10 +265,11 @@ if (SPIRV_CROSS_STATIC)
endif()
endif()
set(spirv-cross-abi-major 0)
set(spirv-cross-abi-minor 9)
set(spirv-cross-abi-patch 0)
if (SPIRV_CROSS_SHARED)
set(spirv-cross-abi-major 0)
set(spirv-cross-abi-minor 6)
set(spirv-cross-abi-patch 0)
set(SPIRV_CROSS_VERSION ${spirv-cross-abi-major}.${spirv-cross-abi-minor}.${spirv-cross-abi-patch})
set(SPIRV_CROSS_INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib)
set(SPIRV_CROSS_INSTALL_INC_DIR ${CMAKE_INSTALL_PREFIX}/include/spirv_cross)
@@ -431,7 +432,10 @@ if (SPIRV_CROSS_CLI)
target_compile_options(spirv-cross-c-api-test PRIVATE -std=c89 -Wall -Wextra)
endif()
add_test(NAME spirv-cross-c-api-test
COMMAND $<TARGET_FILE:spirv-cross-c-api-test> ${CMAKE_CURRENT_SOURCE_DIR}/tests-other/c_api_test.spv)
COMMAND $<TARGET_FILE:spirv-cross-c-api-test> ${CMAKE_CURRENT_SOURCE_DIR}/tests-other/c_api_test.spv
${spirv-cross-abi-major}
${spirv-cross-abi-minor}
${spirv-cross-abi-patch})
add_test(NAME spirv-cross-small-vector-test
COMMAND $<TARGET_FILE:spirv-cross-small-vector-test>)
add_test(NAME spirv-cross-test

View File

@@ -1,8 +1,8 @@
#!/bin/bash
GLSLANG_REV=ef807f4bc543e061f25dbbee6cb64dd5053b2adc
SPIRV_TOOLS_REV=12e4a7b649e6fe28683de9fc352200c82948a1f0
SPIRV_HEADERS_REV=111a25e4ae45e2b4d7c18415e1d6884712b958c4
GLSLANG_REV=e291f7a09f6733f6634fe077a228056fabee881e
SPIRV_TOOLS_REV=89fe836fe22c3e5c2a062ebeade012e2c2f0839b
SPIRV_HEADERS_REV=c4f8f65792d4bf2657ca751904c511bbcf2ac77b
if [ -z $PROTOCOL ]; then
PROTOCOL=git

View File

@@ -511,6 +511,7 @@ struct CLIArguments
bool msl_argument_buffers = false;
bool msl_texture_buffer_native = false;
bool glsl_emit_push_constant_as_ubo = false;
bool glsl_emit_ubo_as_plain_uniforms = false;
SmallVector<uint32_t> msl_discrete_descriptor_sets;
SmallVector<PLSArg> pls_in;
SmallVector<PLSArg> pls_out;
@@ -563,6 +564,7 @@ static void print_help()
"\t[--cpp]\n"
"\t[--cpp-interface-name <name>]\n"
"\t[--glsl-emit-push-constant-as-ubo]\n"
"\t[--glsl-emit-ubo-as-plain-uniforms]\n"
"\t[--msl]\n"
"\t[--msl-version <MMmmpp>]\n"
"\t[--msl-capture-output]\n"
@@ -854,6 +856,7 @@ static string compile_iteration(const CLIArguments &args, std::vector<uint32_t>
opts.vertex.flip_vert_y = args.yflip;
opts.vertex.support_nonzero_base_instance = args.support_nonzero_baseinstance;
opts.emit_push_constant_as_uniform_buffer = args.glsl_emit_push_constant_as_ubo;
opts.emit_uniform_buffer_as_plain_uniforms = args.glsl_emit_ubo_as_plain_uniforms;
compiler->set_common_options(opts);
// Set HLSL specific options.
@@ -1025,6 +1028,7 @@ static int main_inner(int argc, char *argv[])
cbs.add("--cpp-interface-name", [&args](CLIParser &parser) { args.cpp_interface_name = parser.next_string(); });
cbs.add("--metal", [&args](CLIParser &) { args.msl = true; }); // Legacy compatibility
cbs.add("--glsl-emit-push-constant-as-ubo", [&args](CLIParser &) { args.glsl_emit_push_constant_as_ubo = true; });
cbs.add("--glsl-emit-ubo-as-plain-uniforms", [&args](CLIParser &) { args.glsl_emit_ubo_as_plain_uniforms = true; });
cbs.add("--msl", [&args](CLIParser &) { args.msl = true; });
cbs.add("--hlsl", [&args](CLIParser &) { args.hlsl = true; });
cbs.add("--hlsl-enable-compat", [&args](CLIParser &) { args.hlsl_compat = true; });

View File

@@ -0,0 +1,15 @@
RWByteAddressBuffer _11 : register(u1);
void comp_main()
{
uint _14;
_11.GetDimensions(_14);
_14 = (_14 - 16) / 16;
_11.Store(0, uint(int(_14)));
}
[numthreads(1, 1, 1)]
void main()
{
comp_main();
}

View File

@@ -0,0 +1,46 @@
struct UBO_1_1
{
float4 v[64];
};
ConstantBuffer<UBO_1_1> ubos[] : register(b0, space3);
ByteAddressBuffer ssbos[] : register(t0, space4);
Texture2D<float4> uSamplers[] : register(t0, space0);
SamplerState uSamps[] : register(s0, space2);
Texture2D<float4> uCombinedSamplers[] : register(t0, space1);
SamplerState _uCombinedSamplers_sampler[] : register(s0, space1);
static int vIndex;
static float4 FragColor;
static float2 vUV;
struct SPIRV_Cross_Input
{
nointerpolation int vIndex : TEXCOORD0;
float2 vUV : TEXCOORD1;
};
struct SPIRV_Cross_Output
{
float4 FragColor : SV_Target0;
};
void frag_main()
{
int _22 = vIndex + 10;
int _32 = vIndex + 40;
FragColor = uSamplers[NonUniformResourceIndex(_22)].Sample(uSamps[NonUniformResourceIndex(_32)], vUV);
FragColor = uCombinedSamplers[NonUniformResourceIndex(_22)].Sample(_uCombinedSamplers_sampler[NonUniformResourceIndex(_22)], vUV);
FragColor += ubos[NonUniformResourceIndex(vIndex + 20)].v[_32];
FragColor += asfloat(ssbos[NonUniformResourceIndex(vIndex + 50)].Load4((vIndex + 60) * 16 + 0));
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
vIndex = stage_input.vIndex;
vUV = stage_input.vUV;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@@ -8,13 +8,15 @@ constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(4u, 1u, 1u);
kernel void main0()
{
threadgroup_barrier(mem_flags::mem_threadgroup);
threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture);
threadgroup_barrier(mem_flags::mem_texture);
threadgroup_barrier(mem_flags::mem_device);
threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture);
threadgroup_barrier(mem_flags::mem_threadgroup);
threadgroup_barrier(mem_flags::mem_none);
threadgroup_barrier(mem_flags::mem_threadgroup);
threadgroup_barrier(mem_flags::mem_threadgroup);
threadgroup_barrier(mem_flags::mem_threadgroup);
threadgroup_barrier(mem_flags::mem_none);
threadgroup_barrier(mem_flags::mem_threadgroup);
threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture);
threadgroup_barrier(mem_flags::mem_texture);
threadgroup_barrier(mem_flags::mem_device);
threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture);
threadgroup_barrier(mem_flags::mem_threadgroup);
}

View File

@@ -5,11 +5,6 @@
using namespace metal;
struct spvAux
{
uint swizzleConst[1];
};
enum class spvSwizzle : uint
{
none = 0,
@@ -130,9 +125,9 @@ inline vec<T, 4> spvGatherCompareSwizzle(sampler s, const thread Tex& t, Ts... p
return t.gather_compare(s, spvForward<Ts>(params)...);
}
kernel void main0(constant spvAux& spvAuxBuffer [[buffer(30)]], texture2d<float> foo [[texture(0)]], texture2d<float, access::write> bar [[texture(1)]], sampler fooSmplr [[sampler(0)]])
kernel void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture2d<float> foo [[texture(0)]], texture2d<float, access::write> bar [[texture(1)]], sampler fooSmplr [[sampler(0)]])
{
constant uint32_t& fooSwzl = spvAuxBuffer.swizzleConst[0];
constant uint32_t& fooSwzl = spvSwizzleConstants[0];
bar.write(spvTextureSwizzle(foo.sample(fooSmplr, float2(1.0), level(0.0)), fooSwzl), uint2(int2(0)));
}

View File

@@ -0,0 +1,156 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct spvDescriptorSetBuffer0
{
constant uint* spvSwizzleConstants [[id(0)]];
array<texture2d<float>, 4> uSampler0 [[id(1)]];
array<sampler, 4> uSampler0Smplr [[id(5)]];
};
struct main0_out
{
float4 FragColor [[color(0)]];
};
struct main0_in
{
float2 vUV [[user(locn0)]];
};
enum class spvSwizzle : uint
{
none = 0,
zero,
one,
red,
green,
blue,
alpha
};
template<typename T> struct spvRemoveReference { typedef T type; };
template<typename T> struct spvRemoveReference<thread T&> { typedef T type; };
template<typename T> struct spvRemoveReference<thread T&&> { typedef T type; };
template<typename T> inline constexpr thread T&& spvForward(thread typename spvRemoveReference<T>::type& x)
{
return static_cast<thread T&&>(x);
}
template<typename T> inline constexpr thread T&& spvForward(thread typename spvRemoveReference<T>::type&& x)
{
return static_cast<thread T&&>(x);
}
template<typename T>
inline T spvGetSwizzle(vec<T, 4> x, T c, spvSwizzle s)
{
switch (s)
{
case spvSwizzle::none:
return c;
case spvSwizzle::zero:
return 0;
case spvSwizzle::one:
return 1;
case spvSwizzle::red:
return x.r;
case spvSwizzle::green:
return x.g;
case spvSwizzle::blue:
return x.b;
case spvSwizzle::alpha:
return x.a;
}
}
// Wrapper function that swizzles texture samples and fetches.
template<typename T>
inline vec<T, 4> spvTextureSwizzle(vec<T, 4> x, uint s)
{
if (!s)
return x;
return vec<T, 4>(spvGetSwizzle(x, x.r, spvSwizzle((s >> 0) & 0xFF)), spvGetSwizzle(x, x.g, spvSwizzle((s >> 8) & 0xFF)), spvGetSwizzle(x, x.b, spvSwizzle((s >> 16) & 0xFF)), spvGetSwizzle(x, x.a, spvSwizzle((s >> 24) & 0xFF)));
}
template<typename T>
inline T spvTextureSwizzle(T x, uint s)
{
return spvTextureSwizzle(vec<T, 4>(x, 0, 0, 1), s).x;
}
// Wrapper function that swizzles texture gathers.
template<typename T, typename Tex, typename... Ts>
inline vec<T, 4> spvGatherSwizzle(sampler s, const thread Tex& t, Ts... params, component c, uint sw) METAL_CONST_ARG(c)
{
if (sw)
{
switch (spvSwizzle((sw >> (uint(c) * 8)) & 0xFF))
{
case spvSwizzle::none:
break;
case spvSwizzle::zero:
return vec<T, 4>(0, 0, 0, 0);
case spvSwizzle::one:
return vec<T, 4>(1, 1, 1, 1);
case spvSwizzle::red:
return t.gather(s, spvForward<Ts>(params)..., component::x);
case spvSwizzle::green:
return t.gather(s, spvForward<Ts>(params)..., component::y);
case spvSwizzle::blue:
return t.gather(s, spvForward<Ts>(params)..., component::z);
case spvSwizzle::alpha:
return t.gather(s, spvForward<Ts>(params)..., component::w);
}
}
switch (c)
{
case component::x:
return t.gather(s, spvForward<Ts>(params)..., component::x);
case component::y:
return t.gather(s, spvForward<Ts>(params)..., component::y);
case component::z:
return t.gather(s, spvForward<Ts>(params)..., component::z);
case component::w:
return t.gather(s, spvForward<Ts>(params)..., component::w);
}
}
// Wrapper function that swizzles depth texture gathers.
template<typename T, typename Tex, typename... Ts>
inline vec<T, 4> spvGatherCompareSwizzle(sampler s, const thread Tex& t, Ts... params, uint sw)
{
if (sw)
{
switch (spvSwizzle(sw & 0xFF))
{
case spvSwizzle::none:
case spvSwizzle::red:
break;
case spvSwizzle::zero:
case spvSwizzle::green:
case spvSwizzle::blue:
case spvSwizzle::alpha:
return vec<T, 4>(0, 0, 0, 0);
case spvSwizzle::one:
return vec<T, 4>(1, 1, 1, 1);
}
}
return t.gather_compare(s, spvForward<Ts>(params)...);
}
fragment main0_out main0(main0_in in [[stage_in]], constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], constant uint* spvSwizzleConstants [[buffer(30)]], texture2d<float> uSampler1 [[texture(0)]], sampler uSampler1Smplr [[sampler(0)]])
{
main0_out out = {};
constant uint32_t* spvDescriptorSet0_uSampler0Swzl = &spvDescriptorSet0.spvSwizzleConstants[1];
constant uint32_t& uSampler1Swzl = spvSwizzleConstants[0];
out.FragColor = spvTextureSwizzle(spvDescriptorSet0.uSampler0[2].sample(spvDescriptorSet0.uSampler0Smplr[2], in.vUV), spvDescriptorSet0_uSampler0Swzl[2]);
out.FragColor += spvTextureSwizzle(uSampler1.sample(uSampler1Smplr, in.vUV), uSampler1Swzl);
out.FragColor += spvTextureSwizzle(spvDescriptorSet0.uSampler0[1].sample(spvDescriptorSet0.uSampler0Smplr[1], in.vUV), spvDescriptorSet0_uSampler0Swzl[1]);
out.FragColor += spvTextureSwizzle(uSampler1.sample(uSampler1Smplr, in.vUV), uSampler1Swzl);
return out;
}

View File

@@ -0,0 +1,146 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 FragColor [[color(0)]];
};
struct main0_in
{
float2 vUV [[user(locn0)]];
};
enum class spvSwizzle : uint
{
none = 0,
zero,
one,
red,
green,
blue,
alpha
};
template<typename T> struct spvRemoveReference { typedef T type; };
template<typename T> struct spvRemoveReference<thread T&> { typedef T type; };
template<typename T> struct spvRemoveReference<thread T&&> { typedef T type; };
template<typename T> inline constexpr thread T&& spvForward(thread typename spvRemoveReference<T>::type& x)
{
return static_cast<thread T&&>(x);
}
template<typename T> inline constexpr thread T&& spvForward(thread typename spvRemoveReference<T>::type&& x)
{
return static_cast<thread T&&>(x);
}
template<typename T>
inline T spvGetSwizzle(vec<T, 4> x, T c, spvSwizzle s)
{
switch (s)
{
case spvSwizzle::none:
return c;
case spvSwizzle::zero:
return 0;
case spvSwizzle::one:
return 1;
case spvSwizzle::red:
return x.r;
case spvSwizzle::green:
return x.g;
case spvSwizzle::blue:
return x.b;
case spvSwizzle::alpha:
return x.a;
}
}
// Wrapper function that swizzles texture samples and fetches.
template<typename T>
inline vec<T, 4> spvTextureSwizzle(vec<T, 4> x, uint s)
{
if (!s)
return x;
return vec<T, 4>(spvGetSwizzle(x, x.r, spvSwizzle((s >> 0) & 0xFF)), spvGetSwizzle(x, x.g, spvSwizzle((s >> 8) & 0xFF)), spvGetSwizzle(x, x.b, spvSwizzle((s >> 16) & 0xFF)), spvGetSwizzle(x, x.a, spvSwizzle((s >> 24) & 0xFF)));
}
template<typename T>
inline T spvTextureSwizzle(T x, uint s)
{
return spvTextureSwizzle(vec<T, 4>(x, 0, 0, 1), s).x;
}
// Wrapper function that swizzles texture gathers.
template<typename T, typename Tex, typename... Ts>
inline vec<T, 4> spvGatherSwizzle(sampler s, const thread Tex& t, Ts... params, component c, uint sw) METAL_CONST_ARG(c)
{
if (sw)
{
switch (spvSwizzle((sw >> (uint(c) * 8)) & 0xFF))
{
case spvSwizzle::none:
break;
case spvSwizzle::zero:
return vec<T, 4>(0, 0, 0, 0);
case spvSwizzle::one:
return vec<T, 4>(1, 1, 1, 1);
case spvSwizzle::red:
return t.gather(s, spvForward<Ts>(params)..., component::x);
case spvSwizzle::green:
return t.gather(s, spvForward<Ts>(params)..., component::y);
case spvSwizzle::blue:
return t.gather(s, spvForward<Ts>(params)..., component::z);
case spvSwizzle::alpha:
return t.gather(s, spvForward<Ts>(params)..., component::w);
}
}
switch (c)
{
case component::x:
return t.gather(s, spvForward<Ts>(params)..., component::x);
case component::y:
return t.gather(s, spvForward<Ts>(params)..., component::y);
case component::z:
return t.gather(s, spvForward<Ts>(params)..., component::z);
case component::w:
return t.gather(s, spvForward<Ts>(params)..., component::w);
}
}
// Wrapper function that swizzles depth texture gathers.
template<typename T, typename Tex, typename... Ts>
inline vec<T, 4> spvGatherCompareSwizzle(sampler s, const thread Tex& t, Ts... params, uint sw)
{
if (sw)
{
switch (spvSwizzle(sw & 0xFF))
{
case spvSwizzle::none:
case spvSwizzle::red:
break;
case spvSwizzle::zero:
case spvSwizzle::green:
case spvSwizzle::blue:
case spvSwizzle::alpha:
return vec<T, 4>(0, 0, 0, 0);
case spvSwizzle::one:
return vec<T, 4>(1, 1, 1, 1);
}
}
return t.gather_compare(s, spvForward<Ts>(params)...);
}
fragment main0_out main0(main0_in in [[stage_in]], constant uint* spvSwizzleConstants [[buffer(30)]], array<texture2d<float>, 4> uSampler [[texture(0)]], array<sampler, 4> uSamplerSmplr [[sampler(0)]])
{
main0_out out = {};
constant uint32_t* uSamplerSwzl = &spvSwizzleConstants[0];
out.FragColor = spvTextureSwizzle(uSampler[2].sample(uSamplerSmplr[2], in.vUV), uSamplerSwzl[2]);
out.FragColor += spvTextureSwizzle(uSampler[1].sample(uSamplerSmplr[1], in.vUV), uSamplerSwzl[1]);
return out;
}

View File

@@ -0,0 +1,50 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct UBO
{
float4 v[64];
};
struct SSBO
{
float4 v[1];
};
struct main0_out
{
float4 FragColor [[color(0)]];
};
struct main0_in
{
int vIndex [[user(locn0)]];
float2 vUV [[user(locn1)]];
};
fragment main0_out main0(main0_in in [[stage_in]], constant UBO* ubos_0 [[buffer(0)]], constant UBO* ubos_1 [[buffer(1)]], const device SSBO* ssbos_0 [[buffer(2)]], const device SSBO* ssbos_1 [[buffer(3)]], array<texture2d<float>, 8> uSamplers [[texture(0)]], array<texture2d<float>, 8> uCombinedSamplers [[texture(8)]], array<sampler, 7> uSamps [[sampler(1)]], array<sampler, 8> uCombinedSamplersSmplr [[sampler(8)]])
{
constant UBO* ubos[] =
{
ubos_0,
ubos_1,
};
const device SSBO* ssbos[] =
{
ssbos_0,
ssbos_1,
};
main0_out out = {};
int _24 = in.vIndex + 10;
int _35 = in.vIndex + 40;
out.FragColor = uSamplers[_24].sample(uSamps[_35], in.vUV);
out.FragColor = uCombinedSamplers[_24].sample(uCombinedSamplersSmplr[_24], in.vUV);
out.FragColor += ubos[(in.vIndex + 20)]->v[_35];
out.FragColor += ssbos[(in.vIndex + 50)]->v[in.vIndex + 60];
return out;
}

View File

@@ -0,0 +1,92 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct SSBO
{
float FragColor;
};
inline uint4 spvSubgroupBallot(bool value)
{
simd_vote vote = simd_ballot(value);
// simd_ballot() returns a 64-bit integer-like object, but
// SPIR-V callers expect a uint4. We must convert.
// FIXME: This won't include higher bits if Apple ever supports
// 128 lanes in an SIMD-group.
return uint4((uint)((simd_vote::vote_t)vote & 0xFFFFFFFF), (uint)(((simd_vote::vote_t)vote >> 32) & 0xFFFFFFFF), 0, 0);
}
inline bool spvSubgroupBallotBitExtract(uint4 ballot, uint bit)
{
return !!extract_bits(ballot[bit / 32], bit % 32, 1);
}
inline uint spvSubgroupBallotFindLSB(uint4 ballot)
{
return select(ctz(ballot.x), select(32 + ctz(ballot.y), select(64 + ctz(ballot.z), select(96 + ctz(ballot.w), uint(-1), ballot.w == 0), ballot.z == 0), ballot.y == 0), ballot.x == 0);
}
inline uint spvSubgroupBallotFindMSB(uint4 ballot)
{
return select(128 - (clz(ballot.w) + 1), select(96 - (clz(ballot.z) + 1), select(64 - (clz(ballot.y) + 1), select(32 - (clz(ballot.x) + 1), uint(-1), ballot.x == 0), ballot.y == 0), ballot.z == 0), ballot.w == 0);
}
inline uint spvSubgroupBallotBitCount(uint4 ballot)
{
return popcount(ballot.x) + popcount(ballot.y) + popcount(ballot.z) + popcount(ballot.w);
}
inline uint spvSubgroupBallotInclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID)
{
uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID + 1, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0)), uint2(0));
return spvSubgroupBallotBitCount(ballot & mask);
}
inline uint spvSubgroupBallotExclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID)
{
uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID - 32, 0)), uint2(0));
return spvSubgroupBallotBitCount(ballot & mask);
}
template<typename T>
inline bool spvSubgroupAllEqual(T value)
{
return simd_all(value == simd_broadcast_first(value));
}
template<>
inline bool spvSubgroupAllEqual(bool value)
{
return simd_all(value) || !simd_any(value);
}
kernel void main0(device SSBO& _9 [[buffer(0)]], uint gl_NumSubgroups [[simdgroups_per_threadgroup]], uint gl_SubgroupID [[simdgroup_index_in_threadgroup]], uint gl_SubgroupSize [[thread_execution_width]], uint gl_SubgroupInvocationID [[thread_index_in_simdgroup]])
{
uint4 gl_SubgroupEqMask = 27 > 32 ? uint4(0, (1 << (gl_SubgroupInvocationID - 32)), uint2(0)) : uint4(1 << gl_SubgroupInvocationID, uint3(0));
uint4 gl_SubgroupGeMask = uint4(extract_bits(0xFFFFFFFF, min(gl_SubgroupInvocationID, 32u), (uint)max(min((int)gl_SubgroupSize, 32) - (int)gl_SubgroupInvocationID, 0)), extract_bits(0xFFFFFFFF, (uint)max((int)gl_SubgroupInvocationID - 32, 0), (uint)max((int)gl_SubgroupSize - (int)max(gl_SubgroupInvocationID, 32u), 0)), uint2(0));
uint4 gl_SubgroupGtMask = uint4(extract_bits(0xFFFFFFFF, min(gl_SubgroupInvocationID + 1, 32u), (uint)max(min((int)gl_SubgroupSize, 32) - (int)gl_SubgroupInvocationID - 1, 0)), extract_bits(0xFFFFFFFF, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0), (uint)max((int)gl_SubgroupSize - (int)max(gl_SubgroupInvocationID + 1, 32u), 0)), uint2(0));
uint4 gl_SubgroupLeMask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID + 1, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0)), uint2(0));
uint4 gl_SubgroupLtMask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID - 32, 0)), uint2(0));
_9.FragColor = float(gl_NumSubgroups);
_9.FragColor = float(gl_SubgroupID);
_9.FragColor = float(gl_SubgroupSize);
_9.FragColor = float(gl_SubgroupInvocationID);
simdgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture);
simdgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture);
simdgroup_barrier(mem_flags::mem_device);
simdgroup_barrier(mem_flags::mem_threadgroup);
simdgroup_barrier(mem_flags::mem_texture);
_9.FragColor = float4(gl_SubgroupEqMask).x;
_9.FragColor = float4(gl_SubgroupGeMask).x;
_9.FragColor = float4(gl_SubgroupGtMask).x;
_9.FragColor = float4(gl_SubgroupLeMask).x;
_9.FragColor = float4(gl_SubgroupLtMask).x;
uint4 _83 = spvSubgroupBallot(true);
float4 _165 = simd_prefix_inclusive_product(simd_product(float4(20.0)));
int4 _167 = simd_prefix_inclusive_product(simd_product(int4(20)));
}

View File

@@ -0,0 +1,23 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct SSBO
{
float FragColor;
};
kernel void main0(device SSBO& _9 [[buffer(0)]], uint gl_NumSubgroups [[quadgroups_per_threadgroup]], uint gl_SubgroupID [[quadgroup_index_in_threadgroup]], uint gl_SubgroupSize [[thread_execution_width]], uint gl_SubgroupInvocationID [[thread_index_in_quadgroup]])
{
_9.FragColor = float(gl_NumSubgroups);
_9.FragColor = float(gl_SubgroupID);
_9.FragColor = float(gl_SubgroupSize);
_9.FragColor = float(gl_SubgroupInvocationID);
simdgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture);
simdgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture);
simdgroup_barrier(mem_flags::mem_device);
simdgroup_barrier(mem_flags::mem_threadgroup);
simdgroup_barrier(mem_flags::mem_texture);
}

View File

@@ -0,0 +1,14 @@
#version 450
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 1, std140) buffer SSBO
{
uint size;
float v[];
} _11;
void main()
{
_11.size = uint(int(uint(_11.v.length())));
}

View File

@@ -0,0 +1,26 @@
#version 450
#extension GL_EXT_buffer_reference : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(buffer_reference) buffer PtrUint;
layout(buffer_reference) buffer PtrInt;
layout(buffer_reference, std430) buffer PtrUint
{
uint value;
};
layout(buffer_reference, std430) buffer PtrInt
{
int value;
};
layout(set = 0, binding = 0, std430) buffer Buf
{
PtrUint ptr;
} _11;
void main()
{
PtrInt(_11.ptr).value = 10;
}

View File

@@ -0,0 +1,15 @@
RWByteAddressBuffer _11 : register(u1);
void comp_main()
{
uint _14;
_11.GetDimensions(_14);
_14 = (_14 - 16) / 16;
_11.Store(0, uint(int(_14)));
}
[numthreads(1, 1, 1)]
void main()
{
comp_main();
}

View File

@@ -0,0 +1,46 @@
struct UBO_1_1
{
float4 v[64];
};
ConstantBuffer<UBO_1_1> ubos[] : register(b0, space3);
ByteAddressBuffer ssbos[] : register(t0, space4);
Texture2D<float4> uSamplers[] : register(t0, space0);
SamplerState uSamps[] : register(s0, space2);
Texture2D<float4> uCombinedSamplers[] : register(t0, space1);
SamplerState _uCombinedSamplers_sampler[] : register(s0, space1);
static int vIndex;
static float4 FragColor;
static float2 vUV;
struct SPIRV_Cross_Input
{
nointerpolation int vIndex : TEXCOORD0;
float2 vUV : TEXCOORD1;
};
struct SPIRV_Cross_Output
{
float4 FragColor : SV_Target0;
};
void frag_main()
{
int i = vIndex;
FragColor = uSamplers[NonUniformResourceIndex(i + 10)].Sample(uSamps[NonUniformResourceIndex(i + 40)], vUV);
int _47 = i + 10;
FragColor = uCombinedSamplers[NonUniformResourceIndex(_47)].Sample(_uCombinedSamplers_sampler[NonUniformResourceIndex(_47)], vUV);
FragColor += ubos[NonUniformResourceIndex(i + 20)].v[i + 40];
FragColor += asfloat(ssbos[NonUniformResourceIndex(i + 50)].Load4((i + 60) * 16 + 0));
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
vIndex = stage_input.vIndex;
vUV = stage_input.vUV;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@@ -5,11 +5,6 @@
using namespace metal;
struct spvAux
{
uint swizzleConst[1];
};
// Returns 2D texture coords corresponding to 1D texel buffer coords
uint2 spvTexelBufferCoord(uint tc)
{
@@ -136,18 +131,18 @@ inline vec<T, 4> spvGatherCompareSwizzle(sampler s, const thread Tex& t, Ts... p
return t.gather_compare(s, spvForward<Ts>(params)...);
}
fragment void main0(constant spvAux& spvAuxBuffer [[buffer(30)]], texture1d<float> tex1d [[texture(0)]], texture2d<float> tex2d [[texture(1)]], texture3d<float> tex3d [[texture(2)]], texturecube<float> texCube [[texture(3)]], texture2d_array<float> tex2dArray [[texture(4)]], texturecube_array<float> texCubeArray [[texture(5)]], texture2d<float> texBuffer [[texture(6)]], depth2d<float> depth2d [[texture(7)]], depthcube<float> depthCube [[texture(8)]], depth2d_array<float> depth2dArray [[texture(9)]], depthcube_array<float> depthCubeArray [[texture(10)]], sampler tex1dSamp [[sampler(0)]], sampler tex2dSamp [[sampler(1)]], sampler tex3dSamp [[sampler(2)]], sampler texCubeSamp [[sampler(3)]], sampler tex2dArraySamp [[sampler(4)]], sampler texCubeArraySamp [[sampler(5)]], sampler depth2dSamp [[sampler(7)]], sampler depthCubeSamp [[sampler(8)]], sampler depth2dArraySamp [[sampler(9)]], sampler depthCubeArraySamp [[sampler(10)]])
fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d<float> tex1d [[texture(0)]], texture2d<float> tex2d [[texture(1)]], texture3d<float> tex3d [[texture(2)]], texturecube<float> texCube [[texture(3)]], texture2d_array<float> tex2dArray [[texture(4)]], texturecube_array<float> texCubeArray [[texture(5)]], texture2d<float> texBuffer [[texture(6)]], depth2d<float> depth2d [[texture(7)]], depthcube<float> depthCube [[texture(8)]], depth2d_array<float> depth2dArray [[texture(9)]], depthcube_array<float> depthCubeArray [[texture(10)]], sampler tex1dSamp [[sampler(0)]], sampler tex2dSamp [[sampler(1)]], sampler tex3dSamp [[sampler(2)]], sampler texCubeSamp [[sampler(3)]], sampler tex2dArraySamp [[sampler(4)]], sampler texCubeArraySamp [[sampler(5)]], sampler depth2dSamp [[sampler(7)]], sampler depthCubeSamp [[sampler(8)]], sampler depth2dArraySamp [[sampler(9)]], sampler depthCubeArraySamp [[sampler(10)]])
{
constant uint32_t& tex1dSwzl = spvAuxBuffer.swizzleConst[0];
constant uint32_t& tex2dSwzl = spvAuxBuffer.swizzleConst[1];
constant uint32_t& tex3dSwzl = spvAuxBuffer.swizzleConst[2];
constant uint32_t& texCubeSwzl = spvAuxBuffer.swizzleConst[3];
constant uint32_t& tex2dArraySwzl = spvAuxBuffer.swizzleConst[4];
constant uint32_t& texCubeArraySwzl = spvAuxBuffer.swizzleConst[5];
constant uint32_t& depth2dSwzl = spvAuxBuffer.swizzleConst[7];
constant uint32_t& depthCubeSwzl = spvAuxBuffer.swizzleConst[8];
constant uint32_t& depth2dArraySwzl = spvAuxBuffer.swizzleConst[9];
constant uint32_t& depthCubeArraySwzl = spvAuxBuffer.swizzleConst[10];
constant uint32_t& tex1dSwzl = spvSwizzleConstants[0];
constant uint32_t& tex2dSwzl = spvSwizzleConstants[1];
constant uint32_t& tex3dSwzl = spvSwizzleConstants[2];
constant uint32_t& texCubeSwzl = spvSwizzleConstants[3];
constant uint32_t& tex2dArraySwzl = spvSwizzleConstants[4];
constant uint32_t& texCubeArraySwzl = spvSwizzleConstants[5];
constant uint32_t& depth2dSwzl = spvSwizzleConstants[7];
constant uint32_t& depthCubeSwzl = spvSwizzleConstants[8];
constant uint32_t& depth2dArraySwzl = spvSwizzleConstants[9];
constant uint32_t& depthCubeArraySwzl = spvSwizzleConstants[10];
float4 c = spvTextureSwizzle(tex1d.sample(tex1dSamp, 0.0), tex1dSwzl);
c = spvTextureSwizzle(tex2d.sample(tex2dSamp, float2(0.0)), tex2dSwzl);
c = spvTextureSwizzle(tex3d.sample(tex3dSamp, float3(0.0)), tex3dSwzl);

View File

@@ -5,11 +5,6 @@
using namespace metal;
struct spvAux
{
uint swizzleConst[1];
};
// Returns 2D texture coords corresponding to 1D texel buffer coords
uint2 spvTexelBufferCoord(uint tc)
{
@@ -136,14 +131,14 @@ inline vec<T, 4> spvGatherCompareSwizzle(sampler s, const thread Tex& t, Ts... p
return t.gather_compare(s, spvForward<Ts>(params)...);
}
fragment void main0(constant spvAux& spvAuxBuffer [[buffer(30)]], texture1d<int> tex1d [[texture(0)]], texture2d<int> tex2d [[texture(1)]], texture3d<int> tex3d [[texture(2)]], texturecube<int> texCube [[texture(3)]], texture2d_array<int> tex2dArray [[texture(4)]], texturecube_array<int> texCubeArray [[texture(5)]], texture2d<int> texBuffer [[texture(6)]], sampler tex1dSmplr [[sampler(0)]], sampler tex2dSmplr [[sampler(1)]], sampler tex3dSmplr [[sampler(2)]], sampler texCubeSmplr [[sampler(3)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]])
fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d<int> tex1d [[texture(0)]], texture2d<int> tex2d [[texture(1)]], texture3d<int> tex3d [[texture(2)]], texturecube<int> texCube [[texture(3)]], texture2d_array<int> tex2dArray [[texture(4)]], texturecube_array<int> texCubeArray [[texture(5)]], texture2d<int> texBuffer [[texture(6)]], sampler tex1dSmplr [[sampler(0)]], sampler tex2dSmplr [[sampler(1)]], sampler tex3dSmplr [[sampler(2)]], sampler texCubeSmplr [[sampler(3)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]])
{
constant uint32_t& tex1dSwzl = spvAuxBuffer.swizzleConst[0];
constant uint32_t& tex2dSwzl = spvAuxBuffer.swizzleConst[1];
constant uint32_t& tex3dSwzl = spvAuxBuffer.swizzleConst[2];
constant uint32_t& texCubeSwzl = spvAuxBuffer.swizzleConst[3];
constant uint32_t& tex2dArraySwzl = spvAuxBuffer.swizzleConst[4];
constant uint32_t& texCubeArraySwzl = spvAuxBuffer.swizzleConst[5];
constant uint32_t& tex1dSwzl = spvSwizzleConstants[0];
constant uint32_t& tex2dSwzl = spvSwizzleConstants[1];
constant uint32_t& tex3dSwzl = spvSwizzleConstants[2];
constant uint32_t& texCubeSwzl = spvSwizzleConstants[3];
constant uint32_t& tex2dArraySwzl = spvSwizzleConstants[4];
constant uint32_t& texCubeArraySwzl = spvSwizzleConstants[5];
float4 c = float4(spvTextureSwizzle(tex1d.sample(tex1dSmplr, 0.0), tex1dSwzl));
c = float4(spvTextureSwizzle(tex2d.sample(tex2dSmplr, float2(0.0)), tex2dSwzl));
c = float4(spvTextureSwizzle(tex3d.sample(tex3dSmplr, float3(0.0)), tex3dSwzl));

View File

@@ -5,11 +5,6 @@
using namespace metal;
struct spvAux
{
uint swizzleConst[1];
};
// Returns 2D texture coords corresponding to 1D texel buffer coords
uint2 spvTexelBufferCoord(uint tc)
{
@@ -183,18 +178,18 @@ float4 doSwizzle(thread texture1d<float> tex1d, thread const sampler tex1dSmplr,
return c;
}
fragment void main0(constant spvAux& spvAuxBuffer [[buffer(30)]], texture1d<float> tex1d [[texture(0)]], texture2d<float> tex2d [[texture(1)]], texture3d<float> tex3d [[texture(2)]], texturecube<float> texCube [[texture(3)]], texture2d_array<float> tex2dArray [[texture(4)]], texturecube_array<float> texCubeArray [[texture(5)]], texture2d<float> texBuffer [[texture(6)]], depth2d<float> depth2d [[texture(7)]], depthcube<float> depthCube [[texture(8)]], depth2d_array<float> depth2dArray [[texture(9)]], depthcube_array<float> depthCubeArray [[texture(10)]], sampler tex1dSmplr [[sampler(0)]], sampler tex2dSmplr [[sampler(1)]], sampler tex3dSmplr [[sampler(2)]], sampler texCubeSmplr [[sampler(3)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]], sampler depth2dSmplr [[sampler(7)]], sampler depthCubeSmplr [[sampler(8)]], sampler depth2dArraySmplr [[sampler(9)]], sampler depthCubeArraySmplr [[sampler(10)]])
fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d<float> tex1d [[texture(0)]], texture2d<float> tex2d [[texture(1)]], texture3d<float> tex3d [[texture(2)]], texturecube<float> texCube [[texture(3)]], texture2d_array<float> tex2dArray [[texture(4)]], texturecube_array<float> texCubeArray [[texture(5)]], texture2d<float> texBuffer [[texture(6)]], depth2d<float> depth2d [[texture(7)]], depthcube<float> depthCube [[texture(8)]], depth2d_array<float> depth2dArray [[texture(9)]], depthcube_array<float> depthCubeArray [[texture(10)]], sampler tex1dSmplr [[sampler(0)]], sampler tex2dSmplr [[sampler(1)]], sampler tex3dSmplr [[sampler(2)]], sampler texCubeSmplr [[sampler(3)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]], sampler depth2dSmplr [[sampler(7)]], sampler depthCubeSmplr [[sampler(8)]], sampler depth2dArraySmplr [[sampler(9)]], sampler depthCubeArraySmplr [[sampler(10)]])
{
constant uint32_t& tex1dSwzl = spvAuxBuffer.swizzleConst[0];
constant uint32_t& tex2dSwzl = spvAuxBuffer.swizzleConst[1];
constant uint32_t& tex3dSwzl = spvAuxBuffer.swizzleConst[2];
constant uint32_t& texCubeSwzl = spvAuxBuffer.swizzleConst[3];
constant uint32_t& tex2dArraySwzl = spvAuxBuffer.swizzleConst[4];
constant uint32_t& texCubeArraySwzl = spvAuxBuffer.swizzleConst[5];
constant uint32_t& depth2dSwzl = spvAuxBuffer.swizzleConst[7];
constant uint32_t& depthCubeSwzl = spvAuxBuffer.swizzleConst[8];
constant uint32_t& depth2dArraySwzl = spvAuxBuffer.swizzleConst[9];
constant uint32_t& depthCubeArraySwzl = spvAuxBuffer.swizzleConst[10];
constant uint32_t& tex1dSwzl = spvSwizzleConstants[0];
constant uint32_t& tex2dSwzl = spvSwizzleConstants[1];
constant uint32_t& tex3dSwzl = spvSwizzleConstants[2];
constant uint32_t& texCubeSwzl = spvSwizzleConstants[3];
constant uint32_t& tex2dArraySwzl = spvSwizzleConstants[4];
constant uint32_t& texCubeArraySwzl = spvSwizzleConstants[5];
constant uint32_t& depth2dSwzl = spvSwizzleConstants[7];
constant uint32_t& depthCubeSwzl = spvSwizzleConstants[8];
constant uint32_t& depth2dArraySwzl = spvSwizzleConstants[9];
constant uint32_t& depthCubeArraySwzl = spvSwizzleConstants[10];
float4 c = doSwizzle(tex1d, tex1dSmplr, tex1dSwzl, tex2d, tex2dSmplr, tex2dSwzl, tex3d, tex3dSmplr, tex3dSwzl, texCube, texCubeSmplr, texCubeSwzl, tex2dArray, tex2dArraySmplr, tex2dArraySwzl, texCubeArray, texCubeArraySmplr, texCubeArraySwzl, depth2d, depth2dSmplr, depth2dSwzl, depthCube, depthCubeSmplr, depthCubeSwzl, depth2dArray, depth2dArraySmplr, depth2dArraySwzl, depthCubeArray, depthCubeArraySmplr, depthCubeArraySwzl, texBuffer);
}

View File

@@ -5,11 +5,6 @@
using namespace metal;
struct spvAux
{
uint swizzleConst[1];
};
// Returns 2D texture coords corresponding to 1D texel buffer coords
uint2 spvTexelBufferCoord(uint tc)
{
@@ -136,14 +131,14 @@ inline vec<T, 4> spvGatherCompareSwizzle(sampler s, const thread Tex& t, Ts... p
return t.gather_compare(s, spvForward<Ts>(params)...);
}
fragment void main0(constant spvAux& spvAuxBuffer [[buffer(30)]], texture1d<uint> tex1d [[texture(0)]], texture2d<uint> tex2d [[texture(1)]], texture3d<uint> tex3d [[texture(2)]], texturecube<uint> texCube [[texture(3)]], texture2d_array<uint> tex2dArray [[texture(4)]], texturecube_array<uint> texCubeArray [[texture(5)]], texture2d<uint> texBuffer [[texture(6)]], sampler tex1dSmplr [[sampler(0)]], sampler tex2dSmplr [[sampler(1)]], sampler tex3dSmplr [[sampler(2)]], sampler texCubeSmplr [[sampler(3)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]])
fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d<uint> tex1d [[texture(0)]], texture2d<uint> tex2d [[texture(1)]], texture3d<uint> tex3d [[texture(2)]], texturecube<uint> texCube [[texture(3)]], texture2d_array<uint> tex2dArray [[texture(4)]], texturecube_array<uint> texCubeArray [[texture(5)]], texture2d<uint> texBuffer [[texture(6)]], sampler tex1dSmplr [[sampler(0)]], sampler tex2dSmplr [[sampler(1)]], sampler tex3dSmplr [[sampler(2)]], sampler texCubeSmplr [[sampler(3)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]])
{
constant uint32_t& tex1dSwzl = spvAuxBuffer.swizzleConst[0];
constant uint32_t& tex2dSwzl = spvAuxBuffer.swizzleConst[1];
constant uint32_t& tex3dSwzl = spvAuxBuffer.swizzleConst[2];
constant uint32_t& texCubeSwzl = spvAuxBuffer.swizzleConst[3];
constant uint32_t& tex2dArraySwzl = spvAuxBuffer.swizzleConst[4];
constant uint32_t& texCubeArraySwzl = spvAuxBuffer.swizzleConst[5];
constant uint32_t& tex1dSwzl = spvSwizzleConstants[0];
constant uint32_t& tex2dSwzl = spvSwizzleConstants[1];
constant uint32_t& tex3dSwzl = spvSwizzleConstants[2];
constant uint32_t& texCubeSwzl = spvSwizzleConstants[3];
constant uint32_t& tex2dArraySwzl = spvSwizzleConstants[4];
constant uint32_t& texCubeArraySwzl = spvSwizzleConstants[5];
float4 c = float4(spvTextureSwizzle(tex1d.sample(tex1dSmplr, 0.0), tex1dSwzl));
c = float4(spvTextureSwizzle(tex2d.sample(tex2dSmplr, float2(0.0)), tex2dSwzl));
c = float4(spvTextureSwizzle(tex3d.sample(tex3dSmplr, float3(0.0)), tex3dSwzl));

View File

@@ -5,11 +5,6 @@
using namespace metal;
struct spvAux
{
uint swizzleConst[1];
};
// Returns 2D texture coords corresponding to 1D texel buffer coords
uint2 spvTexelBufferCoord(uint tc)
{
@@ -136,18 +131,18 @@ inline vec<T, 4> spvGatherCompareSwizzle(sampler s, const thread Tex& t, Ts... p
return t.gather_compare(s, spvForward<Ts>(params)...);
}
fragment void main0(constant spvAux& spvAuxBuffer [[buffer(30)]], texture1d<float> tex1d [[texture(0)]], texture2d<float> tex2d [[texture(1)]], texture3d<float> tex3d [[texture(2)]], texturecube<float> texCube [[texture(3)]], texture2d_array<float> tex2dArray [[texture(4)]], texturecube_array<float> texCubeArray [[texture(5)]], texture2d<float> texBuffer [[texture(6)]], depth2d<float> depth2d [[texture(7)]], depthcube<float> depthCube [[texture(8)]], depth2d_array<float> depth2dArray [[texture(9)]], depthcube_array<float> depthCubeArray [[texture(10)]], sampler tex1dSmplr [[sampler(0)]], sampler tex2dSmplr [[sampler(1)]], sampler tex3dSmplr [[sampler(2)]], sampler texCubeSmplr [[sampler(3)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]], sampler depth2dSmplr [[sampler(7)]], sampler depthCubeSmplr [[sampler(8)]], sampler depth2dArraySmplr [[sampler(9)]], sampler depthCubeArraySmplr [[sampler(10)]])
fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d<float> tex1d [[texture(0)]], texture2d<float> tex2d [[texture(1)]], texture3d<float> tex3d [[texture(2)]], texturecube<float> texCube [[texture(3)]], texture2d_array<float> tex2dArray [[texture(4)]], texturecube_array<float> texCubeArray [[texture(5)]], texture2d<float> texBuffer [[texture(6)]], depth2d<float> depth2d [[texture(7)]], depthcube<float> depthCube [[texture(8)]], depth2d_array<float> depth2dArray [[texture(9)]], depthcube_array<float> depthCubeArray [[texture(10)]], sampler tex1dSmplr [[sampler(0)]], sampler tex2dSmplr [[sampler(1)]], sampler tex3dSmplr [[sampler(2)]], sampler texCubeSmplr [[sampler(3)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]], sampler depth2dSmplr [[sampler(7)]], sampler depthCubeSmplr [[sampler(8)]], sampler depth2dArraySmplr [[sampler(9)]], sampler depthCubeArraySmplr [[sampler(10)]])
{
constant uint32_t& tex1dSwzl = spvAuxBuffer.swizzleConst[0];
constant uint32_t& tex2dSwzl = spvAuxBuffer.swizzleConst[1];
constant uint32_t& tex3dSwzl = spvAuxBuffer.swizzleConst[2];
constant uint32_t& texCubeSwzl = spvAuxBuffer.swizzleConst[3];
constant uint32_t& tex2dArraySwzl = spvAuxBuffer.swizzleConst[4];
constant uint32_t& texCubeArraySwzl = spvAuxBuffer.swizzleConst[5];
constant uint32_t& depth2dSwzl = spvAuxBuffer.swizzleConst[7];
constant uint32_t& depthCubeSwzl = spvAuxBuffer.swizzleConst[8];
constant uint32_t& depth2dArraySwzl = spvAuxBuffer.swizzleConst[9];
constant uint32_t& depthCubeArraySwzl = spvAuxBuffer.swizzleConst[10];
constant uint32_t& tex1dSwzl = spvSwizzleConstants[0];
constant uint32_t& tex2dSwzl = spvSwizzleConstants[1];
constant uint32_t& tex3dSwzl = spvSwizzleConstants[2];
constant uint32_t& texCubeSwzl = spvSwizzleConstants[3];
constant uint32_t& tex2dArraySwzl = spvSwizzleConstants[4];
constant uint32_t& texCubeArraySwzl = spvSwizzleConstants[5];
constant uint32_t& depth2dSwzl = spvSwizzleConstants[7];
constant uint32_t& depthCubeSwzl = spvSwizzleConstants[8];
constant uint32_t& depth2dArraySwzl = spvSwizzleConstants[9];
constant uint32_t& depthCubeArraySwzl = spvSwizzleConstants[10];
float4 c = spvTextureSwizzle(tex1d.sample(tex1dSmplr, 0.0), tex1dSwzl);
c = spvTextureSwizzle(tex2d.sample(tex2dSmplr, float2(0.0)), tex2dSwzl);
c = spvTextureSwizzle(tex3d.sample(tex3dSmplr, float3(0.0)), tex3dSwzl);

View File

@@ -5,11 +5,6 @@
using namespace metal;
struct spvAux
{
uint swizzleConst[1];
};
struct main0_out
{
float4 fragColor [[color(0)]];
@@ -188,19 +183,19 @@ float4 do_samples(thread const texture1d<float> t1, thread const sampler t1Smplr
return c;
}
fragment main0_out main0(constant spvAux& spvAuxBuffer [[buffer(30)]], texture1d<float> tex1d [[texture(0)]], texture2d<float> tex2d [[texture(1)]], texture3d<float> tex3d [[texture(2)]], texturecube<float> texCube [[texture(3)]], texture2d_array<float> tex2dArray [[texture(4)]], texturecube_array<float> texCubeArray [[texture(5)]], texture2d<float> texBuffer [[texture(6)]], depth2d<float> depth2d [[texture(7)]], depthcube<float> depthCube [[texture(8)]], depth2d_array<float> depth2dArray [[texture(9)]], depthcube_array<float> depthCubeArray [[texture(10)]], sampler tex1dSmplr [[sampler(0)]], sampler tex3dSmplr [[sampler(2)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]], sampler depth2dSmplr [[sampler(7)]], sampler depthCubeSmplr [[sampler(8)]], sampler depthCubeArraySmplr [[sampler(10)]], sampler defaultSampler [[sampler(11)]], sampler shadowSampler [[sampler(12)]])
fragment main0_out main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d<float> tex1d [[texture(0)]], texture2d<float> tex2d [[texture(1)]], texture3d<float> tex3d [[texture(2)]], texturecube<float> texCube [[texture(3)]], texture2d_array<float> tex2dArray [[texture(4)]], texturecube_array<float> texCubeArray [[texture(5)]], texture2d<float> texBuffer [[texture(6)]], depth2d<float> depth2d [[texture(7)]], depthcube<float> depthCube [[texture(8)]], depth2d_array<float> depth2dArray [[texture(9)]], depthcube_array<float> depthCubeArray [[texture(10)]], sampler tex1dSmplr [[sampler(0)]], sampler tex3dSmplr [[sampler(2)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]], sampler depth2dSmplr [[sampler(7)]], sampler depthCubeSmplr [[sampler(8)]], sampler depthCubeArraySmplr [[sampler(10)]], sampler defaultSampler [[sampler(11)]], sampler shadowSampler [[sampler(12)]])
{
main0_out out = {};
constant uint32_t& tex1dSwzl = spvAuxBuffer.swizzleConst[0];
constant uint32_t& tex2dSwzl = spvAuxBuffer.swizzleConst[1];
constant uint32_t& tex3dSwzl = spvAuxBuffer.swizzleConst[2];
constant uint32_t& texCubeSwzl = spvAuxBuffer.swizzleConst[3];
constant uint32_t& tex2dArraySwzl = spvAuxBuffer.swizzleConst[4];
constant uint32_t& texCubeArraySwzl = spvAuxBuffer.swizzleConst[5];
constant uint32_t& depth2dSwzl = spvAuxBuffer.swizzleConst[7];
constant uint32_t& depthCubeSwzl = spvAuxBuffer.swizzleConst[8];
constant uint32_t& depth2dArraySwzl = spvAuxBuffer.swizzleConst[9];
constant uint32_t& depthCubeArraySwzl = spvAuxBuffer.swizzleConst[10];
constant uint32_t& tex1dSwzl = spvSwizzleConstants[0];
constant uint32_t& tex2dSwzl = spvSwizzleConstants[1];
constant uint32_t& tex3dSwzl = spvSwizzleConstants[2];
constant uint32_t& texCubeSwzl = spvSwizzleConstants[3];
constant uint32_t& tex2dArraySwzl = spvSwizzleConstants[4];
constant uint32_t& texCubeArraySwzl = spvSwizzleConstants[5];
constant uint32_t& depth2dSwzl = spvSwizzleConstants[7];
constant uint32_t& depthCubeSwzl = spvSwizzleConstants[8];
constant uint32_t& depth2dArraySwzl = spvSwizzleConstants[9];
constant uint32_t& depthCubeArraySwzl = spvSwizzleConstants[10];
out.fragColor = do_samples(tex1d, tex1dSmplr, tex1dSwzl, tex2d, tex2dSwzl, tex3d, tex3dSmplr, tex3dSwzl, texCube, texCubeSwzl, tex2dArray, tex2dArraySmplr, tex2dArraySwzl, texCubeArray, texCubeArraySmplr, texCubeArraySwzl, texBuffer, depth2d, depth2dSmplr, depth2dSwzl, depthCube, depthCubeSmplr, depthCubeSwzl, depth2dArray, depth2dArraySwzl, depthCubeArray, depthCubeArraySmplr, depthCubeArraySwzl, defaultSampler, shadowSampler);
return out;
}

View File

@@ -14,17 +14,22 @@ void barrier_shared()
void full_barrier()
{
threadgroup_barrier(mem_flags::mem_threadgroup);
threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture);
}
void image_barrier()
{
threadgroup_barrier(mem_flags::mem_texture);
}
void buffer_barrier()
{
threadgroup_barrier(mem_flags::mem_none);
threadgroup_barrier(mem_flags::mem_device);
}
void group_barrier()
{
threadgroup_barrier(mem_flags::mem_threadgroup);
threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture);
}
void barrier_shared_exec()
@@ -34,17 +39,22 @@ void barrier_shared_exec()
void full_barrier_exec()
{
threadgroup_barrier(mem_flags::mem_threadgroup);
threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture);
}
void image_barrier_exec()
{
threadgroup_barrier(mem_flags::mem_texture);
}
void buffer_barrier_exec()
{
threadgroup_barrier(mem_flags::mem_none);
threadgroup_barrier(mem_flags::mem_device);
}
void group_barrier_exec()
{
threadgroup_barrier(mem_flags::mem_threadgroup);
threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture);
}
void exec_barrier()
@@ -56,10 +66,12 @@ kernel void main0()
{
barrier_shared();
full_barrier();
image_barrier();
buffer_barrier();
group_barrier();
barrier_shared_exec();
full_barrier_exec();
image_barrier_exec();
buffer_barrier_exec();
group_barrier_exec();
exec_barrier();

View File

@@ -5,11 +5,6 @@
using namespace metal;
struct spvAux
{
uint swizzleConst[1];
};
enum class spvSwizzle : uint
{
none = 0,
@@ -130,9 +125,9 @@ inline vec<T, 4> spvGatherCompareSwizzle(sampler s, const thread Tex& t, Ts... p
return t.gather_compare(s, spvForward<Ts>(params)...);
}
kernel void main0(constant spvAux& spvAuxBuffer [[buffer(30)]], texture2d<float> foo [[texture(0)]], texture2d<float, access::write> bar [[texture(1)]], sampler fooSmplr [[sampler(0)]])
kernel void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture2d<float> foo [[texture(0)]], texture2d<float, access::write> bar [[texture(1)]], sampler fooSmplr [[sampler(0)]])
{
constant uint32_t& fooSwzl = spvAuxBuffer.swizzleConst[0];
constant uint32_t& fooSwzl = spvSwizzleConstants[0];
float4 a = spvTextureSwizzle(foo.sample(fooSmplr, float2(1.0), level(0.0)), fooSwzl);
bar.write(a, uint2(int2(0)));
}

View File

@@ -0,0 +1,171 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct spvDescriptorSetBuffer0
{
constant uint* spvSwizzleConstants [[id(0)]];
array<texture2d<float>, 4> uSampler0 [[id(1)]];
array<sampler, 4> uSampler0Smplr [[id(5)]];
};
struct main0_out
{
float4 FragColor [[color(0)]];
};
struct main0_in
{
float2 vUV [[user(locn0)]];
};
enum class spvSwizzle : uint
{
none = 0,
zero,
one,
red,
green,
blue,
alpha
};
template<typename T> struct spvRemoveReference { typedef T type; };
template<typename T> struct spvRemoveReference<thread T&> { typedef T type; };
template<typename T> struct spvRemoveReference<thread T&&> { typedef T type; };
template<typename T> inline constexpr thread T&& spvForward(thread typename spvRemoveReference<T>::type& x)
{
return static_cast<thread T&&>(x);
}
template<typename T> inline constexpr thread T&& spvForward(thread typename spvRemoveReference<T>::type&& x)
{
return static_cast<thread T&&>(x);
}
template<typename T>
inline T spvGetSwizzle(vec<T, 4> x, T c, spvSwizzle s)
{
switch (s)
{
case spvSwizzle::none:
return c;
case spvSwizzle::zero:
return 0;
case spvSwizzle::one:
return 1;
case spvSwizzle::red:
return x.r;
case spvSwizzle::green:
return x.g;
case spvSwizzle::blue:
return x.b;
case spvSwizzle::alpha:
return x.a;
}
}
// Wrapper function that swizzles texture samples and fetches.
template<typename T>
inline vec<T, 4> spvTextureSwizzle(vec<T, 4> x, uint s)
{
if (!s)
return x;
return vec<T, 4>(spvGetSwizzle(x, x.r, spvSwizzle((s >> 0) & 0xFF)), spvGetSwizzle(x, x.g, spvSwizzle((s >> 8) & 0xFF)), spvGetSwizzle(x, x.b, spvSwizzle((s >> 16) & 0xFF)), spvGetSwizzle(x, x.a, spvSwizzle((s >> 24) & 0xFF)));
}
template<typename T>
inline T spvTextureSwizzle(T x, uint s)
{
return spvTextureSwizzle(vec<T, 4>(x, 0, 0, 1), s).x;
}
// Wrapper function that swizzles texture gathers.
template<typename T, typename Tex, typename... Ts>
inline vec<T, 4> spvGatherSwizzle(sampler s, const thread Tex& t, Ts... params, component c, uint sw) METAL_CONST_ARG(c)
{
if (sw)
{
switch (spvSwizzle((sw >> (uint(c) * 8)) & 0xFF))
{
case spvSwizzle::none:
break;
case spvSwizzle::zero:
return vec<T, 4>(0, 0, 0, 0);
case spvSwizzle::one:
return vec<T, 4>(1, 1, 1, 1);
case spvSwizzle::red:
return t.gather(s, spvForward<Ts>(params)..., component::x);
case spvSwizzle::green:
return t.gather(s, spvForward<Ts>(params)..., component::y);
case spvSwizzle::blue:
return t.gather(s, spvForward<Ts>(params)..., component::z);
case spvSwizzle::alpha:
return t.gather(s, spvForward<Ts>(params)..., component::w);
}
}
switch (c)
{
case component::x:
return t.gather(s, spvForward<Ts>(params)..., component::x);
case component::y:
return t.gather(s, spvForward<Ts>(params)..., component::y);
case component::z:
return t.gather(s, spvForward<Ts>(params)..., component::z);
case component::w:
return t.gather(s, spvForward<Ts>(params)..., component::w);
}
}
// Wrapper function that swizzles depth texture gathers.
template<typename T, typename Tex, typename... Ts>
inline vec<T, 4> spvGatherCompareSwizzle(sampler s, const thread Tex& t, Ts... params, uint sw)
{
if (sw)
{
switch (spvSwizzle(sw & 0xFF))
{
case spvSwizzle::none:
case spvSwizzle::red:
break;
case spvSwizzle::zero:
case spvSwizzle::green:
case spvSwizzle::blue:
case spvSwizzle::alpha:
return vec<T, 4>(0, 0, 0, 0);
case spvSwizzle::one:
return vec<T, 4>(1, 1, 1, 1);
}
}
return t.gather_compare(s, spvForward<Ts>(params)...);
}
float4 sample_in_func_1(thread const array<texture2d<float>, 4> uSampler0, thread const array<sampler, 4> uSampler0Smplr, constant uint32_t* uSampler0Swzl, thread float2& vUV)
{
return spvTextureSwizzle(uSampler0[2].sample(uSampler0Smplr[2], vUV), uSampler0Swzl[2]);
}
float4 sample_in_func_2(thread float2& vUV, thread texture2d<float> uSampler1, thread const sampler uSampler1Smplr, constant uint32_t& uSampler1Swzl)
{
return spvTextureSwizzle(uSampler1.sample(uSampler1Smplr, vUV), uSampler1Swzl);
}
float4 sample_single_in_func(thread const texture2d<float> s, thread const sampler sSmplr, constant uint32_t& sSwzl, thread float2& vUV)
{
return spvTextureSwizzle(s.sample(sSmplr, vUV), sSwzl);
}
fragment main0_out main0(main0_in in [[stage_in]], constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], constant uint* spvSwizzleConstants [[buffer(30)]], texture2d<float> uSampler1 [[texture(0)]], sampler uSampler1Smplr [[sampler(0)]])
{
main0_out out = {};
constant uint32_t* spvDescriptorSet0_uSampler0Swzl = &spvDescriptorSet0.spvSwizzleConstants[1];
constant uint32_t& uSampler1Swzl = spvSwizzleConstants[0];
out.FragColor = sample_in_func_1(spvDescriptorSet0.uSampler0, spvDescriptorSet0.uSampler0Smplr, spvDescriptorSet0_uSampler0Swzl, in.vUV);
out.FragColor += sample_in_func_2(in.vUV, uSampler1, uSampler1Smplr, uSampler1Swzl);
out.FragColor += sample_single_in_func(spvDescriptorSet0.uSampler0[1], spvDescriptorSet0.uSampler0Smplr[1], spvDescriptorSet0_uSampler0Swzl[1], in.vUV);
out.FragColor += sample_single_in_func(uSampler1, uSampler1Smplr, uSampler1Swzl, in.vUV);
return out;
}

View File

@@ -0,0 +1,156 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 FragColor [[color(0)]];
};
struct main0_in
{
float2 vUV [[user(locn0)]];
};
enum class spvSwizzle : uint
{
none = 0,
zero,
one,
red,
green,
blue,
alpha
};
template<typename T> struct spvRemoveReference { typedef T type; };
template<typename T> struct spvRemoveReference<thread T&> { typedef T type; };
template<typename T> struct spvRemoveReference<thread T&&> { typedef T type; };
template<typename T> inline constexpr thread T&& spvForward(thread typename spvRemoveReference<T>::type& x)
{
return static_cast<thread T&&>(x);
}
template<typename T> inline constexpr thread T&& spvForward(thread typename spvRemoveReference<T>::type&& x)
{
return static_cast<thread T&&>(x);
}
template<typename T>
inline T spvGetSwizzle(vec<T, 4> x, T c, spvSwizzle s)
{
switch (s)
{
case spvSwizzle::none:
return c;
case spvSwizzle::zero:
return 0;
case spvSwizzle::one:
return 1;
case spvSwizzle::red:
return x.r;
case spvSwizzle::green:
return x.g;
case spvSwizzle::blue:
return x.b;
case spvSwizzle::alpha:
return x.a;
}
}
// Wrapper function that swizzles texture samples and fetches.
template<typename T>
inline vec<T, 4> spvTextureSwizzle(vec<T, 4> x, uint s)
{
if (!s)
return x;
return vec<T, 4>(spvGetSwizzle(x, x.r, spvSwizzle((s >> 0) & 0xFF)), spvGetSwizzle(x, x.g, spvSwizzle((s >> 8) & 0xFF)), spvGetSwizzle(x, x.b, spvSwizzle((s >> 16) & 0xFF)), spvGetSwizzle(x, x.a, spvSwizzle((s >> 24) & 0xFF)));
}
template<typename T>
inline T spvTextureSwizzle(T x, uint s)
{
return spvTextureSwizzle(vec<T, 4>(x, 0, 0, 1), s).x;
}
// Wrapper function that swizzles texture gathers.
template<typename T, typename Tex, typename... Ts>
inline vec<T, 4> spvGatherSwizzle(sampler s, const thread Tex& t, Ts... params, component c, uint sw) METAL_CONST_ARG(c)
{
if (sw)
{
switch (spvSwizzle((sw >> (uint(c) * 8)) & 0xFF))
{
case spvSwizzle::none:
break;
case spvSwizzle::zero:
return vec<T, 4>(0, 0, 0, 0);
case spvSwizzle::one:
return vec<T, 4>(1, 1, 1, 1);
case spvSwizzle::red:
return t.gather(s, spvForward<Ts>(params)..., component::x);
case spvSwizzle::green:
return t.gather(s, spvForward<Ts>(params)..., component::y);
case spvSwizzle::blue:
return t.gather(s, spvForward<Ts>(params)..., component::z);
case spvSwizzle::alpha:
return t.gather(s, spvForward<Ts>(params)..., component::w);
}
}
switch (c)
{
case component::x:
return t.gather(s, spvForward<Ts>(params)..., component::x);
case component::y:
return t.gather(s, spvForward<Ts>(params)..., component::y);
case component::z:
return t.gather(s, spvForward<Ts>(params)..., component::z);
case component::w:
return t.gather(s, spvForward<Ts>(params)..., component::w);
}
}
// Wrapper function that swizzles depth texture gathers.
template<typename T, typename Tex, typename... Ts>
inline vec<T, 4> spvGatherCompareSwizzle(sampler s, const thread Tex& t, Ts... params, uint sw)
{
if (sw)
{
switch (spvSwizzle(sw & 0xFF))
{
case spvSwizzle::none:
case spvSwizzle::red:
break;
case spvSwizzle::zero:
case spvSwizzle::green:
case spvSwizzle::blue:
case spvSwizzle::alpha:
return vec<T, 4>(0, 0, 0, 0);
case spvSwizzle::one:
return vec<T, 4>(1, 1, 1, 1);
}
}
return t.gather_compare(s, spvForward<Ts>(params)...);
}
float4 sample_in_func(thread const array<texture2d<float>, 4> uSampler, thread const array<sampler, 4> uSamplerSmplr, constant uint32_t* uSamplerSwzl, thread float2& vUV)
{
return spvTextureSwizzle(uSampler[2].sample(uSamplerSmplr[2], vUV), uSamplerSwzl[2]);
}
float4 sample_single_in_func(thread const texture2d<float> s, thread const sampler sSmplr, constant uint32_t& sSwzl, thread float2& vUV)
{
return spvTextureSwizzle(s.sample(sSmplr, vUV), sSwzl);
}
fragment main0_out main0(main0_in in [[stage_in]], constant uint* spvSwizzleConstants [[buffer(30)]], array<texture2d<float>, 4> uSampler [[texture(0)]], array<sampler, 4> uSamplerSmplr [[sampler(0)]])
{
main0_out out = {};
constant uint32_t* uSamplerSwzl = &spvSwizzleConstants[0];
out.FragColor = sample_in_func(uSampler, uSamplerSmplr, uSamplerSwzl, in.vUV);
out.FragColor += sample_single_in_func(uSampler[1], uSamplerSmplr[1], uSamplerSwzl[1], in.vUV);
return out;
}

View File

@@ -0,0 +1,51 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct UBO
{
float4 v[64];
};
struct SSBO
{
float4 v[1];
};
struct main0_out
{
float4 FragColor [[color(0)]];
};
struct main0_in
{
int vIndex [[user(locn0)]];
float2 vUV [[user(locn1)]];
};
fragment main0_out main0(main0_in in [[stage_in]], constant UBO* ubos_0 [[buffer(0)]], constant UBO* ubos_1 [[buffer(1)]], const device SSBO* ssbos_0 [[buffer(2)]], const device SSBO* ssbos_1 [[buffer(3)]], array<texture2d<float>, 8> uSamplers [[texture(0)]], array<texture2d<float>, 8> uCombinedSamplers [[texture(8)]], array<sampler, 7> uSamps [[sampler(1)]], array<sampler, 8> uCombinedSamplersSmplr [[sampler(8)]])
{
constant UBO* ubos[] =
{
ubos_0,
ubos_1,
};
const device SSBO* ssbos[] =
{
ssbos_0,
ssbos_1,
};
main0_out out = {};
int i = in.vIndex;
int _24 = i + 10;
out.FragColor = uSamplers[_24].sample(uSamps[i + 40], in.vUV);
int _50 = i + 10;
out.FragColor = uCombinedSamplers[_50].sample(uCombinedSamplersSmplr[_50], in.vUV);
out.FragColor += ubos[(i + 20)]->v[i + 40];
out.FragColor += ssbos[(i + 50)]->v[i + 60];
return out;
}

View File

@@ -0,0 +1,146 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct SSBO
{
float FragColor;
};
inline uint4 spvSubgroupBallot(bool value)
{
simd_vote vote = simd_ballot(value);
// simd_ballot() returns a 64-bit integer-like object, but
// SPIR-V callers expect a uint4. We must convert.
// FIXME: This won't include higher bits if Apple ever supports
// 128 lanes in an SIMD-group.
return uint4((uint)((simd_vote::vote_t)vote & 0xFFFFFFFF), (uint)(((simd_vote::vote_t)vote >> 32) & 0xFFFFFFFF), 0, 0);
}
inline bool spvSubgroupBallotBitExtract(uint4 ballot, uint bit)
{
return !!extract_bits(ballot[bit / 32], bit % 32, 1);
}
inline uint spvSubgroupBallotFindLSB(uint4 ballot)
{
return select(ctz(ballot.x), select(32 + ctz(ballot.y), select(64 + ctz(ballot.z), select(96 + ctz(ballot.w), uint(-1), ballot.w == 0), ballot.z == 0), ballot.y == 0), ballot.x == 0);
}
inline uint spvSubgroupBallotFindMSB(uint4 ballot)
{
return select(128 - (clz(ballot.w) + 1), select(96 - (clz(ballot.z) + 1), select(64 - (clz(ballot.y) + 1), select(32 - (clz(ballot.x) + 1), uint(-1), ballot.x == 0), ballot.y == 0), ballot.z == 0), ballot.w == 0);
}
inline uint spvSubgroupBallotBitCount(uint4 ballot)
{
return popcount(ballot.x) + popcount(ballot.y) + popcount(ballot.z) + popcount(ballot.w);
}
inline uint spvSubgroupBallotInclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID)
{
uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID + 1, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0)), uint2(0));
return spvSubgroupBallotBitCount(ballot & mask);
}
inline uint spvSubgroupBallotExclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID)
{
uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID - 32, 0)), uint2(0));
return spvSubgroupBallotBitCount(ballot & mask);
}
template<typename T>
inline bool spvSubgroupAllEqual(T value)
{
return simd_all(value == simd_broadcast_first(value));
}
template<>
inline bool spvSubgroupAllEqual(bool value)
{
return simd_all(value) || !simd_any(value);
}
kernel void main0(device SSBO& _9 [[buffer(0)]], uint gl_NumSubgroups [[simdgroups_per_threadgroup]], uint gl_SubgroupID [[simdgroup_index_in_threadgroup]], uint gl_SubgroupSize [[thread_execution_width]], uint gl_SubgroupInvocationID [[thread_index_in_simdgroup]])
{
uint4 gl_SubgroupEqMask = 27 > 32 ? uint4(0, (1 << (gl_SubgroupInvocationID - 32)), uint2(0)) : uint4(1 << gl_SubgroupInvocationID, uint3(0));
uint4 gl_SubgroupGeMask = uint4(extract_bits(0xFFFFFFFF, min(gl_SubgroupInvocationID, 32u), (uint)max(min((int)gl_SubgroupSize, 32) - (int)gl_SubgroupInvocationID, 0)), extract_bits(0xFFFFFFFF, (uint)max((int)gl_SubgroupInvocationID - 32, 0), (uint)max((int)gl_SubgroupSize - (int)max(gl_SubgroupInvocationID, 32u), 0)), uint2(0));
uint4 gl_SubgroupGtMask = uint4(extract_bits(0xFFFFFFFF, min(gl_SubgroupInvocationID + 1, 32u), (uint)max(min((int)gl_SubgroupSize, 32) - (int)gl_SubgroupInvocationID - 1, 0)), extract_bits(0xFFFFFFFF, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0), (uint)max((int)gl_SubgroupSize - (int)max(gl_SubgroupInvocationID + 1, 32u), 0)), uint2(0));
uint4 gl_SubgroupLeMask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID + 1, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0)), uint2(0));
uint4 gl_SubgroupLtMask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID - 32, 0)), uint2(0));
_9.FragColor = float(gl_NumSubgroups);
_9.FragColor = float(gl_SubgroupID);
_9.FragColor = float(gl_SubgroupSize);
_9.FragColor = float(gl_SubgroupInvocationID);
simdgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture);
simdgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture);
simdgroup_barrier(mem_flags::mem_device);
simdgroup_barrier(mem_flags::mem_threadgroup);
simdgroup_barrier(mem_flags::mem_texture);
bool elected = simd_is_first();
_9.FragColor = float4(gl_SubgroupEqMask).x;
_9.FragColor = float4(gl_SubgroupGeMask).x;
_9.FragColor = float4(gl_SubgroupGtMask).x;
_9.FragColor = float4(gl_SubgroupLeMask).x;
_9.FragColor = float4(gl_SubgroupLtMask).x;
float4 broadcasted = simd_broadcast(float4(10.0), 8u);
float3 first = simd_broadcast_first(float3(20.0));
uint4 ballot_value = spvSubgroupBallot(true);
bool inverse_ballot_value = spvSubgroupBallotBitExtract(ballot_value, gl_SubgroupInvocationID);
bool bit_extracted = spvSubgroupBallotBitExtract(uint4(10u), 8u);
uint bit_count = spvSubgroupBallotBitCount(ballot_value);
uint inclusive_bit_count = spvSubgroupBallotInclusiveBitCount(ballot_value, gl_SubgroupInvocationID);
uint exclusive_bit_count = spvSubgroupBallotExclusiveBitCount(ballot_value, gl_SubgroupInvocationID);
uint lsb = spvSubgroupBallotFindLSB(ballot_value);
uint msb = spvSubgroupBallotFindMSB(ballot_value);
uint shuffled = simd_shuffle(10u, 8u);
uint shuffled_xor = simd_shuffle_xor(30u, 8u);
uint shuffled_up = simd_shuffle_up(20u, 4u);
uint shuffled_down = simd_shuffle_down(20u, 4u);
bool has_all = simd_all(true);
bool has_any = simd_any(true);
bool has_equal = spvSubgroupAllEqual(0);
has_equal = spvSubgroupAllEqual(true);
float4 added = simd_sum(float4(20.0));
int4 iadded = simd_sum(int4(20));
float4 multiplied = simd_product(float4(20.0));
int4 imultiplied = simd_product(int4(20));
float4 lo = simd_min(float4(20.0));
float4 hi = simd_max(float4(20.0));
int4 slo = simd_min(int4(20));
int4 shi = simd_max(int4(20));
uint4 ulo = simd_min(uint4(20u));
uint4 uhi = simd_max(uint4(20u));
uint4 anded = simd_and(ballot_value);
uint4 ored = simd_or(ballot_value);
uint4 xored = simd_xor(ballot_value);
added = simd_prefix_inclusive_sum(added);
iadded = simd_prefix_inclusive_sum(iadded);
multiplied = simd_prefix_inclusive_product(multiplied);
imultiplied = simd_prefix_inclusive_product(imultiplied);
added = simd_prefix_exclusive_sum(multiplied);
multiplied = simd_prefix_exclusive_product(multiplied);
iadded = simd_prefix_exclusive_sum(imultiplied);
imultiplied = simd_prefix_exclusive_product(imultiplied);
added = quad_sum(added);
multiplied = quad_product(multiplied);
iadded = quad_sum(iadded);
imultiplied = quad_product(imultiplied);
lo = quad_min(lo);
hi = quad_max(hi);
ulo = quad_min(ulo);
uhi = quad_max(uhi);
slo = quad_min(slo);
shi = quad_max(shi);
anded = quad_and(anded);
ored = quad_or(ored);
xored = quad_xor(xored);
float4 swap_horiz = quad_shuffle_xor(float4(20.0), 1u);
float4 swap_vertical = quad_shuffle_xor(float4(20.0), 2u);
float4 swap_diagonal = quad_shuffle_xor(float4(20.0), 3u);
float4 quad_broadcast0 = quad_broadcast(float4(20.0), 3u);
}

View File

@@ -0,0 +1,31 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct SSBO
{
float FragColor;
};
kernel void main0(device SSBO& _9 [[buffer(0)]], uint gl_NumSubgroups [[quadgroups_per_threadgroup]], uint gl_SubgroupID [[quadgroup_index_in_threadgroup]], uint gl_SubgroupSize [[thread_execution_width]], uint gl_SubgroupInvocationID [[thread_index_in_quadgroup]])
{
_9.FragColor = float(gl_NumSubgroups);
_9.FragColor = float(gl_SubgroupID);
_9.FragColor = float(gl_SubgroupSize);
_9.FragColor = float(gl_SubgroupInvocationID);
simdgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture);
simdgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture);
simdgroup_barrier(mem_flags::mem_device);
simdgroup_barrier(mem_flags::mem_threadgroup);
simdgroup_barrier(mem_flags::mem_texture);
uint shuffled = quad_shuffle(10u, 8u);
uint shuffled_xor = quad_shuffle_xor(30u, 8u);
uint shuffled_up = quad_shuffle_up(20u, 4u);
uint shuffled_down = quad_shuffle_down(20u, 4u);
float4 swap_horiz = quad_shuffle_xor(float4(20.0), 1u);
float4 swap_vertical = quad_shuffle_xor(float4(20.0), 2u);
float4 swap_diagonal = quad_shuffle_xor(float4(20.0), 3u);
float4 quad_broadcast0 = quad_broadcast(float4(20.0), 3u);
}

View File

@@ -0,0 +1,14 @@
#version 450
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 1, std140) buffer SSBO
{
uint size;
float v[];
} _11;
void main()
{
_11.size = uint(int(uint(_11.v.length())));
}

View File

@@ -0,0 +1,26 @@
#version 450
#extension GL_EXT_buffer_reference : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(buffer_reference) buffer PtrUint;
layout(buffer_reference) buffer PtrInt;
layout(buffer_reference, std430) buffer PtrUint
{
uint value;
};
layout(buffer_reference, std430) buffer PtrInt
{
int value;
};
layout(set = 0, binding = 0, std430) buffer Buf
{
PtrUint ptr;
} _11;
void main()
{
PtrInt(_11.ptr).value = 10;
}

View File

@@ -22,7 +22,7 @@ void copy_node(restrict Node dst, restrict Node a, restrict Node b)
dst.value = a.value + b.value;
}
void overwrite_node(out Node dst, Node src)
void overwrite_node(out restrict Node dst, restrict Node src)
{
dst = src;
}

View File

@@ -0,0 +1,12 @@
#version 450
layout(local_size_x = 1) in;
layout(set = 0, binding = 1, std140) buffer SSBO
{
uint size;
float v[];
};
void main()
{
size = v.length();
}

View File

@@ -0,0 +1,28 @@
#version 450
#extension GL_EXT_nonuniform_qualifier : require
layout(set = 0, binding = 0) uniform texture2D uSamplers[];
layout(set = 1, binding = 0) uniform sampler2D uCombinedSamplers[];
layout(set = 2, binding = 0) uniform sampler uSamps[];
layout(location = 0) flat in int vIndex;
layout(location = 1) in vec2 vUV;
layout(location = 0) out vec4 FragColor;
layout(set = 3, binding = 0) uniform UBO
{
vec4 v[64];
} ubos[];
layout(set = 4, binding = 0) readonly buffer SSBO
{
vec4 v[];
} ssbos[];
void main()
{
int i = vIndex;
FragColor = texture(sampler2D(uSamplers[nonuniformEXT(i + 10)], uSamps[nonuniformEXT(i + 40)]), vUV);
FragColor = texture(uCombinedSamplers[nonuniformEXT(i + 10)], vUV);
FragColor += ubos[nonuniformEXT(i + 20)].v[nonuniformEXT(i + 40)];
FragColor += ssbos[nonuniformEXT(i + 50)].v[nonuniformEXT(i + 60)];
}

View File

@@ -11,12 +11,10 @@ void full_barrier()
memoryBarrier();
}
#if 0
void image_barrier()
{
memoryBarrierImage();
}
#endif
void buffer_barrier()
{
@@ -40,13 +38,11 @@ void full_barrier_exec()
barrier();
}
#if 0
void image_barrier_exec()
{
memoryBarrierImage();
barrier();
}
#endif
void buffer_barrier_exec()
{
@@ -69,13 +65,13 @@ void main()
{
barrier_shared();
full_barrier();
//image_barrier();
image_barrier();
buffer_barrier();
group_barrier();
barrier_shared_exec();
full_barrier_exec();
//image_barrier_exec();
image_barrier_exec();
buffer_barrier_exec();
group_barrier_exec();

View File

@@ -0,0 +1,31 @@
#version 450
layout(set = 0, binding = 1) uniform sampler2D uSampler0[4];
layout(set = 2, binding = 0) uniform sampler2D uSampler1;
layout(set = 1, binding = 4) uniform sampler2D uSamp;
layout(location = 0) in vec2 vUV;
layout(location = 0) out vec4 FragColor;
vec4 sample_in_func_1()
{
return texture(uSampler0[2], vUV);
}
vec4 sample_in_func_2()
{
return texture(uSampler1, vUV);
}
vec4 sample_single_in_func(sampler2D s)
{
return texture(s, vUV);
}
void main()
{
FragColor = sample_in_func_1();
FragColor += sample_in_func_2();
FragColor += sample_single_in_func(uSampler0[1]);
FragColor += sample_single_in_func(uSampler1);
}

View File

@@ -0,0 +1,23 @@
#version 450
layout(set = 0, binding = 0) uniform sampler2D uSampler[4];
layout(set = 0, binding = 1) uniform sampler2D uSamp;
layout(location = 0) in vec2 vUV;
layout(location = 0) out vec4 FragColor;
vec4 sample_in_func()
{
return texture(uSampler[2], vUV);
}
vec4 sample_single_in_func(sampler2D s)
{
return texture(s, vUV);
}
void main()
{
FragColor = sample_in_func();
FragColor += sample_single_in_func(uSampler[1]);
}

View File

@@ -0,0 +1,28 @@
#version 450
#extension GL_EXT_nonuniform_qualifier : require
layout(binding = 0) uniform texture2D uSamplers[8];
layout(binding = 8) uniform sampler2D uCombinedSamplers[8];
layout(binding = 1) uniform sampler uSamps[7];
layout(location = 0) flat in int vIndex;
layout(location = 1) in vec2 vUV;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 0) uniform UBO
{
vec4 v[64];
} ubos[2];
layout(set = 0, binding = 2) readonly buffer SSBO
{
vec4 v[];
} ssbos[2];
void main()
{
int i = vIndex;
FragColor = texture(sampler2D(uSamplers[nonuniformEXT(i + 10)], uSamps[nonuniformEXT(i + 40)]), vUV);
FragColor = texture(uCombinedSamplers[nonuniformEXT(i + 10)], vUV);
FragColor += ubos[nonuniformEXT(i + 20)].v[nonuniformEXT(i + 40)];
FragColor += ssbos[nonuniformEXT(i + 50)].v[nonuniformEXT(i + 60)];
}

View File

@@ -0,0 +1,126 @@
#version 450
#extension GL_KHR_shader_subgroup_basic : require
#extension GL_KHR_shader_subgroup_ballot : require
#extension GL_KHR_shader_subgroup_vote : require
#extension GL_KHR_shader_subgroup_shuffle : require
#extension GL_KHR_shader_subgroup_shuffle_relative : require
#extension GL_KHR_shader_subgroup_arithmetic : require
#extension GL_KHR_shader_subgroup_clustered : require
#extension GL_KHR_shader_subgroup_quad : require
layout(local_size_x = 1) in;
layout(std430, binding = 0) buffer SSBO
{
float FragColor;
};
void main()
{
// basic
FragColor = float(gl_NumSubgroups);
FragColor = float(gl_SubgroupID);
FragColor = float(gl_SubgroupSize);
FragColor = float(gl_SubgroupInvocationID);
subgroupBarrier();
subgroupMemoryBarrier();
subgroupMemoryBarrierBuffer();
subgroupMemoryBarrierShared();
subgroupMemoryBarrierImage();
bool elected = subgroupElect();
// ballot
FragColor = float(gl_SubgroupEqMask);
FragColor = float(gl_SubgroupGeMask);
FragColor = float(gl_SubgroupGtMask);
FragColor = float(gl_SubgroupLeMask);
FragColor = float(gl_SubgroupLtMask);
vec4 broadcasted = subgroupBroadcast(vec4(10.0), 8u);
vec3 first = subgroupBroadcastFirst(vec3(20.0));
uvec4 ballot_value = subgroupBallot(true);
bool inverse_ballot_value = subgroupInverseBallot(ballot_value);
bool bit_extracted = subgroupBallotBitExtract(uvec4(10u), 8u);
uint bit_count = subgroupBallotBitCount(ballot_value);
uint inclusive_bit_count = subgroupBallotInclusiveBitCount(ballot_value);
uint exclusive_bit_count = subgroupBallotExclusiveBitCount(ballot_value);
uint lsb = subgroupBallotFindLSB(ballot_value);
uint msb = subgroupBallotFindMSB(ballot_value);
// shuffle
uint shuffled = subgroupShuffle(10u, 8u);
uint shuffled_xor = subgroupShuffleXor(30u, 8u);
// shuffle relative
uint shuffled_up = subgroupShuffleUp(20u, 4u);
uint shuffled_down = subgroupShuffleDown(20u, 4u);
// vote
bool has_all = subgroupAll(true);
bool has_any = subgroupAny(true);
bool has_equal = subgroupAllEqual(0);
has_equal = subgroupAllEqual(true);
// arithmetic
vec4 added = subgroupAdd(vec4(20.0));
ivec4 iadded = subgroupAdd(ivec4(20));
vec4 multiplied = subgroupMul(vec4(20.0));
ivec4 imultiplied = subgroupMul(ivec4(20));
vec4 lo = subgroupMin(vec4(20.0));
vec4 hi = subgroupMax(vec4(20.0));
ivec4 slo = subgroupMin(ivec4(20));
ivec4 shi = subgroupMax(ivec4(20));
uvec4 ulo = subgroupMin(uvec4(20));
uvec4 uhi = subgroupMax(uvec4(20));
uvec4 anded = subgroupAnd(ballot_value);
uvec4 ored = subgroupOr(ballot_value);
uvec4 xored = subgroupXor(ballot_value);
added = subgroupInclusiveAdd(added);
iadded = subgroupInclusiveAdd(iadded);
multiplied = subgroupInclusiveMul(multiplied);
imultiplied = subgroupInclusiveMul(imultiplied);
//lo = subgroupInclusiveMin(lo); // FIXME: Unsupported by Metal
//hi = subgroupInclusiveMax(hi);
//slo = subgroupInclusiveMin(slo);
//shi = subgroupInclusiveMax(shi);
//ulo = subgroupInclusiveMin(ulo);
//uhi = subgroupInclusiveMax(uhi);
//anded = subgroupInclusiveAnd(anded);
//ored = subgroupInclusiveOr(ored);
//xored = subgroupInclusiveXor(ored);
//added = subgroupExclusiveAdd(lo);
added = subgroupExclusiveAdd(multiplied);
multiplied = subgroupExclusiveMul(multiplied);
iadded = subgroupExclusiveAdd(imultiplied);
imultiplied = subgroupExclusiveMul(imultiplied);
//lo = subgroupExclusiveMin(lo); // FIXME: Unsupported by Metal
//hi = subgroupExclusiveMax(hi);
//ulo = subgroupExclusiveMin(ulo);
//uhi = subgroupExclusiveMax(uhi);
//slo = subgroupExclusiveMin(slo);
//shi = subgroupExclusiveMax(shi);
//anded = subgroupExclusiveAnd(anded);
//ored = subgroupExclusiveOr(ored);
//xored = subgroupExclusiveXor(ored);
// clustered
added = subgroupClusteredAdd(added, 4u);
multiplied = subgroupClusteredMul(multiplied, 4u);
iadded = subgroupClusteredAdd(iadded, 4u);
imultiplied = subgroupClusteredMul(imultiplied, 4u);
lo = subgroupClusteredMin(lo, 4u);
hi = subgroupClusteredMax(hi, 4u);
ulo = subgroupClusteredMin(ulo, 4u);
uhi = subgroupClusteredMax(uhi, 4u);
slo = subgroupClusteredMin(slo, 4u);
shi = subgroupClusteredMax(shi, 4u);
anded = subgroupClusteredAnd(anded, 4u);
ored = subgroupClusteredOr(ored, 4u);
xored = subgroupClusteredXor(xored, 4u);
// quad
vec4 swap_horiz = subgroupQuadSwapHorizontal(vec4(20.0));
vec4 swap_vertical = subgroupQuadSwapVertical(vec4(20.0));
vec4 swap_diagonal = subgroupQuadSwapDiagonal(vec4(20.0));
vec4 quad_broadcast = subgroupQuadBroadcast(vec4(20.0), 3u);
}

View File

@@ -0,0 +1,41 @@
#version 450
#extension GL_KHR_shader_subgroup_basic : require
#extension GL_KHR_shader_subgroup_shuffle : require
#extension GL_KHR_shader_subgroup_shuffle_relative : require
#extension GL_KHR_shader_subgroup_quad : require
layout(local_size_x = 1) in;
layout(std430, binding = 0) buffer SSBO
{
float FragColor;
};
// Reduced test for functionality exposed on iOS.
void main()
{
// basic
FragColor = float(gl_NumSubgroups);
FragColor = float(gl_SubgroupID);
FragColor = float(gl_SubgroupSize);
FragColor = float(gl_SubgroupInvocationID);
subgroupBarrier();
subgroupMemoryBarrier();
subgroupMemoryBarrierBuffer();
subgroupMemoryBarrierShared();
subgroupMemoryBarrierImage();
// shuffle
uint shuffled = subgroupShuffle(10u, 8u);
uint shuffled_xor = subgroupShuffleXor(30u, 8u);
// shuffle relative
uint shuffled_up = subgroupShuffleUp(20u, 4u);
uint shuffled_down = subgroupShuffleDown(20u, 4u);
// quad
vec4 swap_horiz = subgroupQuadSwapHorizontal(vec4(20.0));
vec4 swap_vertical = subgroupQuadSwapVertical(vec4(20.0));
vec4 swap_diagonal = subgroupQuadSwapDiagonal(vec4(20.0));
vec4 quad_broadcast = subgroupQuadBroadcast(vec4(20.0), 3u);
}

View File

@@ -0,0 +1,12 @@
#version 450
layout(local_size_x = 1) in;
layout(set = 0, binding = 1, std140) buffer SSBO
{
uint size;
float v[];
};
void main()
{
size = v.length();
}

View File

@@ -0,0 +1,22 @@
#version 450
#extension GL_EXT_buffer_reference: require
layout(buffer_reference) buffer PtrUint
{
uint value;
};
layout(buffer_reference) buffer PtrInt
{
int value;
};
layout(set = 0, binding = 0) buffer Buf
{
PtrUint ptr;
};
void main()
{
PtrInt(ptr).value = 10;
}

View File

@@ -21,7 +21,7 @@ void copy_node(restrict Node dst, restrict Node a, restrict Node b)
dst.value = a.value + b.value;
}
void overwrite_node(out Node dst, Node src)
void overwrite_node(out restrict Node dst, restrict Node src)
{
dst = src;
}

View File

@@ -317,7 +317,7 @@ string CompilerCPP::compile()
backend.basic_uint_type = "uint32_t";
backend.swizzle_is_function = true;
backend.shared_is_implied = true;
backend.flexible_member_array_supported = false;
backend.unsized_array_supported = false;
backend.explicit_struct_type = true;
backend.use_initializer_list = true;

View File

@@ -4217,7 +4217,7 @@ Compiler::PhysicalStorageBufferPointerHandler::PhysicalStorageBufferPointerHandl
bool Compiler::PhysicalStorageBufferPointerHandler::handle(Op op, const uint32_t *args, uint32_t)
{
if (op == OpConvertUToPtr)
if (op == OpConvertUToPtr || op == OpBitcast)
{
auto &type = compiler.get<SPIRType>(args[0]);
if (type.storage == StorageClassPhysicalStorageBufferEXT && type.pointer && type.pointer_depth == 1)

View File

@@ -442,6 +442,9 @@ spvc_result spvc_compiler_options_set_uint(spvc_compiler_options options, spvc_c
case SPVC_COMPILER_OPTION_GLSL_EMIT_PUSH_CONSTANT_AS_UNIFORM_BUFFER:
options->glsl.emit_push_constant_as_uniform_buffer = value != 0;
break;
case SPVC_COMPILER_OPTION_GLSL_EMIT_UNIFORM_BUFFER_AS_PLAIN_UNIFORMS:
options->glsl.emit_uniform_buffer_as_plain_uniforms = value != 0;
break;
#endif
#if SPIRV_CROSS_C_API_HLSL
@@ -471,8 +474,8 @@ spvc_result spvc_compiler_options_set_uint(spvc_compiler_options options, spvc_c
options->msl.texel_buffer_texture_width = value;
break;
case SPVC_COMPILER_OPTION_MSL_AUX_BUFFER_INDEX:
options->msl.aux_buffer_index = value;
case SPVC_COMPILER_OPTION_MSL_SWIZZLE_BUFFER_INDEX:
options->msl.swizzle_buffer_index = value;
break;
case SPVC_COMPILER_OPTION_MSL_INDIRECT_PARAMS_BUFFER_INDEX:
@@ -723,7 +726,7 @@ spvc_bool spvc_compiler_msl_is_rasterization_disabled(spvc_compiler compiler)
#endif
}
spvc_bool spvc_compiler_msl_needs_aux_buffer(spvc_compiler compiler)
spvc_bool spvc_compiler_msl_needs_swizzle_buffer(spvc_compiler compiler)
{
#if SPIRV_CROSS_C_API_MSL
if (compiler->backend != SPVC_BACKEND_MSL)
@@ -733,13 +736,18 @@ spvc_bool spvc_compiler_msl_needs_aux_buffer(spvc_compiler compiler)
}
auto &msl = *static_cast<CompilerMSL *>(compiler->compiler.get());
return msl.needs_aux_buffer() ? SPVC_TRUE : SPVC_FALSE;
return msl.needs_swizzle_buffer() ? SPVC_TRUE : SPVC_FALSE;
#else
compiler->context->report_error("MSL function used on a non-MSL backend.");
return SPVC_FALSE;
#endif
}
spvc_bool spvc_compiler_msl_needs_aux_buffer(spvc_compiler compiler)
{
return spvc_compiler_msl_needs_swizzle_buffer(compiler);
}
spvc_bool spvc_compiler_msl_needs_output_buffer(spvc_compiler compiler)
{
#if SPIRV_CROSS_C_API_MSL
@@ -1273,6 +1281,11 @@ const char *spvc_compiler_get_member_decoration_string(spvc_compiler compiler, s
.c_str();
}
const char *spvc_compiler_get_member_name(spvc_compiler compiler, spvc_type_id id, unsigned member_index)
{
return compiler->compiler->get_member_name(id, member_index).c_str();
}
spvc_result spvc_compiler_get_entry_points(spvc_compiler compiler, const spvc_entry_point **entry_points,
size_t *num_entry_points)
{
@@ -1410,7 +1423,7 @@ unsigned spvc_type_get_bit_width(spvc_type type)
return type->width;
}
unsigned spvc_type_get_SmallVector_size(spvc_type type)
unsigned spvc_type_get_vector_size(spvc_type type)
{
return type->vecsize;
}
@@ -1640,6 +1653,32 @@ spvc_constant_id spvc_compiler_get_work_group_size_specialization_constants(spvc
return ret;
}
spvc_result spvc_compiler_get_active_buffer_ranges(spvc_compiler compiler,
spvc_variable_id id,
const spvc_buffer_range **ranges,
size_t *num_ranges)
{
SPVC_BEGIN_SAFE_SCOPE
{
auto active_ranges = compiler->compiler->get_active_buffer_ranges(id);
SmallVector<spvc_buffer_range> translated;
translated.reserve(active_ranges.size());
for (auto &r : active_ranges)
{
spvc_buffer_range trans = { r.index, r.offset, r.range };
translated.push_back(trans);
}
auto ptr = spvc_allocate<TemporaryBuffer<spvc_buffer_range>>();
ptr->buffer = std::move(translated);
*ranges = ptr->buffer.data();
*num_ranges = ptr->buffer.size();
compiler->context->allocations.push_back(std::move(ptr));
}
SPVC_END_SAFE_SCOPE(compiler->context, SPVC_ERROR_OUT_OF_MEMORY)
return SPVC_SUCCESS;
}
float spvc_constant_get_scalar_fp16(spvc_constant constant, unsigned column, unsigned row)
{
return constant->scalar_f16(column, row);

View File

@@ -33,7 +33,7 @@ extern "C" {
/* Bumped if ABI or API breaks backwards compatibility. */
#define SPVC_C_API_VERSION_MAJOR 0
/* Bumped if APIs or enumerations are added in a backwards compatible way. */
#define SPVC_C_API_VERSION_MINOR 6
#define SPVC_C_API_VERSION_MINOR 9
/* Bumped if internal implementation details change. */
#define SPVC_C_API_VERSION_PATCH 0
@@ -111,6 +111,14 @@ typedef struct spvc_specialization_constant
unsigned constant_id;
} spvc_specialization_constant;
/* See C++ API. */
typedef struct spvc_buffer_range
{
unsigned index;
size_t offset;
size_t range;
} spvc_buffer_range;
/* See C++ API. */
typedef struct spvc_hlsl_root_constants
{
@@ -290,9 +298,12 @@ SPVC_PUBLIC_API void spvc_msl_resource_binding_init(spvc_msl_resource_binding *b
#define SPVC_MSL_PUSH_CONSTANT_DESC_SET (~(0u))
#define SPVC_MSL_PUSH_CONSTANT_BINDING (0)
#define SPVC_MSL_SWIZZLE_BUFFER_BINDING (~(1u))
/* Obsolete. Sticks around for backwards compatibility. */
#define SPVC_MSL_AUX_BUFFER_STRUCT_VERSION 1
/* Runtime check for incompatibility. */
/* Runtime check for incompatibility. Obsolete. */
SPVC_PUBLIC_API unsigned spvc_msl_get_aux_buffer_struct_version(void);
/* Maps to C++ API. */
@@ -407,7 +418,11 @@ typedef enum spvc_compiler_option
SPVC_COMPILER_OPTION_MSL_VERSION = 17 | SPVC_COMPILER_OPTION_MSL_BIT,
SPVC_COMPILER_OPTION_MSL_TEXEL_BUFFER_TEXTURE_WIDTH = 18 | SPVC_COMPILER_OPTION_MSL_BIT,
/* Obsolete, use SWIZZLE_BUFFER_INDEX instead. */
SPVC_COMPILER_OPTION_MSL_AUX_BUFFER_INDEX = 19 | SPVC_COMPILER_OPTION_MSL_BIT,
SPVC_COMPILER_OPTION_MSL_SWIZZLE_BUFFER_INDEX = 19 | SPVC_COMPILER_OPTION_MSL_BIT,
SPVC_COMPILER_OPTION_MSL_INDIRECT_PARAMS_BUFFER_INDEX = 20 | SPVC_COMPILER_OPTION_MSL_BIT,
SPVC_COMPILER_OPTION_MSL_SHADER_OUTPUT_BUFFER_INDEX = 21 | SPVC_COMPILER_OPTION_MSL_BIT,
SPVC_COMPILER_OPTION_MSL_SHADER_PATCH_OUTPUT_BUFFER_INDEX = 22 | SPVC_COMPILER_OPTION_MSL_BIT,
@@ -426,6 +441,8 @@ typedef enum spvc_compiler_option
SPVC_COMPILER_OPTION_MSL_TEXTURE_BUFFER_NATIVE = 34 | SPVC_COMPILER_OPTION_MSL_BIT,
SPVC_COMPILER_OPTION_GLSL_EMIT_UNIFORM_BUFFER_AS_PLAIN_UNIFORMS = 35 | SPVC_COMPILER_OPTION_GLSL_BIT,
SPVC_COMPILER_OPTION_INT_MAX = 0x7fffffff
} spvc_compiler_option;
@@ -503,7 +520,11 @@ SPVC_PUBLIC_API spvc_variable_id spvc_compiler_hlsl_remap_num_workgroups_builtin
* Maps to C++ API.
*/
SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_is_rasterization_disabled(spvc_compiler compiler);
/* Obsolete. Renamed to needs_swizzle_buffer. */
SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_needs_aux_buffer(spvc_compiler compiler);
SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_needs_swizzle_buffer(spvc_compiler compiler);
SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_needs_output_buffer(spvc_compiler compiler);
SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_needs_patch_output_buffer(spvc_compiler compiler);
SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_needs_input_threadgroup_mem(spvc_compiler compiler);
@@ -565,6 +586,7 @@ SPVC_PUBLIC_API unsigned spvc_compiler_get_member_decoration(spvc_compiler compi
unsigned member_index, SpvDecoration decoration);
SPVC_PUBLIC_API const char *spvc_compiler_get_member_decoration_string(spvc_compiler compiler, spvc_type_id id,
unsigned member_index, SpvDecoration decoration);
SPVC_PUBLIC_API const char *spvc_compiler_get_member_name(spvc_compiler compiler, spvc_type_id id, unsigned member_index);
/*
* Entry points.
@@ -657,6 +679,15 @@ SPVC_PUBLIC_API spvc_constant_id spvc_compiler_get_work_group_size_specializatio
spvc_specialization_constant *y,
spvc_specialization_constant *z);
/*
* Buffer ranges
* Maps to C++ API.
*/
SPVC_PUBLIC_API spvc_result spvc_compiler_get_active_buffer_ranges(spvc_compiler compiler,
spvc_variable_id id,
const spvc_buffer_range **ranges,
size_t *num_ranges);
/*
* No stdint.h until C99, sigh :(
* For smaller types, the result is sign or zero-extended as appropriate.

View File

@@ -1459,9 +1459,19 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var)
attr.push_back(join("set = ", dec.set));
}
bool push_constant_block = options.vulkan_semantics && var.storage == StorageClassPushConstant;
bool ssbo_block = var.storage == StorageClassStorageBuffer ||
(var.storage == StorageClassUniform && typeflags.get(DecorationBufferBlock));
bool emulated_ubo = var.storage == StorageClassPushConstant && options.emit_push_constant_as_uniform_buffer;
bool ubo_block = var.storage == StorageClassUniform && typeflags.get(DecorationBlock);
// GL 3.0/GLSL 1.30 is not considered legacy, but it doesn't have UBOs ...
bool can_use_buffer_blocks = (options.es && options.version >= 300) || (!options.es && options.version >= 140);
// pretend no UBOs when options say so
if (ubo_block && options.emit_uniform_buffer_as_plain_uniforms)
can_use_buffer_blocks = false;
bool can_use_binding;
if (options.es)
can_use_binding = options.version >= 310;
@@ -1478,12 +1488,6 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var)
if (flags.get(DecorationOffset))
attr.push_back(join("offset = ", dec.offset));
bool push_constant_block = options.vulkan_semantics && var.storage == StorageClassPushConstant;
bool ssbo_block = var.storage == StorageClassStorageBuffer ||
(var.storage == StorageClassUniform && typeflags.get(DecorationBufferBlock));
bool emulated_ubo = var.storage == StorageClassPushConstant && options.emit_push_constant_as_uniform_buffer;
bool ubo_block = var.storage == StorageClassUniform && typeflags.get(DecorationBlock);
// Instead of adding explicit offsets for every element here, just assume we're using std140 or std430.
// If SPIR-V does not comply with either layout, we cannot really work around it.
if (can_use_buffer_blocks && (ubo_block || emulated_ubo))
@@ -1611,9 +1615,13 @@ void CompilerGLSL::emit_push_constant_block_glsl(const SPIRVariable &var)
void CompilerGLSL::emit_buffer_block(const SPIRVariable &var)
{
auto &type = get<SPIRType>(var.basetype);
bool ubo_block = var.storage == StorageClassUniform && has_decoration(type.self, DecorationBlock);
if (flattened_buffer_blocks.count(var.self))
emit_buffer_block_flattened(var);
else if (is_legacy() || (!options.es && options.version == 130))
else if (is_legacy() || (!options.es && options.version == 130) ||
(ubo_block && options.emit_uniform_buffer_as_plain_uniforms))
emit_buffer_block_legacy(var);
else
emit_buffer_block_native(var);
@@ -5772,6 +5780,10 @@ case OpGroupNonUniform##op: \
string CompilerGLSL::bitcast_glsl_op(const SPIRType &out_type, const SPIRType &in_type)
{
// OpBitcast can deal with pointers.
if (out_type.pointer || in_type.pointer)
return type_to_glsl(out_type);
if (out_type.basetype == in_type.basetype)
return "";
@@ -7566,7 +7578,8 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
uint32_t result_type = ops[0];
uint32_t id = ops[1];
auto e = access_chain_internal(ops[2], &ops[3], length - 3, ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, nullptr);
set<SPIRExpression>(id, e + ".length()", result_type, true);
set<SPIRExpression>(id, join(type_to_glsl(get<SPIRType>(result_type)), "(", e, ".length())"), result_type,
true);
break;
}
@@ -9913,7 +9926,7 @@ string CompilerGLSL::to_array_size(const SPIRType &type, uint32_t index)
return to_expression(size);
else if (size)
return convert_to_string(size);
else if (!backend.flexible_member_array_supported)
else if (!backend.unsized_array_supported)
{
// For runtime-sized arrays, we can work around
// lack of standard support for this by simply having
@@ -11832,6 +11845,9 @@ void CompilerGLSL::bitcast_to_builtin_store(uint32_t target_id, std::string &exp
void CompilerGLSL::convert_non_uniform_expression(const SPIRType &type, std::string &expr)
{
if (*backend.nonuniform_qualifier == '\0')
return;
// Handle SPV_EXT_descriptor_indexing.
if (type.basetype == SPIRType::Sampler || type.basetype == SPIRType::SampledImage ||
type.basetype == SPIRType::Image)

View File

@@ -99,6 +99,10 @@ public:
// In non-Vulkan GLSL, emit push constant blocks as UBOs rather than plain uniforms.
bool emit_push_constant_as_uniform_buffer = false;
// Always emit uniform blocks as plain uniforms, regardless of the GLSL version, even when UBOs are supported.
// Does not apply to shader storage or push constant blocks.
bool emit_uniform_buffer_as_plain_uniforms = false;
enum Precision
{
DontCare,
@@ -375,7 +379,7 @@ protected:
const char *nonuniform_qualifier = "nonuniformEXT";
bool swizzle_is_function = false;
bool shared_is_implied = false;
bool flexible_member_array_supported = true;
bool unsized_array_supported = true;
bool explicit_struct_type = false;
bool use_initializer_list = false;
bool use_typed_initializer_list = false;

View File

@@ -4508,6 +4508,25 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
HLSL_UFOP(reversebits);
break;
case OpArrayLength:
{
auto *var = maybe_get<SPIRVariable>(ops[2]);
if (!var)
SPIRV_CROSS_THROW("Array length must point directly to an SSBO block.");
auto &type = get<SPIRType>(var->basetype);
if (!has_decoration(type.self, DecorationBlock) && !has_decoration(type.self, DecorationBufferBlock))
SPIRV_CROSS_THROW("Array length expression must point to a block type.");
// This must be 32-bit uint, so we're good to go.
emit_uninitialized_temporary_expression(ops[0], ops[1]);
statement(to_expression(ops[2]), ".GetDimensions(", to_expression(ops[1]), ");");
uint32_t offset = type_struct_member_offset(type, ops[3]);
uint32_t stride = type_struct_member_array_stride(type, ops[3]);
statement(to_expression(ops[1]), " = (", to_expression(ops[1]), " - ", offset, ") / ", stride, ";");
break;
}
default:
CompilerGLSL::emit_instruction(instruction);
break;
@@ -4628,6 +4647,28 @@ uint32_t CompilerHLSL::remap_num_workgroups_builtin()
return variable_id;
}
void CompilerHLSL::validate_shader_model()
{
// Check for nonuniform qualifier.
// Instead of looping over all decorations to find this, just look at capabilities.
for (auto &cap : ir.declared_capabilities)
{
switch (cap)
{
case CapabilityShaderNonUniformEXT:
case CapabilityRuntimeDescriptorArrayEXT:
if (hlsl_options.shader_model < 51)
SPIRV_CROSS_THROW(
"Shader model 5.1 or higher is required to use bindless resources or NonUniformResourceIndex.");
default:
break;
}
}
if (ir.addressing_model != AddressingModelLogical)
SPIRV_CROSS_THROW("Only Logical addressing model can be used with HLSL.");
}
string CompilerHLSL::compile()
{
// Do not deal with ES-isms like precision, older extensions and such.
@@ -4644,7 +4685,7 @@ string CompilerHLSL::compile()
backend.basic_uint_type = "uint";
backend.swizzle_is_function = false;
backend.shared_is_implied = true;
backend.flexible_member_array_supported = false;
backend.unsized_array_supported = true;
backend.explicit_struct_type = false;
backend.use_initializer_list = true;
backend.use_constructor_splatting = false;
@@ -4653,8 +4694,10 @@ string CompilerHLSL::compile()
backend.can_declare_struct_inline = false;
backend.can_declare_arrays_inline = false;
backend.can_return_array = false;
backend.nonuniform_qualifier = "NonUniformResourceIndex";
build_function_control_flow_graphs_and_analyze();
validate_shader_model();
update_active_builtins();
analyze_image_and_sampler_usage();

View File

@@ -220,6 +220,8 @@ private:
// Custom root constant layout, which should be emitted
// when translating push constant ranges.
std::vector<RootConstants> root_constants_layout;
void validate_shader_model();
};
} // namespace SPIRV_CROSS_NAMESPACE

File diff suppressed because it is too large Load Diff

View File

@@ -152,11 +152,11 @@ static const uint32_t kPushConstDescSet = ~(0u);
// element to indicate the bindings for the push constants.
static const uint32_t kPushConstBinding = 0;
static const uint32_t kMaxArgumentBuffers = 8;
// Special constant used in a MSLResourceBinding binding
// element to indicate the buffer binding for swizzle buffers.
static const uint32_t kSwizzleBufferBinding = ~(1u);
// The current version of the aux buffer structure. It must be incremented any time a
// new field is added to the aux buffer.
#define SPIRV_CROSS_MSL_AUX_BUFFER_STRUCT_VERSION 1
static const uint32_t kMaxArgumentBuffers = 8;
// Decompiles SPIR-V to Metal Shading Language
class CompilerMSL : public CompilerGLSL
@@ -174,7 +174,7 @@ public:
Platform platform = macOS;
uint32_t msl_version = make_msl_version(1, 2);
uint32_t texel_buffer_texture_width = 4096; // Width of 2D Metal textures used as 1D texel buffers
uint32_t aux_buffer_index = 30;
uint32_t swizzle_buffer_index = 30;
uint32_t indirect_params_buffer_index = 29;
uint32_t shader_output_buffer_index = 28;
uint32_t shader_patch_output_buffer_index = 27;
@@ -243,10 +243,10 @@ public:
}
// Provide feedback to calling API to allow it to pass an auxiliary
// buffer if the shader needs it.
bool needs_aux_buffer() const
// swizzle buffer if the shader needs it.
bool needs_swizzle_buffer() const
{
return used_aux_buffer;
return used_swizzle_buffer;
}
// Provide feedback to calling API to allow it to pass an output
@@ -344,6 +344,12 @@ protected:
SPVFuncImplRowMajor4x2,
SPVFuncImplRowMajor4x3,
SPVFuncImplTextureSwizzle,
SPVFuncImplSubgroupBallot,
SPVFuncImplSubgroupBallotBitExtract,
SPVFuncImplSubgroupBallotFindLSB,
SPVFuncImplSubgroupBallotFindMSB,
SPVFuncImplSubgroupBallotBitCount,
SPVFuncImplSubgroupAllEqual,
SPVFuncImplArrayCopyMultidimMax = 6
};
@@ -354,6 +360,7 @@ protected:
void emit_header() override;
void emit_function_prototype(SPIRFunction &func, const Bitset &return_flags) override;
void emit_sampled_image_op(uint32_t result_type, uint32_t result_id, uint32_t image_id, uint32_t samp_id) override;
void emit_subgroup_op(const Instruction &i) override;
void emit_fixup() override;
std::string to_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index,
const std::string &qualifier = "");
@@ -477,7 +484,9 @@ protected:
uint32_t builtin_base_instance_id = 0;
uint32_t builtin_invocation_id_id = 0;
uint32_t builtin_primitive_id_id = 0;
uint32_t aux_buffer_id = 0;
uint32_t builtin_subgroup_invocation_id_id = 0;
uint32_t builtin_subgroup_size_id = 0;
uint32_t swizzle_buffer_id = 0;
void bitcast_to_builtin_store(uint32_t target_id, std::string &expr, const SPIRType &expr_type) override;
void bitcast_from_builtin_load(uint32_t source_id, std::string &expr, const SPIRType &expr_type) override;
@@ -515,9 +524,10 @@ protected:
bool needs_instance_idx_arg = false;
bool is_rasterization_disabled = false;
bool capture_output_to_buffer = false;
bool needs_aux_buffer_def = false;
bool used_aux_buffer = false;
bool needs_swizzle_buffer_def = false;
bool used_swizzle_buffer = false;
bool added_builtin_tess_level = false;
bool needs_subgroup_invocation_id = false;
std::string qual_pos_var_name;
std::string stage_in_var_name = "in";
std::string stage_out_var_name = "out";
@@ -561,6 +571,7 @@ protected:
bool suppress_missing_prototypes = false;
bool uses_atomics = false;
bool uses_resource_write = false;
bool needs_subgroup_invocation_id = false;
};
// OpcodeHandler that scans for uses of sampled images

View File

@@ -59,6 +59,7 @@ static bool is_valid_spirv_version(uint32_t version)
case 0x10100: // SPIR-V 1.1
case 0x10200: // SPIR-V 1.2
case 0x10300: // SPIR-V 1.3
case 0x10400: // SPIR-V 1.4
return true;
default:

View File

@@ -143,7 +143,7 @@ def cross_compile_msl(shader, spirv, opt, iterations, paths):
spirv_path = create_temporary()
msl_path = create_temporary(os.path.basename(shader))
spirv_cmd = [paths.spirv_as, '-o', spirv_path, shader]
spirv_cmd = [paths.spirv_as, '--target-env', 'vulkan1.1', '-o', spirv_path, shader]
if '.preserve.' in shader:
spirv_cmd.append('--preserve-numeric-ids')
@@ -220,13 +220,18 @@ def shader_to_win_path(shader):
ignore_fxc = False
def validate_shader_hlsl(shader, force_no_external_validation, paths):
subprocess.check_call([paths.glslang, '-e', 'main', '-D', '--target-env', 'vulkan1.1', '-V', shader])
if not '.nonuniformresource' in shader:
# glslang HLSL does not support this, so rely on fxc to test it.
subprocess.check_call([paths.glslang, '-e', 'main', '-D', '--target-env', 'vulkan1.1', '-V', shader])
is_no_fxc = '.nofxc.' in shader
global ignore_fxc
if (not ignore_fxc) and (not force_no_external_validation) and (not is_no_fxc):
try:
win_path = shader_to_win_path(shader)
subprocess.check_call(['fxc', '-nologo', shader_model_hlsl(shader), win_path])
args = ['fxc', '-nologo', shader_model_hlsl(shader), win_path]
if '.nonuniformresource.' in shader:
args.append('/enable_unbounded_descriptor_tables')
subprocess.check_call(args)
except OSError as oe:
if (oe.errno != errno.ENOENT): # Ignore not found errors
print('Failed to run FXC.')
@@ -253,7 +258,7 @@ def cross_compile_hlsl(shader, spirv, opt, force_no_external_validation, iterati
spirv_path = create_temporary()
hlsl_path = create_temporary(os.path.basename(shader))
spirv_cmd = [paths.spirv_as, '-o', spirv_path, shader]
spirv_cmd = [paths.spirv_as, '--target-env', 'vulkan1.1', '-o', spirv_path, shader]
if '.preserve.' in shader:
spirv_cmd.append('--preserve-numeric-ids')
@@ -281,7 +286,7 @@ def cross_compile_reflect(shader, spirv, opt, iterations, paths):
spirv_path = create_temporary()
reflect_path = create_temporary(os.path.basename(shader))
spirv_cmd = [paths.spirv_as, '-o', spirv_path, shader]
spirv_cmd = [paths.spirv_as, '--target-env', 'vulkan1.1', '-o', spirv_path, shader]
if '.preserve.' in shader:
spirv_cmd.append('--preserve-numeric-ids')
@@ -312,7 +317,7 @@ def cross_compile(shader, vulkan, spirv, invalid_spirv, eliminate, is_legacy, fl
if vulkan or spirv:
vulkan_glsl_path = create_temporary('vk' + os.path.basename(shader))
spirv_cmd = [paths.spirv_as, '-o', spirv_path, shader]
spirv_cmd = [paths.spirv_as, '--target-env', 'vulkan1.1', '-o', spirv_path, shader]
if '.preserve.' in shader:
spirv_cmd.append('--preserve-numeric-ids')

View File

@@ -116,12 +116,32 @@ int main(int argc, char **argv)
SpvId *buffer = NULL;
size_t word_count = 0;
if (argc != 2)
if (argc != 5)
return 1;
if (read_file(argv[1], &buffer, &word_count) < 0)
return 1;
unsigned abi_major, abi_minor, abi_patch;
spvc_get_version(&abi_major, &abi_minor, &abi_patch);
if (abi_major != strtoul(argv[2], NULL, 0))
{
fprintf(stderr, "VERSION_MAJOR mismatch!\n");
return 1;
}
if (abi_minor != strtoul(argv[3], NULL, 0))
{
fprintf(stderr, "VERSION_MINOR mismatch!\n");
return 1;
}
if (abi_patch != strtoul(argv[4], NULL, 0))
{
fprintf(stderr, "VERSION_PATCH mismatch!\n");
return 1;
}
SPVC_CHECKED_CALL(spvc_context_create(&context));
spvc_context_set_error_callback(context, error_callback, NULL);
SPVC_CHECKED_CALL(spvc_context_parse_spirv(context, buffer, word_count, &ir));

View File

@@ -70,7 +70,8 @@
<id value="18" vendor="Wine" tool="VKD3D Shader Compiler" comment="Contact wine-devel@winehq.org"/>
<id value="19" vendor="Clay" tool="Clay Shader Compiler" comment="Contact info@clayengine.com"/>
<id value="20" vendor="W3C WebGPU Group" tool="WHLSL Shader Translator" comment="https://github.com/gpuweb/WHLSL"/>
<unused start="21" end="0xFFFF" comment="Tool ID range reservable for future use by vendors"/>
<id value="21" vendor="Google" tool="Clspv" comment="Contact David Neto, dneto@google.com"/>
<unused start="22" end="0xFFFF" comment="Tool ID range reservable for future use by vendors"/>
</ids>
<!-- SECTION: SPIR-V Opcodes and Enumerants -->

View File

@@ -26,7 +26,7 @@
],
"magic_number" : "0x07230203",
"major_version" : 1,
"minor_version" : 3,
"minor_version" : 4,
"revision" : 1,
"instructions" : [
{
@@ -519,6 +519,7 @@
"operands" : [
{ "kind" : "IdRef", "name" : "'Target'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "MemoryAccess", "quantifier" : "?" },
{ "kind" : "MemoryAccess", "quantifier" : "?" }
]
},
@@ -529,6 +530,7 @@
{ "kind" : "IdRef", "name" : "'Target'" },
{ "kind" : "IdRef", "name" : "'Source'" },
{ "kind" : "IdRef", "name" : "'Size'" },
{ "kind" : "MemoryAccess", "quantifier" : "?" },
{ "kind" : "MemoryAccess", "quantifier" : "?" }
],
"capabilities" : [ "Addresses" ]
@@ -2100,7 +2102,8 @@
{ "kind" : "IdRef", "name" : "'Value'" },
{ "kind" : "IdRef", "name" : "'Comparator'" }
],
"capabilities" : [ "Kernel" ]
"capabilities" : [ "Kernel" ],
"lastVersion" : "1.3"
},
{
"opname" : "OpAtomicIIncrement",
@@ -3605,6 +3608,50 @@
"capabilities" : [ "GroupNonUniformQuad" ],
"version" : "1.3"
},
{
"opname" : "OpCopyLogical",
"opcode" : 400,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Operand'" }
],
"version" : "1.4"
},
{
"opname" : "OpPtrEqual",
"opcode" : 401,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Operand 1'" },
{ "kind" : "IdRef", "name" : "'Operand 2'" }
],
"version" : "1.4"
},
{
"opname" : "OpPtrNotEqual",
"opcode" : 402,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Operand 1'" },
{ "kind" : "IdRef", "name" : "'Operand 2'" }
],
"version" : "1.4"
},
{
"opname" : "OpPtrDiff",
"opcode" : 403,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Operand 1'" },
{ "kind" : "IdRef", "name" : "'Operand 2'" }
],
"capabilities" : [ "Addresses", "VariablePointers", "VariablePointersStorageBuffer" ],
"version" : "1.4"
},
{
"opname" : "OpSubgroupBallotKHR",
"opcode" : 4421,
@@ -3823,6 +3870,34 @@
"extensions" : [ "SPV_AMD_shader_fragment_mask" ],
"version" : "None"
},
{
"opname" : "OpImageSampleFootprintNV",
"opcode" : 5283,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Sampled Image'" },
{ "kind" : "IdRef", "name" : "'Coordinate'" },
{ "kind" : "IdRef", "name" : "'Granularity'" },
{ "kind" : "IdRef", "name" : "'Coarse'" },
{ "kind" : "ImageOperands", "quantifier" : "?" }
],
"capabilities" : [ "ImageFootprintNV" ],
"extensions" : [ "SPV_NV_shader_image_footprint" ],
"version" : "None"
},
{
"opname" : "OpGroupNonUniformPartitionNV",
"opcode" : 5296,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Value'" }
],
"capabilities" : [ "GroupNonUniformPartitionedNV" ],
"extensions" : [ "SPV_NV_shader_subgroup_partitioned" ],
"version" : "None"
},
{
"opname" : "OpWritePackedPrimitiveIndices4x8NV",
"opcode" : 5299,
@@ -3900,6 +3975,75 @@
"capabilities" : [ "RayTracingNV" ],
"extensions" : [ "SPV_NV_ray_tracing" ]
},
{
"opname" : "OpTypeCooperativeMatrixNV",
"opcode" : 5358,
"operands" : [
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Component Type'" },
{ "kind" : "IdScope", "name" : "'Execution'" },
{ "kind" : "IdRef", "name" : "'Rows'" },
{ "kind" : "IdRef", "name" : "'Columns'" }
],
"capabilities" : [ "CooperativeMatrixNV" ],
"extensions" : [ "SPV_NV_cooperative_matrix" ],
"version" : "None"
},
{
"opname" : "OpCooperativeMatrixLoadNV",
"opcode" : 5359,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Pointer'" },
{ "kind" : "IdRef", "name" : "'Stride'" },
{ "kind" : "IdRef", "name" : "'Column Major'" },
{ "kind" : "MemoryAccess", "quantifier" : "?" }
],
"capabilities" : [ "CooperativeMatrixNV" ],
"extensions" : [ "SPV_NV_cooperative_matrix" ],
"version" : "None"
},
{
"opname" : "OpCooperativeMatrixStoreNV",
"opcode" : 5360,
"operands" : [
{ "kind" : "IdRef", "name" : "'Pointer'" },
{ "kind" : "IdRef", "name" : "'Object'" },
{ "kind" : "IdRef", "name" : "'Stride'" },
{ "kind" : "IdRef", "name" : "'Column Major'" },
{ "kind" : "MemoryAccess", "quantifier" : "?" }
],
"capabilities" : [ "CooperativeMatrixNV" ],
"extensions" : [ "SPV_NV_cooperative_matrix" ],
"version" : "None"
},
{
"opname" : "OpCooperativeMatrixMulAddNV",
"opcode" : 5361,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'A'" },
{ "kind" : "IdRef", "name" : "'B'" },
{ "kind" : "IdRef", "name" : "'C'" }
],
"capabilities" : [ "CooperativeMatrixNV" ],
"extensions" : [ "SPV_NV_cooperative_matrix" ],
"version" : "None"
},
{
"opname" : "OpCooperativeMatrixLengthNV",
"opcode" : 5362,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Type'" }
],
"capabilities" : [ "CooperativeMatrixNV" ],
"extensions" : [ "SPV_NV_cooperative_matrix" ],
"version" : "None"
},
{
"opname" : "OpSubgroupShuffleINTEL",
"opcode" : 5571,
@@ -4021,6 +4165,214 @@
"capabilities" : [ "SubgroupImageMediaBlockIOINTEL" ],
"version" : "None"
},
{
"opname" : "OpUCountLeadingZerosINTEL",
"opcode" : 5585,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Operand'" }
],
"capabilities" : [ "IntegerFunctions2INTEL" ],
"version" : "None"
},
{
"opname" : "OpUCountTrailingZerosINTEL",
"opcode" : 5586,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Operand'" }
],
"capabilities" : [ "IntegerFunctions2INTEL" ],
"version" : "None"
},
{
"opname" : "OpAbsISubINTEL",
"opcode" : 5587,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Operand 1'" },
{ "kind" : "IdRef", "name" : "'Operand 2'" }
],
"capabilities" : [ "IntegerFunctions2INTEL" ],
"version" : "None"
},
{
"opname" : "OpAbsUSubINTEL",
"opcode" : 5588,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Operand 1'" },
{ "kind" : "IdRef", "name" : "'Operand 2'" }
],
"capabilities" : [ "IntegerFunctions2INTEL" ],
"version" : "None"
},
{
"opname" : "OpIAddSatINTEL",
"opcode" : 5589,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Operand 1'" },
{ "kind" : "IdRef", "name" : "'Operand 2'" }
],
"capabilities" : [ "IntegerFunctions2INTEL" ],
"version" : "None"
},
{
"opname" : "OpUAddSatINTEL",
"opcode" : 5590,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Operand 1'" },
{ "kind" : "IdRef", "name" : "'Operand 2'" }
],
"capabilities" : [ "IntegerFunctions2INTEL" ],
"version" : "None"
},
{
"opname" : "OpIAverageINTEL",
"opcode" : 5591,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Operand 1'" },
{ "kind" : "IdRef", "name" : "'Operand 2'" }
],
"capabilities" : [ "IntegerFunctions2INTEL" ],
"version" : "None"
},
{
"opname" : "OpUAverageINTEL",
"opcode" : 5592,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Operand 1'" },
{ "kind" : "IdRef", "name" : "'Operand 2'" }
],
"capabilities" : [ "IntegerFunctions2INTEL" ],
"version" : "None"
},
{
"opname" : "OpIAverageRoundedINTEL",
"opcode" : 5593,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Operand 1'" },
{ "kind" : "IdRef", "name" : "'Operand 2'" }
],
"capabilities" : [ "IntegerFunctions2INTEL" ],
"version" : "None"
},
{
"opname" : "OpUAverageRoundedINTEL",
"opcode" : 5594,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Operand 1'" },
{ "kind" : "IdRef", "name" : "'Operand 2'" }
],
"capabilities" : [ "IntegerFunctions2INTEL" ],
"version" : "None"
},
{
"opname" : "OpISubSatINTEL",
"opcode" : 5595,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Operand 1'" },
{ "kind" : "IdRef", "name" : "'Operand 2'" }
],
"capabilities" : [ "IntegerFunctions2INTEL" ],
"version" : "None"
},
{
"opname" : "OpUSubSatINTEL",
"opcode" : 5596,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Operand 1'" },
{ "kind" : "IdRef", "name" : "'Operand 2'" }
],
"capabilities" : [ "IntegerFunctions2INTEL" ],
"version" : "None"
},
{
"opname" : "OpIMul32x16INTEL",
"opcode" : 5597,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Operand 1'" },
{ "kind" : "IdRef", "name" : "'Operand 2'" }
],
"capabilities" : [ "IntegerFunctions2INTEL" ],
"version" : "None"
},
{
"opname" : "OpUMul32x16INTEL",
"opcode" : 5598,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Operand 1'" },
{ "kind" : "IdRef", "name" : "'Operand 2'" }
],
"capabilities" : [ "IntegerFunctions2INTEL" ],
"version" : "None"
},
{
"opname" : "OpDecorateString",
"opcode" : 5632,
"operands" : [
{ "kind" : "IdRef", "name" : "'Target'" },
{ "kind" : "Decoration" }
],
"extensions" : [ "SPV_GOOGLE_decorate_string", "SPV_GOOGLE_hlsl_functionality1" ],
"version" : "1.4"
},
{
"opname" : "OpDecorateStringGOOGLE",
"opcode" : 5632,
"operands" : [
{ "kind" : "IdRef", "name" : "'Target'" },
{ "kind" : "Decoration" }
],
"extensions" : [ "SPV_GOOGLE_decorate_string", "SPV_GOOGLE_hlsl_functionality1" ],
"version" : "1.4"
},
{
"opname" : "OpMemberDecorateString",
"opcode" : 5633,
"operands" : [
{ "kind" : "IdRef", "name" : "'Struct Type'" },
{ "kind" : "LiteralInteger", "name" : "'Member'" },
{ "kind" : "Decoration" }
],
"extensions" : [ "SPV_GOOGLE_decorate_string", "SPV_GOOGLE_hlsl_functionality1" ],
"version" : "1.4"
},
{
"opname" : "OpMemberDecorateStringGOOGLE",
"opcode" : 5633,
"operands" : [
{ "kind" : "IdRef", "name" : "'Struct Type'" },
{ "kind" : "LiteralInteger", "name" : "'Member'" },
{ "kind" : "Decoration" }
],
"extensions" : [ "SPV_GOOGLE_decorate_string", "SPV_GOOGLE_hlsl_functionality1" ],
"version" : "1.4"
},
{
"opname" : "OpVmeImageINTEL",
"opcode" : 5699,
@@ -5419,124 +5771,6 @@
],
"capabilities" : [ "SubgroupAvcMotionEstimationINTEL" ],
"version" : "None"
},
{
"opname" : "OpDecorateStringGOOGLE",
"opcode" : 5632,
"operands" : [
{ "kind" : "IdRef", "name" : "'Target'" },
{ "kind" : "Decoration" }
],
"extensions" : [ "SPV_GOOGLE_decorate_string", "SPV_GOOGLE_hlsl_functionality1" ],
"version" : "None"
},
{
"opname" : "OpMemberDecorateStringGOOGLE",
"opcode" : 5633,
"operands" : [
{ "kind" : "IdRef", "name" : "'Struct Type'" },
{ "kind" : "LiteralInteger", "name" : "'Member'" },
{ "kind" : "Decoration" }
],
"extensions" : [ "SPV_GOOGLE_decorate_string", "SPV_GOOGLE_hlsl_functionality1" ],
"version" : "None"
},
{
"opname" : "OpGroupNonUniformPartitionNV",
"opcode" : 5296,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Value'" }
],
"capabilities" : [ "GroupNonUniformPartitionedNV" ],
"extensions" : [ "SPV_NV_shader_subgroup_partitioned" ],
"version" : "None"
},
{
"opname" : "OpImageSampleFootprintNV",
"opcode" : 5283,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Sampled Image'" },
{ "kind" : "IdRef", "name" : "'Coordinate'" },
{ "kind" : "IdRef", "name" : "'Granularity'" },
{ "kind" : "IdRef", "name" : "'Coarse'" },
{ "kind" : "ImageOperands", "quantifier" : "?" }
],
"capabilities" : [ "ImageFootprintNV" ],
"extensions" : [ "SPV_NV_shader_image_footprint" ],
"version" : "None"
},
{
"opname" : "OpTypeCooperativeMatrixNV",
"opcode" : 5358,
"operands" : [
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Component Type'" },
{ "kind" : "IdScope", "name" : "'Execution'" },
{ "kind" : "IdRef", "name" : "'Rows'" },
{ "kind" : "IdRef", "name" : "'Columns'" }
],
"capabilities" : [ "CooperativeMatrixNV" ],
"extensions" : [ "SPV_NV_cooperative_matrix" ],
"version" : "None"
},
{
"opname" : "OpCooperativeMatrixLoadNV",
"opcode" : 5359,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Pointer'" },
{ "kind" : "IdRef", "name" : "'Stride'" },
{ "kind" : "IdRef", "name" : "'Column Major'" },
{ "kind" : "MemoryAccess", "quantifier" : "?" }
],
"capabilities" : [ "CooperativeMatrixNV" ],
"extensions" : [ "SPV_NV_cooperative_matrix" ],
"version" : "None"
},
{
"opname" : "OpCooperativeMatrixStoreNV",
"opcode" : 5360,
"operands" : [
{ "kind" : "IdRef", "name" : "'Pointer'" },
{ "kind" : "IdRef", "name" : "'Object'" },
{ "kind" : "IdRef", "name" : "'Stride'" },
{ "kind" : "IdRef", "name" : "'Column Major'" },
{ "kind" : "MemoryAccess", "quantifier" : "?" }
],
"capabilities" : [ "CooperativeMatrixNV" ],
"extensions" : [ "SPV_NV_cooperative_matrix" ],
"version" : "None"
},
{
"opname" : "OpCooperativeMatrixMulAddNV",
"opcode" : 5361,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'A'" },
{ "kind" : "IdRef", "name" : "'B'" },
{ "kind" : "IdRef", "name" : "'C'" }
],
"capabilities" : [ "CooperativeMatrixNV" ],
"extensions" : [ "SPV_NV_cooperative_matrix" ],
"version" : "None"
},
{
"opname" : "OpCooperativeMatrixLengthNV",
"opcode" : 5362,
"operands" : [
{ "kind" : "IdResultType" },
{ "kind" : "IdResult" },
{ "kind" : "IdRef", "name" : "'Type'" }
],
"capabilities" : [ "CooperativeMatrixNV" ],
"extensions" : [ "SPV_NV_cooperative_matrix" ],
"version" : "None"
}
],
"operand_kinds" : [
@@ -5634,6 +5868,16 @@
"enumerant" : "VolatileTexelKHR",
"value" : "0x0800",
"capabilities" : [ "VulkanMemoryModelKHR" ]
},
{
"enumerant" : "SignExtend",
"value" : "0x1000",
"version" : "1.4"
},
{
"enumerant" : "ZeroExtend",
"value" : "0x2000",
"version" : "1.4"
}
]
},
@@ -5718,6 +5962,46 @@
{ "kind" : "LiteralInteger" }
],
"version" : "1.1"
},
{
"enumerant" : "MinIterations",
"value" : "0x0010",
"parameters" : [
{ "kind" : "LiteralInteger" }
],
"version" : "1.4"
},
{
"enumerant" : "MaxIterations",
"value" : "0x0020",
"parameters" : [
{ "kind" : "LiteralInteger" }
],
"version" : "1.4"
},
{
"enumerant" : "IterationMultiple",
"value" : "0x0040",
"parameters" : [
{ "kind" : "LiteralInteger" }
],
"version" : "1.4"
},
{
"enumerant" : "PeelCount",
"value" : "0x0080",
"parameters" : [
{ "kind" : "LiteralInteger" }
],
"version" : "1.4"
},
{
"enumerant" : "PartialCount",
"value" : "0x0100",
"parameters" : [
{ "kind" : "LiteralInteger" }
],
"version" : "1.4"
}
]
},
@@ -6284,55 +6568,55 @@
"extensions" : [ "SPV_KHR_post_depth_coverage" ],
"version" : "None"
},
{
{
"enumerant" : "DenormPreserve",
"value" : 4459,
"capabilities" : [ "DenormPreserve"],
"capabilities" : [ "DenormPreserve" ],
"extensions" : [ "SPV_KHR_float_controls" ],
"parameters" : [
{ "kind" : "LiteralInteger", "name" : "'Target Width'" }
],
"version" : "None"
"version" : "1.4"
},
{
"enumerant" : "DenormFlushToZero",
"value" : 4460,
"capabilities" : [ "DenormFlushToZero"],
"capabilities" : [ "DenormFlushToZero" ],
"extensions" : [ "SPV_KHR_float_controls" ],
"parameters" : [
{ "kind" : "LiteralInteger", "name" : "'Target Width'" }
],
"version" : "None"
"version" : "1.4"
},
{
"enumerant" : "SignedZeroInfNanPreserve",
"value" : 4461,
"capabilities" : [ "SignedZeroInfNanPreserve"],
"capabilities" : [ "SignedZeroInfNanPreserve" ],
"extensions" : [ "SPV_KHR_float_controls" ],
"parameters" : [
{ "kind" : "LiteralInteger", "name" : "'Target Width'" }
],
"version" : "None"
"version" : "1.4"
},
{
"enumerant" : "RoundingModeRTE",
"value" : 4462,
"capabilities" : [ "RoundingModeRTE"],
"capabilities" : [ "RoundingModeRTE" ],
"extensions" : [ "SPV_KHR_float_controls" ],
"parameters" : [
{ "kind" : "LiteralInteger", "name" : "'Target Width'" }
],
"version" : "None"
"version" : "1.4"
},
{
"enumerant" : "RoundingModeRTZ",
"value" : 4463,
"capabilities" : [ "RoundingModeRTZ"],
"capabilities" : [ "RoundingModeRTZ" ],
"extensions" : [ "SPV_KHR_float_controls" ],
"parameters" : [
{ "kind" : "LiteralInteger", "name" : "'Target Width'" }
],
"version" : "None"
"version" : "1.4"
},
{
"enumerant" : "StencilRefReplacingEXT",
@@ -7112,7 +7396,8 @@
{
"enumerant" : "BufferBlock",
"value" : 3,
"capabilities" : [ "Shader" ]
"capabilities" : [ "Shader" ],
"lastVersion" : "1.3"
},
{
"enumerant" : "RowMajor",
@@ -7226,6 +7511,15 @@
"value" : 26,
"capabilities" : [ "Shader" ]
},
{
"enumerant" : "UniformId",
"value" : 27,
"capabilities" : [ "Shader" ],
"parameters" : [
{ "kind" : "IdScope", "name" : "'Execution'" }
],
"version" : "1.4"
},
{
"enumerant" : "SaturatedConversion",
"value" : 28,
@@ -7387,13 +7681,13 @@
"enumerant" : "NoSignedWrap",
"value" : 4469,
"extensions" : [ "SPV_KHR_no_integer_wrap_decoration" ],
"version" : "None"
"version" : "1.4"
},
{
"enumerant" : "NoUnsignedWrap",
"value" : 4470,
"extensions" : [ "SPV_KHR_no_integer_wrap_decoration" ],
"version" : "None"
"version" : "1.4"
},
{
"enumerant" : "ExplicitInterpAMD",
@@ -7452,7 +7746,7 @@
"extensions" : [ "SPV_NV_mesh_shader" ],
"version" : "None"
},
{
{
"enumerant" : "PerVertexNV",
"value" : 5285,
"capabilities" : [ "FragmentBarycentricNV" ],
@@ -7464,6 +7758,14 @@
"value" : 5300,
"capabilities" : [ "ShaderNonUniformEXT" ]
},
{
"enumerant" : "CounterBuffer",
"value" : 5634,
"parameters" : [
{ "kind" : "IdRef", "name" : "'Counter Buffer'" }
],
"version" : "1.4"
},
{
"enumerant" : "HlslCounterBufferGOOGLE",
"value" : 5634,
@@ -7473,6 +7775,14 @@
"extensions" : [ "SPV_GOOGLE_hlsl_functionality1" ],
"version" : "None"
},
{
"enumerant" : "UserSemantic",
"value" : 5635,
"parameters" : [
{ "kind" : "LiteralString", "name" : "'Semantic'" }
],
"version" : "1.4"
},
{
"enumerant" : "HlslSemanticGOOGLE",
"value" : 5635,
@@ -8260,7 +8570,8 @@
},
{
"enumerant" : "Groups",
"value" : 18
"value" : 18,
"extensions" : [ "SPV_AMD_shader_ballot" ]
},
{
"enumerant" : "DeviceEnqueue",
@@ -8638,31 +8949,31 @@
"enumerant" : "DenormPreserve",
"value" : 4464,
"extensions" : [ "SPV_KHR_float_controls" ],
"version" : "None"
"version" : "1.4"
},
{
"enumerant" : "DenormFlushToZero",
"value" : 4465,
"extensions" : [ "SPV_KHR_float_controls" ],
"version" : "None"
"version" : "1.4"
},
{
"enumerant" : "SignedZeroInfNanPreserve",
"value" : 4466,
"extensions" : [ "SPV_KHR_float_controls" ],
"version" : "None"
"version" : "1.4"
},
{
"enumerant" : "RoundingModeRTE",
"value" : 4467,
"extensions" : [ "SPV_KHR_float_controls" ],
"version" : "None"
"version" : "1.4"
},
{
"enumerant" : "RoundingModeRTZ",
"value" : 4468,
"extensions" : [ "SPV_KHR_float_controls" ],
"version" : "None"
"version" : "1.4"
},
{
"enumerant" : "Float16ImageAMD",
@@ -8877,6 +9188,13 @@
"extensions" : [ "SPV_INTEL_media_block_io" ],
"version" : "None"
},
{
"enumerant" : "IntegerFunctions2INTEL",
"value" : 5584,
"capabilities" : [ "Shader" ],
"extensions" : [ "SPV_INTEL_shader_integer_functions2" ],
"version" : "None"
},
{
"enumerant" : "SubgroupAvcMotionEstimationINTEL",
"value" : 5696,

View File

@@ -48,8 +48,8 @@ namespace Spv
public static class Specification
{
public const uint MagicNumber = 0x07230203;
public const uint Version = 0x00010300;
public const uint Revision = 7;
public const uint Version = 0x00010400;
public const uint Revision = 1;
public const uint OpCodeMask = 0xffff;
public const uint WordCountShift = 16;
@@ -305,6 +305,8 @@ namespace Spv
MakeTexelVisibleKHR = 9,
NonPrivateTexelKHR = 10,
VolatileTexelKHR = 11,
SignExtend = 12,
ZeroExtend = 13,
}
public enum ImageOperandsMask
@@ -322,6 +324,8 @@ namespace Spv
MakeTexelVisibleKHR = 0x00000200,
NonPrivateTexelKHR = 0x00000400,
VolatileTexelKHR = 0x00000800,
SignExtend = 0x00001000,
ZeroExtend = 0x00002000,
}
public enum FPFastMathModeShift
@@ -404,6 +408,7 @@ namespace Spv
NonWritable = 24,
NonReadable = 25,
Uniform = 26,
UniformId = 27,
SaturatedConversion = 28,
Stream = 29,
Location = 30,
@@ -438,8 +443,10 @@ namespace Spv
NonUniformEXT = 5300,
RestrictPointerEXT = 5355,
AliasedPointerEXT = 5356,
CounterBuffer = 5634,
HlslCounterBufferGOOGLE = 5634,
HlslSemanticGOOGLE = 5635,
UserSemantic = 5635,
}
public enum BuiltIn
@@ -563,6 +570,11 @@ namespace Spv
DontUnroll = 1,
DependencyInfinite = 2,
DependencyLength = 3,
MinIterations = 4,
MaxIterations = 5,
IterationMultiple = 6,
PeelCount = 7,
PartialCount = 8,
}
public enum LoopControlMask
@@ -572,6 +584,11 @@ namespace Spv
DontUnroll = 0x00000002,
DependencyInfinite = 0x00000004,
DependencyLength = 0x00000008,
MinIterations = 0x00000010,
MaxIterations = 0x00000020,
IterationMultiple = 0x00000040,
PeelCount = 0x00000080,
PartialCount = 0x00000100,
}
public enum FunctionControlShift
@@ -820,6 +837,7 @@ namespace Spv
SubgroupBufferBlockIOINTEL = 5569,
SubgroupImageBlockIOINTEL = 5570,
SubgroupImageMediaBlockIOINTEL = 5579,
IntegerFunctions2INTEL = 5584,
SubgroupAvcMotionEstimationINTEL = 5696,
SubgroupAvcMotionEstimationIntraINTEL = 5697,
SubgroupAvcMotionEstimationChromaINTEL = 5698,
@@ -1167,6 +1185,10 @@ namespace Spv
OpGroupNonUniformLogicalXor = 364,
OpGroupNonUniformQuadBroadcast = 365,
OpGroupNonUniformQuadSwap = 366,
OpCopyLogical = 400,
OpPtrEqual = 401,
OpPtrNotEqual = 402,
OpPtrDiff = 403,
OpSubgroupBallotKHR = 4421,
OpSubgroupFirstInvocationKHR = 4422,
OpSubgroupAllKHR = 4428,
@@ -1207,7 +1229,23 @@ namespace Spv
OpSubgroupImageBlockWriteINTEL = 5578,
OpSubgroupImageMediaBlockReadINTEL = 5580,
OpSubgroupImageMediaBlockWriteINTEL = 5581,
OpUCountLeadingZerosINTEL = 5585,
OpUCountTrailingZerosINTEL = 5586,
OpAbsISubINTEL = 5587,
OpAbsUSubINTEL = 5588,
OpIAddSatINTEL = 5589,
OpUAddSatINTEL = 5590,
OpIAverageINTEL = 5591,
OpUAverageINTEL = 5592,
OpIAverageRoundedINTEL = 5593,
OpUAverageRoundedINTEL = 5594,
OpISubSatINTEL = 5595,
OpUSubSatINTEL = 5596,
OpIMul32x16INTEL = 5597,
OpUMul32x16INTEL = 5598,
OpDecorateString = 5632,
OpDecorateStringGOOGLE = 5632,
OpMemberDecorateString = 5633,
OpMemberDecorateStringGOOGLE = 5633,
OpVmeImageINTEL = 5699,
OpTypeVmeImageINTEL = 5700,

View File

@@ -53,12 +53,12 @@
typedef unsigned int SpvId;
#define SPV_VERSION 0x10300
#define SPV_REVISION 7
#define SPV_VERSION 0x10400
#define SPV_REVISION 1
static const unsigned int SpvMagicNumber = 0x07230203;
static const unsigned int SpvVersion = 0x00010300;
static const unsigned int SpvRevision = 7;
static const unsigned int SpvVersion = 0x00010400;
static const unsigned int SpvRevision = 1;
static const unsigned int SpvOpCodeMask = 0xffff;
static const unsigned int SpvWordCountShift = 16;
@@ -313,6 +313,8 @@ typedef enum SpvImageOperandsShift_ {
SpvImageOperandsMakeTexelVisibleKHRShift = 9,
SpvImageOperandsNonPrivateTexelKHRShift = 10,
SpvImageOperandsVolatileTexelKHRShift = 11,
SpvImageOperandsSignExtendShift = 12,
SpvImageOperandsZeroExtendShift = 13,
SpvImageOperandsMax = 0x7fffffff,
} SpvImageOperandsShift;
@@ -330,6 +332,8 @@ typedef enum SpvImageOperandsMask_ {
SpvImageOperandsMakeTexelVisibleKHRMask = 0x00000200,
SpvImageOperandsNonPrivateTexelKHRMask = 0x00000400,
SpvImageOperandsVolatileTexelKHRMask = 0x00000800,
SpvImageOperandsSignExtendMask = 0x00001000,
SpvImageOperandsZeroExtendMask = 0x00002000,
} SpvImageOperandsMask;
typedef enum SpvFPFastMathModeShift_ {
@@ -410,6 +414,7 @@ typedef enum SpvDecoration_ {
SpvDecorationNonWritable = 24,
SpvDecorationNonReadable = 25,
SpvDecorationUniform = 26,
SpvDecorationUniformId = 27,
SpvDecorationSaturatedConversion = 28,
SpvDecorationStream = 29,
SpvDecorationLocation = 30,
@@ -444,8 +449,10 @@ typedef enum SpvDecoration_ {
SpvDecorationNonUniformEXT = 5300,
SpvDecorationRestrictPointerEXT = 5355,
SpvDecorationAliasedPointerEXT = 5356,
SpvDecorationCounterBuffer = 5634,
SpvDecorationHlslCounterBufferGOOGLE = 5634,
SpvDecorationHlslSemanticGOOGLE = 5635,
SpvDecorationUserSemantic = 5635,
SpvDecorationMax = 0x7fffffff,
} SpvDecoration;
@@ -568,6 +575,11 @@ typedef enum SpvLoopControlShift_ {
SpvLoopControlDontUnrollShift = 1,
SpvLoopControlDependencyInfiniteShift = 2,
SpvLoopControlDependencyLengthShift = 3,
SpvLoopControlMinIterationsShift = 4,
SpvLoopControlMaxIterationsShift = 5,
SpvLoopControlIterationMultipleShift = 6,
SpvLoopControlPeelCountShift = 7,
SpvLoopControlPartialCountShift = 8,
SpvLoopControlMax = 0x7fffffff,
} SpvLoopControlShift;
@@ -577,6 +589,11 @@ typedef enum SpvLoopControlMask_ {
SpvLoopControlDontUnrollMask = 0x00000002,
SpvLoopControlDependencyInfiniteMask = 0x00000004,
SpvLoopControlDependencyLengthMask = 0x00000008,
SpvLoopControlMinIterationsMask = 0x00000010,
SpvLoopControlMaxIterationsMask = 0x00000020,
SpvLoopControlIterationMultipleMask = 0x00000040,
SpvLoopControlPeelCountMask = 0x00000080,
SpvLoopControlPartialCountMask = 0x00000100,
} SpvLoopControlMask;
typedef enum SpvFunctionControlShift_ {
@@ -820,6 +837,7 @@ typedef enum SpvCapability_ {
SpvCapabilitySubgroupBufferBlockIOINTEL = 5569,
SpvCapabilitySubgroupImageBlockIOINTEL = 5570,
SpvCapabilitySubgroupImageMediaBlockIOINTEL = 5579,
SpvCapabilityIntegerFunctions2INTEL = 5584,
SpvCapabilitySubgroupAvcMotionEstimationINTEL = 5696,
SpvCapabilitySubgroupAvcMotionEstimationIntraINTEL = 5697,
SpvCapabilitySubgroupAvcMotionEstimationChromaINTEL = 5698,
@@ -1167,6 +1185,10 @@ typedef enum SpvOp_ {
SpvOpGroupNonUniformLogicalXor = 364,
SpvOpGroupNonUniformQuadBroadcast = 365,
SpvOpGroupNonUniformQuadSwap = 366,
SpvOpCopyLogical = 400,
SpvOpPtrEqual = 401,
SpvOpPtrNotEqual = 402,
SpvOpPtrDiff = 403,
SpvOpSubgroupBallotKHR = 4421,
SpvOpSubgroupFirstInvocationKHR = 4422,
SpvOpSubgroupAllKHR = 4428,
@@ -1207,7 +1229,23 @@ typedef enum SpvOp_ {
SpvOpSubgroupImageBlockWriteINTEL = 5578,
SpvOpSubgroupImageMediaBlockReadINTEL = 5580,
SpvOpSubgroupImageMediaBlockWriteINTEL = 5581,
SpvOpUCountLeadingZerosINTEL = 5585,
SpvOpUCountTrailingZerosINTEL = 5586,
SpvOpAbsISubINTEL = 5587,
SpvOpAbsUSubINTEL = 5588,
SpvOpIAddSatINTEL = 5589,
SpvOpUAddSatINTEL = 5590,
SpvOpIAverageINTEL = 5591,
SpvOpUAverageINTEL = 5592,
SpvOpIAverageRoundedINTEL = 5593,
SpvOpUAverageRoundedINTEL = 5594,
SpvOpISubSatINTEL = 5595,
SpvOpUSubSatINTEL = 5596,
SpvOpIMul32x16INTEL = 5597,
SpvOpUMul32x16INTEL = 5598,
SpvOpDecorateString = 5632,
SpvOpDecorateStringGOOGLE = 5632,
SpvOpMemberDecorateString = 5633,
SpvOpMemberDecorateStringGOOGLE = 5633,
SpvOpVmeImageINTEL = 5699,
SpvOpTypeVmeImageINTEL = 5700,
@@ -1675,6 +1713,10 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy
case SpvOpGroupNonUniformLogicalXor: *hasResult = true; *hasResultType = true; break;
case SpvOpGroupNonUniformQuadBroadcast: *hasResult = true; *hasResultType = true; break;
case SpvOpGroupNonUniformQuadSwap: *hasResult = true; *hasResultType = true; break;
case SpvOpCopyLogical: *hasResult = true; *hasResultType = true; break;
case SpvOpPtrEqual: *hasResult = true; *hasResultType = true; break;
case SpvOpPtrNotEqual: *hasResult = true; *hasResultType = true; break;
case SpvOpPtrDiff: *hasResult = true; *hasResultType = true; break;
case SpvOpSubgroupBallotKHR: *hasResult = true; *hasResultType = true; break;
case SpvOpSubgroupFirstInvocationKHR: *hasResult = true; *hasResultType = true; break;
case SpvOpSubgroupAllKHR: *hasResult = true; *hasResultType = true; break;
@@ -1691,6 +1733,8 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy
case SpvOpGroupSMaxNonUniformAMD: *hasResult = true; *hasResultType = true; break;
case SpvOpFragmentMaskFetchAMD: *hasResult = true; *hasResultType = true; break;
case SpvOpFragmentFetchAMD: *hasResult = true; *hasResultType = true; break;
case SpvOpImageSampleFootprintNV: *hasResult = true; *hasResultType = true; break;
case SpvOpGroupNonUniformPartitionNV: *hasResult = true; *hasResultType = true; break;
case SpvOpWritePackedPrimitiveIndices4x8NV: *hasResult = false; *hasResultType = false; break;
case SpvOpReportIntersectionNV: *hasResult = true; *hasResultType = true; break;
case SpvOpIgnoreIntersectionNV: *hasResult = false; *hasResultType = false; break;
@@ -1698,6 +1742,11 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy
case SpvOpTraceNV: *hasResult = false; *hasResultType = false; break;
case SpvOpTypeAccelerationStructureNV: *hasResult = true; *hasResultType = false; break;
case SpvOpExecuteCallableNV: *hasResult = false; *hasResultType = false; break;
case SpvOpTypeCooperativeMatrixNV: *hasResult = true; *hasResultType = false; break;
case SpvOpCooperativeMatrixLoadNV: *hasResult = true; *hasResultType = true; break;
case SpvOpCooperativeMatrixStoreNV: *hasResult = false; *hasResultType = false; break;
case SpvOpCooperativeMatrixMulAddNV: *hasResult = true; *hasResultType = true; break;
case SpvOpCooperativeMatrixLengthNV: *hasResult = true; *hasResultType = true; break;
case SpvOpSubgroupShuffleINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpSubgroupShuffleDownINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpSubgroupShuffleUpINTEL: *hasResult = true; *hasResultType = true; break;
@@ -1708,6 +1757,22 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy
case SpvOpSubgroupImageBlockWriteINTEL: *hasResult = false; *hasResultType = false; break;
case SpvOpSubgroupImageMediaBlockReadINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpSubgroupImageMediaBlockWriteINTEL: *hasResult = false; *hasResultType = false; break;
case SpvOpUCountLeadingZerosINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpUCountTrailingZerosINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpAbsISubINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpAbsUSubINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpIAddSatINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpUAddSatINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpIAverageINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpUAverageINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpIAverageRoundedINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpUAverageRoundedINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpISubSatINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpUSubSatINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpIMul32x16INTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpUMul32x16INTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpDecorateString: *hasResult = false; *hasResultType = false; break;
case SpvOpMemberDecorateString: *hasResult = false; *hasResultType = false; break;
case SpvOpVmeImageINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpTypeVmeImageINTEL: *hasResult = true; *hasResultType = false; break;
case SpvOpTypeAvcImePayloadINTEL: *hasResult = true; *hasResultType = false; break;
@@ -1826,15 +1891,6 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy
case SpvOpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpSubgroupAvcSicGetInterRawSadsINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpDecorateStringGOOGLE: *hasResult = false; *hasResultType = false; break;
case SpvOpMemberDecorateStringGOOGLE: *hasResult = false; *hasResultType = false; break;
case SpvOpGroupNonUniformPartitionNV: *hasResult = true; *hasResultType = true; break;
case SpvOpImageSampleFootprintNV: *hasResult = true; *hasResultType = true; break;
case SpvOpTypeCooperativeMatrixNV: *hasResult = true; *hasResultType = false; break;
case SpvOpCooperativeMatrixLoadNV: *hasResult = true; *hasResultType = true; break;
case SpvOpCooperativeMatrixStoreNV: *hasResult = false; *hasResultType = false; break;
case SpvOpCooperativeMatrixMulAddNV: *hasResult = true; *hasResultType = true; break;
case SpvOpCooperativeMatrixLengthNV: *hasResult = true; *hasResultType = true; break;
}
}
#endif /* SPV_ENABLE_UTILITY_CODE */

View File

@@ -49,12 +49,12 @@ namespace spv {
typedef unsigned int Id;
#define SPV_VERSION 0x10300
#define SPV_REVISION 7
#define SPV_VERSION 0x10400
#define SPV_REVISION 1
static const unsigned int MagicNumber = 0x07230203;
static const unsigned int Version = 0x00010300;
static const unsigned int Revision = 7;
static const unsigned int Version = 0x00010400;
static const unsigned int Revision = 1;
static const unsigned int OpCodeMask = 0xffff;
static const unsigned int WordCountShift = 16;
@@ -309,6 +309,8 @@ enum ImageOperandsShift {
ImageOperandsMakeTexelVisibleKHRShift = 9,
ImageOperandsNonPrivateTexelKHRShift = 10,
ImageOperandsVolatileTexelKHRShift = 11,
ImageOperandsSignExtendShift = 12,
ImageOperandsZeroExtendShift = 13,
ImageOperandsMax = 0x7fffffff,
};
@@ -326,6 +328,8 @@ enum ImageOperandsMask {
ImageOperandsMakeTexelVisibleKHRMask = 0x00000200,
ImageOperandsNonPrivateTexelKHRMask = 0x00000400,
ImageOperandsVolatileTexelKHRMask = 0x00000800,
ImageOperandsSignExtendMask = 0x00001000,
ImageOperandsZeroExtendMask = 0x00002000,
};
enum FPFastMathModeShift {
@@ -406,6 +410,7 @@ enum Decoration {
DecorationNonWritable = 24,
DecorationNonReadable = 25,
DecorationUniform = 26,
DecorationUniformId = 27,
DecorationSaturatedConversion = 28,
DecorationStream = 29,
DecorationLocation = 30,
@@ -440,8 +445,10 @@ enum Decoration {
DecorationNonUniformEXT = 5300,
DecorationRestrictPointerEXT = 5355,
DecorationAliasedPointerEXT = 5356,
DecorationCounterBuffer = 5634,
DecorationHlslCounterBufferGOOGLE = 5634,
DecorationHlslSemanticGOOGLE = 5635,
DecorationUserSemantic = 5635,
DecorationMax = 0x7fffffff,
};
@@ -564,6 +571,11 @@ enum LoopControlShift {
LoopControlDontUnrollShift = 1,
LoopControlDependencyInfiniteShift = 2,
LoopControlDependencyLengthShift = 3,
LoopControlMinIterationsShift = 4,
LoopControlMaxIterationsShift = 5,
LoopControlIterationMultipleShift = 6,
LoopControlPeelCountShift = 7,
LoopControlPartialCountShift = 8,
LoopControlMax = 0x7fffffff,
};
@@ -573,6 +585,11 @@ enum LoopControlMask {
LoopControlDontUnrollMask = 0x00000002,
LoopControlDependencyInfiniteMask = 0x00000004,
LoopControlDependencyLengthMask = 0x00000008,
LoopControlMinIterationsMask = 0x00000010,
LoopControlMaxIterationsMask = 0x00000020,
LoopControlIterationMultipleMask = 0x00000040,
LoopControlPeelCountMask = 0x00000080,
LoopControlPartialCountMask = 0x00000100,
};
enum FunctionControlShift {
@@ -816,6 +833,7 @@ enum Capability {
CapabilitySubgroupBufferBlockIOINTEL = 5569,
CapabilitySubgroupImageBlockIOINTEL = 5570,
CapabilitySubgroupImageMediaBlockIOINTEL = 5579,
CapabilityIntegerFunctions2INTEL = 5584,
CapabilitySubgroupAvcMotionEstimationINTEL = 5696,
CapabilitySubgroupAvcMotionEstimationIntraINTEL = 5697,
CapabilitySubgroupAvcMotionEstimationChromaINTEL = 5698,
@@ -1163,6 +1181,10 @@ enum Op {
OpGroupNonUniformLogicalXor = 364,
OpGroupNonUniformQuadBroadcast = 365,
OpGroupNonUniformQuadSwap = 366,
OpCopyLogical = 400,
OpPtrEqual = 401,
OpPtrNotEqual = 402,
OpPtrDiff = 403,
OpSubgroupBallotKHR = 4421,
OpSubgroupFirstInvocationKHR = 4422,
OpSubgroupAllKHR = 4428,
@@ -1203,7 +1225,23 @@ enum Op {
OpSubgroupImageBlockWriteINTEL = 5578,
OpSubgroupImageMediaBlockReadINTEL = 5580,
OpSubgroupImageMediaBlockWriteINTEL = 5581,
OpUCountLeadingZerosINTEL = 5585,
OpUCountTrailingZerosINTEL = 5586,
OpAbsISubINTEL = 5587,
OpAbsUSubINTEL = 5588,
OpIAddSatINTEL = 5589,
OpUAddSatINTEL = 5590,
OpIAverageINTEL = 5591,
OpUAverageINTEL = 5592,
OpIAverageRoundedINTEL = 5593,
OpUAverageRoundedINTEL = 5594,
OpISubSatINTEL = 5595,
OpUSubSatINTEL = 5596,
OpIMul32x16INTEL = 5597,
OpUMul32x16INTEL = 5598,
OpDecorateString = 5632,
OpDecorateStringGOOGLE = 5632,
OpMemberDecorateString = 5633,
OpMemberDecorateStringGOOGLE = 5633,
OpVmeImageINTEL = 5699,
OpTypeVmeImageINTEL = 5700,
@@ -1671,6 +1709,10 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) {
case OpGroupNonUniformLogicalXor: *hasResult = true; *hasResultType = true; break;
case OpGroupNonUniformQuadBroadcast: *hasResult = true; *hasResultType = true; break;
case OpGroupNonUniformQuadSwap: *hasResult = true; *hasResultType = true; break;
case OpCopyLogical: *hasResult = true; *hasResultType = true; break;
case OpPtrEqual: *hasResult = true; *hasResultType = true; break;
case OpPtrNotEqual: *hasResult = true; *hasResultType = true; break;
case OpPtrDiff: *hasResult = true; *hasResultType = true; break;
case OpSubgroupBallotKHR: *hasResult = true; *hasResultType = true; break;
case OpSubgroupFirstInvocationKHR: *hasResult = true; *hasResultType = true; break;
case OpSubgroupAllKHR: *hasResult = true; *hasResultType = true; break;
@@ -1687,6 +1729,8 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) {
case OpGroupSMaxNonUniformAMD: *hasResult = true; *hasResultType = true; break;
case OpFragmentMaskFetchAMD: *hasResult = true; *hasResultType = true; break;
case OpFragmentFetchAMD: *hasResult = true; *hasResultType = true; break;
case OpImageSampleFootprintNV: *hasResult = true; *hasResultType = true; break;
case OpGroupNonUniformPartitionNV: *hasResult = true; *hasResultType = true; break;
case OpWritePackedPrimitiveIndices4x8NV: *hasResult = false; *hasResultType = false; break;
case OpReportIntersectionNV: *hasResult = true; *hasResultType = true; break;
case OpIgnoreIntersectionNV: *hasResult = false; *hasResultType = false; break;
@@ -1694,6 +1738,11 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) {
case OpTraceNV: *hasResult = false; *hasResultType = false; break;
case OpTypeAccelerationStructureNV: *hasResult = true; *hasResultType = false; break;
case OpExecuteCallableNV: *hasResult = false; *hasResultType = false; break;
case OpTypeCooperativeMatrixNV: *hasResult = true; *hasResultType = false; break;
case OpCooperativeMatrixLoadNV: *hasResult = true; *hasResultType = true; break;
case OpCooperativeMatrixStoreNV: *hasResult = false; *hasResultType = false; break;
case OpCooperativeMatrixMulAddNV: *hasResult = true; *hasResultType = true; break;
case OpCooperativeMatrixLengthNV: *hasResult = true; *hasResultType = true; break;
case OpSubgroupShuffleINTEL: *hasResult = true; *hasResultType = true; break;
case OpSubgroupShuffleDownINTEL: *hasResult = true; *hasResultType = true; break;
case OpSubgroupShuffleUpINTEL: *hasResult = true; *hasResultType = true; break;
@@ -1704,6 +1753,22 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) {
case OpSubgroupImageBlockWriteINTEL: *hasResult = false; *hasResultType = false; break;
case OpSubgroupImageMediaBlockReadINTEL: *hasResult = true; *hasResultType = true; break;
case OpSubgroupImageMediaBlockWriteINTEL: *hasResult = false; *hasResultType = false; break;
case OpUCountLeadingZerosINTEL: *hasResult = true; *hasResultType = true; break;
case OpUCountTrailingZerosINTEL: *hasResult = true; *hasResultType = true; break;
case OpAbsISubINTEL: *hasResult = true; *hasResultType = true; break;
case OpAbsUSubINTEL: *hasResult = true; *hasResultType = true; break;
case OpIAddSatINTEL: *hasResult = true; *hasResultType = true; break;
case OpUAddSatINTEL: *hasResult = true; *hasResultType = true; break;
case OpIAverageINTEL: *hasResult = true; *hasResultType = true; break;
case OpUAverageINTEL: *hasResult = true; *hasResultType = true; break;
case OpIAverageRoundedINTEL: *hasResult = true; *hasResultType = true; break;
case OpUAverageRoundedINTEL: *hasResult = true; *hasResultType = true; break;
case OpISubSatINTEL: *hasResult = true; *hasResultType = true; break;
case OpUSubSatINTEL: *hasResult = true; *hasResultType = true; break;
case OpIMul32x16INTEL: *hasResult = true; *hasResultType = true; break;
case OpUMul32x16INTEL: *hasResult = true; *hasResultType = true; break;
case OpDecorateString: *hasResult = false; *hasResultType = false; break;
case OpMemberDecorateString: *hasResult = false; *hasResultType = false; break;
case OpVmeImageINTEL: *hasResult = true; *hasResultType = true; break;
case OpTypeVmeImageINTEL: *hasResult = true; *hasResultType = false; break;
case OpTypeAvcImePayloadINTEL: *hasResult = true; *hasResultType = false; break;
@@ -1822,15 +1887,6 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) {
case OpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL: *hasResult = true; *hasResultType = true; break;
case OpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL: *hasResult = true; *hasResultType = true; break;
case OpSubgroupAvcSicGetInterRawSadsINTEL: *hasResult = true; *hasResultType = true; break;
case OpDecorateStringGOOGLE: *hasResult = false; *hasResultType = false; break;
case OpMemberDecorateStringGOOGLE: *hasResult = false; *hasResultType = false; break;
case OpGroupNonUniformPartitionNV: *hasResult = true; *hasResultType = true; break;
case OpImageSampleFootprintNV: *hasResult = true; *hasResultType = true; break;
case OpTypeCooperativeMatrixNV: *hasResult = true; *hasResultType = false; break;
case OpCooperativeMatrixLoadNV: *hasResult = true; *hasResultType = true; break;
case OpCooperativeMatrixStoreNV: *hasResult = false; *hasResultType = false; break;
case OpCooperativeMatrixMulAddNV: *hasResult = true; *hasResultType = true; break;
case OpCooperativeMatrixLengthNV: *hasResult = true; *hasResultType = true; break;
}
}
#endif /* SPV_ENABLE_UTILITY_CODE */

View File

@@ -49,12 +49,12 @@ namespace spv {
typedef unsigned int Id;
#define SPV_VERSION 0x10300
#define SPV_REVISION 7
#define SPV_VERSION 0x10400
#define SPV_REVISION 1
static const unsigned int MagicNumber = 0x07230203;
static const unsigned int Version = 0x00010300;
static const unsigned int Revision = 7;
static const unsigned int Version = 0x00010400;
static const unsigned int Revision = 1;
static const unsigned int OpCodeMask = 0xffff;
static const unsigned int WordCountShift = 16;
@@ -309,6 +309,8 @@ enum class ImageOperandsShift : unsigned {
MakeTexelVisibleKHR = 9,
NonPrivateTexelKHR = 10,
VolatileTexelKHR = 11,
SignExtend = 12,
ZeroExtend = 13,
Max = 0x7fffffff,
};
@@ -326,6 +328,8 @@ enum class ImageOperandsMask : unsigned {
MakeTexelVisibleKHR = 0x00000200,
NonPrivateTexelKHR = 0x00000400,
VolatileTexelKHR = 0x00000800,
SignExtend = 0x00001000,
ZeroExtend = 0x00002000,
};
enum class FPFastMathModeShift : unsigned {
@@ -406,6 +410,7 @@ enum class Decoration : unsigned {
NonWritable = 24,
NonReadable = 25,
Uniform = 26,
UniformId = 27,
SaturatedConversion = 28,
Stream = 29,
Location = 30,
@@ -440,8 +445,10 @@ enum class Decoration : unsigned {
NonUniformEXT = 5300,
RestrictPointerEXT = 5355,
AliasedPointerEXT = 5356,
CounterBuffer = 5634,
HlslCounterBufferGOOGLE = 5634,
HlslSemanticGOOGLE = 5635,
UserSemantic = 5635,
Max = 0x7fffffff,
};
@@ -564,6 +571,11 @@ enum class LoopControlShift : unsigned {
DontUnroll = 1,
DependencyInfinite = 2,
DependencyLength = 3,
MinIterations = 4,
MaxIterations = 5,
IterationMultiple = 6,
PeelCount = 7,
PartialCount = 8,
Max = 0x7fffffff,
};
@@ -573,6 +585,11 @@ enum class LoopControlMask : unsigned {
DontUnroll = 0x00000002,
DependencyInfinite = 0x00000004,
DependencyLength = 0x00000008,
MinIterations = 0x00000010,
MaxIterations = 0x00000020,
IterationMultiple = 0x00000040,
PeelCount = 0x00000080,
PartialCount = 0x00000100,
};
enum class FunctionControlShift : unsigned {
@@ -816,6 +833,7 @@ enum class Capability : unsigned {
SubgroupBufferBlockIOINTEL = 5569,
SubgroupImageBlockIOINTEL = 5570,
SubgroupImageMediaBlockIOINTEL = 5579,
IntegerFunctions2INTEL = 5584,
SubgroupAvcMotionEstimationINTEL = 5696,
SubgroupAvcMotionEstimationIntraINTEL = 5697,
SubgroupAvcMotionEstimationChromaINTEL = 5698,
@@ -1163,6 +1181,10 @@ enum class Op : unsigned {
OpGroupNonUniformLogicalXor = 364,
OpGroupNonUniformQuadBroadcast = 365,
OpGroupNonUniformQuadSwap = 366,
OpCopyLogical = 400,
OpPtrEqual = 401,
OpPtrNotEqual = 402,
OpPtrDiff = 403,
OpSubgroupBallotKHR = 4421,
OpSubgroupFirstInvocationKHR = 4422,
OpSubgroupAllKHR = 4428,
@@ -1203,7 +1225,23 @@ enum class Op : unsigned {
OpSubgroupImageBlockWriteINTEL = 5578,
OpSubgroupImageMediaBlockReadINTEL = 5580,
OpSubgroupImageMediaBlockWriteINTEL = 5581,
OpUCountLeadingZerosINTEL = 5585,
OpUCountTrailingZerosINTEL = 5586,
OpAbsISubINTEL = 5587,
OpAbsUSubINTEL = 5588,
OpIAddSatINTEL = 5589,
OpUAddSatINTEL = 5590,
OpIAverageINTEL = 5591,
OpUAverageINTEL = 5592,
OpIAverageRoundedINTEL = 5593,
OpUAverageRoundedINTEL = 5594,
OpISubSatINTEL = 5595,
OpUSubSatINTEL = 5596,
OpIMul32x16INTEL = 5597,
OpUMul32x16INTEL = 5598,
OpDecorateString = 5632,
OpDecorateStringGOOGLE = 5632,
OpMemberDecorateString = 5633,
OpMemberDecorateStringGOOGLE = 5633,
OpVmeImageINTEL = 5699,
OpTypeVmeImageINTEL = 5700,
@@ -1671,6 +1709,10 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) {
case Op::OpGroupNonUniformLogicalXor: *hasResult = true; *hasResultType = true; break;
case Op::OpGroupNonUniformQuadBroadcast: *hasResult = true; *hasResultType = true; break;
case Op::OpGroupNonUniformQuadSwap: *hasResult = true; *hasResultType = true; break;
case Op::OpCopyLogical: *hasResult = true; *hasResultType = true; break;
case Op::OpPtrEqual: *hasResult = true; *hasResultType = true; break;
case Op::OpPtrNotEqual: *hasResult = true; *hasResultType = true; break;
case Op::OpPtrDiff: *hasResult = true; *hasResultType = true; break;
case Op::OpSubgroupBallotKHR: *hasResult = true; *hasResultType = true; break;
case Op::OpSubgroupFirstInvocationKHR: *hasResult = true; *hasResultType = true; break;
case Op::OpSubgroupAllKHR: *hasResult = true; *hasResultType = true; break;
@@ -1687,6 +1729,8 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) {
case Op::OpGroupSMaxNonUniformAMD: *hasResult = true; *hasResultType = true; break;
case Op::OpFragmentMaskFetchAMD: *hasResult = true; *hasResultType = true; break;
case Op::OpFragmentFetchAMD: *hasResult = true; *hasResultType = true; break;
case Op::OpImageSampleFootprintNV: *hasResult = true; *hasResultType = true; break;
case Op::OpGroupNonUniformPartitionNV: *hasResult = true; *hasResultType = true; break;
case Op::OpWritePackedPrimitiveIndices4x8NV: *hasResult = false; *hasResultType = false; break;
case Op::OpReportIntersectionNV: *hasResult = true; *hasResultType = true; break;
case Op::OpIgnoreIntersectionNV: *hasResult = false; *hasResultType = false; break;
@@ -1694,6 +1738,11 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) {
case Op::OpTraceNV: *hasResult = false; *hasResultType = false; break;
case Op::OpTypeAccelerationStructureNV: *hasResult = true; *hasResultType = false; break;
case Op::OpExecuteCallableNV: *hasResult = false; *hasResultType = false; break;
case Op::OpTypeCooperativeMatrixNV: *hasResult = true; *hasResultType = false; break;
case Op::OpCooperativeMatrixLoadNV: *hasResult = true; *hasResultType = true; break;
case Op::OpCooperativeMatrixStoreNV: *hasResult = false; *hasResultType = false; break;
case Op::OpCooperativeMatrixMulAddNV: *hasResult = true; *hasResultType = true; break;
case Op::OpCooperativeMatrixLengthNV: *hasResult = true; *hasResultType = true; break;
case Op::OpSubgroupShuffleINTEL: *hasResult = true; *hasResultType = true; break;
case Op::OpSubgroupShuffleDownINTEL: *hasResult = true; *hasResultType = true; break;
case Op::OpSubgroupShuffleUpINTEL: *hasResult = true; *hasResultType = true; break;
@@ -1704,6 +1753,22 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) {
case Op::OpSubgroupImageBlockWriteINTEL: *hasResult = false; *hasResultType = false; break;
case Op::OpSubgroupImageMediaBlockReadINTEL: *hasResult = true; *hasResultType = true; break;
case Op::OpSubgroupImageMediaBlockWriteINTEL: *hasResult = false; *hasResultType = false; break;
case Op::OpUCountLeadingZerosINTEL: *hasResult = true; *hasResultType = true; break;
case Op::OpUCountTrailingZerosINTEL: *hasResult = true; *hasResultType = true; break;
case Op::OpAbsISubINTEL: *hasResult = true; *hasResultType = true; break;
case Op::OpAbsUSubINTEL: *hasResult = true; *hasResultType = true; break;
case Op::OpIAddSatINTEL: *hasResult = true; *hasResultType = true; break;
case Op::OpUAddSatINTEL: *hasResult = true; *hasResultType = true; break;
case Op::OpIAverageINTEL: *hasResult = true; *hasResultType = true; break;
case Op::OpUAverageINTEL: *hasResult = true; *hasResultType = true; break;
case Op::OpIAverageRoundedINTEL: *hasResult = true; *hasResultType = true; break;
case Op::OpUAverageRoundedINTEL: *hasResult = true; *hasResultType = true; break;
case Op::OpISubSatINTEL: *hasResult = true; *hasResultType = true; break;
case Op::OpUSubSatINTEL: *hasResult = true; *hasResultType = true; break;
case Op::OpIMul32x16INTEL: *hasResult = true; *hasResultType = true; break;
case Op::OpUMul32x16INTEL: *hasResult = true; *hasResultType = true; break;
case Op::OpDecorateString: *hasResult = false; *hasResultType = false; break;
case Op::OpMemberDecorateString: *hasResult = false; *hasResultType = false; break;
case Op::OpVmeImageINTEL: *hasResult = true; *hasResultType = true; break;
case Op::OpTypeVmeImageINTEL: *hasResult = true; *hasResultType = false; break;
case Op::OpTypeAvcImePayloadINTEL: *hasResult = true; *hasResultType = false; break;
@@ -1822,15 +1887,6 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) {
case Op::OpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL: *hasResult = true; *hasResultType = true; break;
case Op::OpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL: *hasResult = true; *hasResultType = true; break;
case Op::OpSubgroupAvcSicGetInterRawSadsINTEL: *hasResult = true; *hasResultType = true; break;
case Op::OpDecorateStringGOOGLE: *hasResult = false; *hasResultType = false; break;
case Op::OpMemberDecorateStringGOOGLE: *hasResult = false; *hasResultType = false; break;
case Op::OpGroupNonUniformPartitionNV: *hasResult = true; *hasResultType = true; break;
case Op::OpImageSampleFootprintNV: *hasResult = true; *hasResultType = true; break;
case Op::OpTypeCooperativeMatrixNV: *hasResult = true; *hasResultType = false; break;
case Op::OpCooperativeMatrixLoadNV: *hasResult = true; *hasResultType = true; break;
case Op::OpCooperativeMatrixStoreNV: *hasResult = false; *hasResultType = false; break;
case Op::OpCooperativeMatrixMulAddNV: *hasResult = true; *hasResultType = true; break;
case Op::OpCooperativeMatrixLengthNV: *hasResult = true; *hasResultType = true; break;
}
}
#endif /* SPV_ENABLE_UTILITY_CODE */

View File

@@ -54,8 +54,8 @@
]
],
"MagicNumber": 119734787,
"Version": 66304,
"Revision": 7,
"Version": 66560,
"Revision": 1,
"OpCodeMask": 65535,
"WordCountShift": 16
},
@@ -351,7 +351,9 @@
"MakeTexelAvailableKHR": 8,
"MakeTexelVisibleKHR": 9,
"NonPrivateTexelKHR": 10,
"VolatileTexelKHR": 11
"VolatileTexelKHR": 11,
"SignExtend": 12,
"ZeroExtend": 13
}
},
{
@@ -442,6 +444,7 @@
"NonWritable": 24,
"NonReadable": 25,
"Uniform": 26,
"UniformId": 27,
"SaturatedConversion": 28,
"Stream": 29,
"Location": 30,
@@ -476,8 +479,10 @@
"NonUniformEXT": 5300,
"RestrictPointerEXT": 5355,
"AliasedPointerEXT": 5356,
"CounterBuffer": 5634,
"HlslCounterBufferGOOGLE": 5634,
"HlslSemanticGOOGLE": 5635
"HlslSemanticGOOGLE": 5635,
"UserSemantic": 5635
}
},
{
@@ -602,7 +607,12 @@
"Unroll": 0,
"DontUnroll": 1,
"DependencyInfinite": 2,
"DependencyLength": 3
"DependencyLength": 3,
"MinIterations": 4,
"MaxIterations": 5,
"IterationMultiple": 6,
"PeelCount": 7,
"PartialCount": 8
}
},
{
@@ -831,6 +841,7 @@
"SubgroupBufferBlockIOINTEL": 5569,
"SubgroupImageBlockIOINTEL": 5570,
"SubgroupImageMediaBlockIOINTEL": 5579,
"IntegerFunctions2INTEL": 5584,
"SubgroupAvcMotionEstimationINTEL": 5696,
"SubgroupAvcMotionEstimationIntraINTEL": 5697,
"SubgroupAvcMotionEstimationChromaINTEL": 5698
@@ -1181,6 +1192,10 @@
"OpGroupNonUniformLogicalXor": 364,
"OpGroupNonUniformQuadBroadcast": 365,
"OpGroupNonUniformQuadSwap": 366,
"OpCopyLogical": 400,
"OpPtrEqual": 401,
"OpPtrNotEqual": 402,
"OpPtrDiff": 403,
"OpSubgroupBallotKHR": 4421,
"OpSubgroupFirstInvocationKHR": 4422,
"OpSubgroupAllKHR": 4428,
@@ -1221,7 +1236,23 @@
"OpSubgroupImageBlockWriteINTEL": 5578,
"OpSubgroupImageMediaBlockReadINTEL": 5580,
"OpSubgroupImageMediaBlockWriteINTEL": 5581,
"OpUCountLeadingZerosINTEL": 5585,
"OpUCountTrailingZerosINTEL": 5586,
"OpAbsISubINTEL": 5587,
"OpAbsUSubINTEL": 5588,
"OpIAddSatINTEL": 5589,
"OpUAddSatINTEL": 5590,
"OpIAverageINTEL": 5591,
"OpUAverageINTEL": 5592,
"OpIAverageRoundedINTEL": 5593,
"OpUAverageRoundedINTEL": 5594,
"OpISubSatINTEL": 5595,
"OpUSubSatINTEL": 5596,
"OpIMul32x16INTEL": 5597,
"OpUMul32x16INTEL": 5598,
"OpDecorateString": 5632,
"OpDecorateStringGOOGLE": 5632,
"OpMemberDecorateString": 5633,
"OpMemberDecorateStringGOOGLE": 5633,
"OpVmeImageINTEL": 5699,
"OpTypeVmeImageINTEL": 5700,

View File

@@ -44,8 +44,8 @@
spv = {
MagicNumber = 0x07230203,
Version = 0x00010300,
Revision = 7,
Version = 0x00010400,
Revision = 1,
OpCodeMask = 0xffff,
WordCountShift = 16,
@@ -288,6 +288,8 @@ spv = {
MakeTexelVisibleKHR = 9,
NonPrivateTexelKHR = 10,
VolatileTexelKHR = 11,
SignExtend = 12,
ZeroExtend = 13,
},
ImageOperandsMask = {
@@ -304,6 +306,8 @@ spv = {
MakeTexelVisibleKHR = 0x00000200,
NonPrivateTexelKHR = 0x00000400,
VolatileTexelKHR = 0x00000800,
SignExtend = 0x00001000,
ZeroExtend = 0x00002000,
},
FPFastMathModeShift = {
@@ -379,6 +383,7 @@ spv = {
NonWritable = 24,
NonReadable = 25,
Uniform = 26,
UniformId = 27,
SaturatedConversion = 28,
Stream = 29,
Location = 30,
@@ -413,8 +418,10 @@ spv = {
NonUniformEXT = 5300,
RestrictPointerEXT = 5355,
AliasedPointerEXT = 5356,
CounterBuffer = 5634,
HlslCounterBufferGOOGLE = 5634,
HlslSemanticGOOGLE = 5635,
UserSemantic = 5635,
},
BuiltIn = {
@@ -534,6 +541,11 @@ spv = {
DontUnroll = 1,
DependencyInfinite = 2,
DependencyLength = 3,
MinIterations = 4,
MaxIterations = 5,
IterationMultiple = 6,
PeelCount = 7,
PartialCount = 8,
},
LoopControlMask = {
@@ -542,6 +554,11 @@ spv = {
DontUnroll = 0x00000002,
DependencyInfinite = 0x00000004,
DependencyLength = 0x00000008,
MinIterations = 0x00000010,
MaxIterations = 0x00000020,
IterationMultiple = 0x00000040,
PeelCount = 0x00000080,
PartialCount = 0x00000100,
},
FunctionControlShift = {
@@ -778,6 +795,7 @@ spv = {
SubgroupBufferBlockIOINTEL = 5569,
SubgroupImageBlockIOINTEL = 5570,
SubgroupImageMediaBlockIOINTEL = 5579,
IntegerFunctions2INTEL = 5584,
SubgroupAvcMotionEstimationINTEL = 5696,
SubgroupAvcMotionEstimationIntraINTEL = 5697,
SubgroupAvcMotionEstimationChromaINTEL = 5698,
@@ -1124,6 +1142,10 @@ spv = {
OpGroupNonUniformLogicalXor = 364,
OpGroupNonUniformQuadBroadcast = 365,
OpGroupNonUniformQuadSwap = 366,
OpCopyLogical = 400,
OpPtrEqual = 401,
OpPtrNotEqual = 402,
OpPtrDiff = 403,
OpSubgroupBallotKHR = 4421,
OpSubgroupFirstInvocationKHR = 4422,
OpSubgroupAllKHR = 4428,
@@ -1164,7 +1186,23 @@ spv = {
OpSubgroupImageBlockWriteINTEL = 5578,
OpSubgroupImageMediaBlockReadINTEL = 5580,
OpSubgroupImageMediaBlockWriteINTEL = 5581,
OpUCountLeadingZerosINTEL = 5585,
OpUCountTrailingZerosINTEL = 5586,
OpAbsISubINTEL = 5587,
OpAbsUSubINTEL = 5588,
OpIAddSatINTEL = 5589,
OpUAddSatINTEL = 5590,
OpIAverageINTEL = 5591,
OpUAverageINTEL = 5592,
OpIAverageRoundedINTEL = 5593,
OpUAverageRoundedINTEL = 5594,
OpISubSatINTEL = 5595,
OpUSubSatINTEL = 5596,
OpIMul32x16INTEL = 5597,
OpUMul32x16INTEL = 5598,
OpDecorateString = 5632,
OpDecorateStringGOOGLE = 5632,
OpMemberDecorateString = 5633,
OpMemberDecorateStringGOOGLE = 5633,
OpVmeImageINTEL = 5699,
OpTypeVmeImageINTEL = 5700,

View File

@@ -44,8 +44,8 @@
spv = {
'MagicNumber' : 0x07230203,
'Version' : 0x00010300,
'Revision' : 7,
'Version' : 0x00010400,
'Revision' : 1,
'OpCodeMask' : 0xffff,
'WordCountShift' : 16,
@@ -288,6 +288,8 @@ spv = {
'MakeTexelVisibleKHR' : 9,
'NonPrivateTexelKHR' : 10,
'VolatileTexelKHR' : 11,
'SignExtend' : 12,
'ZeroExtend' : 13,
},
'ImageOperandsMask' : {
@@ -304,6 +306,8 @@ spv = {
'MakeTexelVisibleKHR' : 0x00000200,
'NonPrivateTexelKHR' : 0x00000400,
'VolatileTexelKHR' : 0x00000800,
'SignExtend' : 0x00001000,
'ZeroExtend' : 0x00002000,
},
'FPFastMathModeShift' : {
@@ -379,6 +383,7 @@ spv = {
'NonWritable' : 24,
'NonReadable' : 25,
'Uniform' : 26,
'UniformId' : 27,
'SaturatedConversion' : 28,
'Stream' : 29,
'Location' : 30,
@@ -413,8 +418,10 @@ spv = {
'NonUniformEXT' : 5300,
'RestrictPointerEXT' : 5355,
'AliasedPointerEXT' : 5356,
'CounterBuffer' : 5634,
'HlslCounterBufferGOOGLE' : 5634,
'HlslSemanticGOOGLE' : 5635,
'UserSemantic' : 5635,
},
'BuiltIn' : {
@@ -534,6 +541,11 @@ spv = {
'DontUnroll' : 1,
'DependencyInfinite' : 2,
'DependencyLength' : 3,
'MinIterations' : 4,
'MaxIterations' : 5,
'IterationMultiple' : 6,
'PeelCount' : 7,
'PartialCount' : 8,
},
'LoopControlMask' : {
@@ -542,6 +554,11 @@ spv = {
'DontUnroll' : 0x00000002,
'DependencyInfinite' : 0x00000004,
'DependencyLength' : 0x00000008,
'MinIterations' : 0x00000010,
'MaxIterations' : 0x00000020,
'IterationMultiple' : 0x00000040,
'PeelCount' : 0x00000080,
'PartialCount' : 0x00000100,
},
'FunctionControlShift' : {
@@ -778,6 +795,7 @@ spv = {
'SubgroupBufferBlockIOINTEL' : 5569,
'SubgroupImageBlockIOINTEL' : 5570,
'SubgroupImageMediaBlockIOINTEL' : 5579,
'IntegerFunctions2INTEL' : 5584,
'SubgroupAvcMotionEstimationINTEL' : 5696,
'SubgroupAvcMotionEstimationIntraINTEL' : 5697,
'SubgroupAvcMotionEstimationChromaINTEL' : 5698,
@@ -1124,6 +1142,10 @@ spv = {
'OpGroupNonUniformLogicalXor' : 364,
'OpGroupNonUniformQuadBroadcast' : 365,
'OpGroupNonUniformQuadSwap' : 366,
'OpCopyLogical' : 400,
'OpPtrEqual' : 401,
'OpPtrNotEqual' : 402,
'OpPtrDiff' : 403,
'OpSubgroupBallotKHR' : 4421,
'OpSubgroupFirstInvocationKHR' : 4422,
'OpSubgroupAllKHR' : 4428,
@@ -1164,7 +1186,23 @@ spv = {
'OpSubgroupImageBlockWriteINTEL' : 5578,
'OpSubgroupImageMediaBlockReadINTEL' : 5580,
'OpSubgroupImageMediaBlockWriteINTEL' : 5581,
'OpUCountLeadingZerosINTEL' : 5585,
'OpUCountTrailingZerosINTEL' : 5586,
'OpAbsISubINTEL' : 5587,
'OpAbsUSubINTEL' : 5588,
'OpIAddSatINTEL' : 5589,
'OpUAddSatINTEL' : 5590,
'OpIAverageINTEL' : 5591,
'OpUAverageINTEL' : 5592,
'OpIAverageRoundedINTEL' : 5593,
'OpUAverageRoundedINTEL' : 5594,
'OpISubSatINTEL' : 5595,
'OpUSubSatINTEL' : 5596,
'OpIMul32x16INTEL' : 5597,
'OpUMul32x16INTEL' : 5598,
'OpDecorateString' : 5632,
'OpDecorateStringGOOGLE' : 5632,
'OpMemberDecorateString' : 5633,
'OpMemberDecorateStringGOOGLE' : 5633,
'OpVmeImageINTEL' : 5699,
'OpTypeVmeImageINTEL' : 5700,

View File

@@ -51,8 +51,8 @@
module spv;
enum uint MagicNumber = 0x07230203;
enum uint Version = 0x00010300;
enum uint Revision = 7;
enum uint Version = 0x00010400;
enum uint Revision = 1;
enum uint OpCodeMask = 0xffff;
enum uint WordCountShift = 16;
@@ -308,6 +308,8 @@ enum ImageOperandsShift : uint
MakeTexelVisibleKHR = 9,
NonPrivateTexelKHR = 10,
VolatileTexelKHR = 11,
SignExtend = 12,
ZeroExtend = 13,
}
enum ImageOperandsMask : uint
@@ -325,6 +327,8 @@ enum ImageOperandsMask : uint
MakeTexelVisibleKHR = 0x00000200,
NonPrivateTexelKHR = 0x00000400,
VolatileTexelKHR = 0x00000800,
SignExtend = 0x00001000,
ZeroExtend = 0x00002000,
}
enum FPFastMathModeShift : uint
@@ -407,6 +411,7 @@ enum Decoration : uint
NonWritable = 24,
NonReadable = 25,
Uniform = 26,
UniformId = 27,
SaturatedConversion = 28,
Stream = 29,
Location = 30,
@@ -441,8 +446,10 @@ enum Decoration : uint
NonUniformEXT = 5300,
RestrictPointerEXT = 5355,
AliasedPointerEXT = 5356,
CounterBuffer = 5634,
HlslCounterBufferGOOGLE = 5634,
HlslSemanticGOOGLE = 5635,
UserSemantic = 5635,
}
enum BuiltIn : uint
@@ -566,6 +573,11 @@ enum LoopControlShift : uint
DontUnroll = 1,
DependencyInfinite = 2,
DependencyLength = 3,
MinIterations = 4,
MaxIterations = 5,
IterationMultiple = 6,
PeelCount = 7,
PartialCount = 8,
}
enum LoopControlMask : uint
@@ -575,6 +587,11 @@ enum LoopControlMask : uint
DontUnroll = 0x00000002,
DependencyInfinite = 0x00000004,
DependencyLength = 0x00000008,
MinIterations = 0x00000010,
MaxIterations = 0x00000020,
IterationMultiple = 0x00000040,
PeelCount = 0x00000080,
PartialCount = 0x00000100,
}
enum FunctionControlShift : uint
@@ -823,6 +840,7 @@ enum Capability : uint
SubgroupBufferBlockIOINTEL = 5569,
SubgroupImageBlockIOINTEL = 5570,
SubgroupImageMediaBlockIOINTEL = 5579,
IntegerFunctions2INTEL = 5584,
SubgroupAvcMotionEstimationINTEL = 5696,
SubgroupAvcMotionEstimationIntraINTEL = 5697,
SubgroupAvcMotionEstimationChromaINTEL = 5698,
@@ -1170,6 +1188,10 @@ enum Op : uint
OpGroupNonUniformLogicalXor = 364,
OpGroupNonUniformQuadBroadcast = 365,
OpGroupNonUniformQuadSwap = 366,
OpCopyLogical = 400,
OpPtrEqual = 401,
OpPtrNotEqual = 402,
OpPtrDiff = 403,
OpSubgroupBallotKHR = 4421,
OpSubgroupFirstInvocationKHR = 4422,
OpSubgroupAllKHR = 4428,
@@ -1210,7 +1232,23 @@ enum Op : uint
OpSubgroupImageBlockWriteINTEL = 5578,
OpSubgroupImageMediaBlockReadINTEL = 5580,
OpSubgroupImageMediaBlockWriteINTEL = 5581,
OpUCountLeadingZerosINTEL = 5585,
OpUCountTrailingZerosINTEL = 5586,
OpAbsISubINTEL = 5587,
OpAbsUSubINTEL = 5588,
OpIAddSatINTEL = 5589,
OpUAddSatINTEL = 5590,
OpIAverageINTEL = 5591,
OpUAverageINTEL = 5592,
OpIAverageRoundedINTEL = 5593,
OpUAverageRoundedINTEL = 5594,
OpISubSatINTEL = 5595,
OpUSubSatINTEL = 5596,
OpIMul32x16INTEL = 5597,
OpUMul32x16INTEL = 5598,
OpDecorateString = 5632,
OpDecorateStringGOOGLE = 5632,
OpMemberDecorateString = 5633,
OpMemberDecorateStringGOOGLE = 5633,
OpVmeImageINTEL = 5699,
OpTypeVmeImageINTEL = 5700,

View File

@@ -42,6 +42,7 @@
#include <cctype>
#include <vector>
#include <utility>
#include <set>
#include "jsoncpp/dist/json/json.h"
@@ -68,9 +69,9 @@ namespace {
TPrinter();
static const int DocMagicNumber = 0x07230203;
static const int DocVersion = 0x00010300;
static const int DocRevision = 7;
#define DocRevisionString "7"
static const int DocVersion = 0x00010400;
static const int DocRevision = 1;
#define DocRevisionString "1"
static const std::string DocCopyright;
static const std::string DocComment1;
static const std::string DocComment2;
@@ -347,7 +348,7 @@ namespace {
bool printMax = (style != enumMask && maxEnum.size() > 0);
for (const auto& v : sorted)
out << enumFmt(opPrefix, v, style, !printMax && v.first == sorted.back().first);
out << enumFmt(opPrefix, v, style, !printMax && v.second == sorted.back().second);
if (printMax)
out << maxEnum;
@@ -503,6 +504,8 @@ namespace {
{
const Json::Value& enums = spvRoot["spv"]["enum"];
std::set<unsigned> seenValues;
for (auto opClass = enums.begin(); opClass != enums.end(); ++opClass) {
const auto opName = (*opClass)["Name"].asString();
if (opName != "Op") {
@@ -516,6 +519,14 @@ namespace {
out << " default: /* unknown opcode */ break;" << std::endl;
for (auto& inst : spv::InstructionDesc) {
// Filter out duplicate enum values, which would break the switch statement.
// These are probably just extension enums promoted to core.
if (seenValues.find(inst.value) != seenValues.end()) {
continue;
}
seenValues.insert(inst.value);
std::string name = inst.name;
out << " case " << fmtEnumUse("Op", name) << ": *hasResult = " << (inst.hasResult() ? "true" : "false") << "; *hasResultType = " << (inst.hasType() ? "true" : "false") << "; break;" << std::endl;
}

View File

@@ -119,8 +119,7 @@ ClassOptionality ToOperandClassAndOptionality(const std::string& operandKind, co
else if (quantifier == "?")
return {OperandLiteralString, true};
else {
assert(0 && "this case should not exist");
return {OperandNone, false};
return {OperandOptionalLiteralStrings, false};
}
} else if (operandKind == "PairLiteralIntegerIdRef") {
// Used by OpSwitch in the grammar
@@ -198,7 +197,7 @@ ClassOptionality ToOperandClassAndOptionality(const std::string& operandKind, co
} else if (operandKind == "FunctionControl") {
type = OperandFunction;
} else if (operandKind == "MemoryAccess") {
type = OperandMemoryAccess;
type = OperandMemoryOperands;
}
if (type == OperandNone) {
@@ -307,6 +306,7 @@ void jsonToSpirv(const std::string& jsonPath, bool buildingHeaders)
const std::string name = inst["opname"].asString();
EnumCaps caps = getCaps(inst);
std::string version = inst["version"].asString();
std::string lastVersion = inst["lastVersion"].asString();
Extensions exts = getExts(inst);
OperandParameters operands;
bool defResultId = false;
@@ -322,7 +322,7 @@ void jsonToSpirv(const std::string& jsonPath, bool buildingHeaders)
}
InstructionDesc.emplace_back(
std::move(EnumValue(opcode, name,
std::move(caps), std::move(version), std::move(exts),
std::move(caps), std::move(version), std::move(lastVersion), std::move(exts),
std::move(operands))),
defTypeId, defResultId);
}
@@ -355,6 +355,7 @@ void jsonToSpirv(const std::string& jsonPath, bool buildingHeaders)
continue;
EnumCaps caps(getCaps(enumerant));
std::string version = enumerant["version"].asString();
std::string lastVersion = enumerant["lastVersion"].asString();
Extensions exts(getExts(enumerant));
OperandParameters params;
const Json::Value& paramsJson = enumerant["parameters"];
@@ -369,7 +370,7 @@ void jsonToSpirv(const std::string& jsonPath, bool buildingHeaders)
}
dest->emplace_back(
value, enumerant["enumerant"].asString(),
std::move(caps), std::move(version), std::move(exts), std::move(params));
std::move(caps), std::move(version), std::move(lastVersion), std::move(exts), std::move(params));
}
};
@@ -437,7 +438,7 @@ void jsonToSpirv(const std::string& jsonPath, bool buildingHeaders)
} else if (enumName == "Dim") {
establishOperandClass(enumName, OperandDimensionality, &DimensionalityParams, operandEnum, category);
} else if (enumName == "MemoryAccess") {
establishOperandClass(enumName, OperandMemoryAccess, &MemoryAccessParams, operandEnum, category);
establishOperandClass(enumName, OperandMemoryOperands, &MemoryAccessParams, operandEnum, category);
} else if (enumName == "Scope") {
establishOperandClass(enumName, OperandScope, &ScopeParams, operandEnum, category);
} else if (enumName == "GroupOperation") {

View File

@@ -47,6 +47,7 @@ enum OperandClass {
OperandVariableIds,
OperandOptionalLiteral,
OperandOptionalLiteralString,
OperandOptionalLiteralStrings,
OperandVariableLiterals,
OperandVariableIdLiteral,
OperandVariableLiteralId,
@@ -76,7 +77,7 @@ enum OperandClass {
OperandLoop,
OperandFunction,
OperandMemorySemantics,
OperandMemoryAccess,
OperandMemoryOperands,
OperandScope,
OperandGroupOperation,
OperandKernelEnqueueFlags,
@@ -145,6 +146,12 @@ public:
assert((where != end()) && "Could not find enum in the enum list");
return *where;
}
// gets *all* entries for the value, including the first one
void gatherAliases(unsigned value, std::vector<EValue*>& aliases) {
std::for_each(begin(), end(), [&](EValue& e) {
if (value == e.value)
aliases.push_back(&e);});
}
// Returns the EValue with the given name. We assume uniqueness
// by name.
EValue& at(std::string name) {
@@ -167,9 +174,11 @@ private:
class EnumValue {
public:
EnumValue() : value(0), desc(nullptr) {}
EnumValue(unsigned int the_value, const std::string& the_name, EnumCaps&& the_caps, const std::string& the_version,
Extensions&& the_extensions, OperandParameters&& the_operands) :
value(the_value), name(the_name), capabilities(std::move(the_caps)), version(std::move(the_version)),
EnumValue(unsigned int the_value, const std::string& the_name, EnumCaps&& the_caps,
const std::string& the_firstVersion, const std::string& the_lastVersion,
Extensions&& the_extensions, OperandParameters&& the_operands) :
value(the_value), name(the_name), capabilities(std::move(the_caps)),
firstVersion(std::move(the_firstVersion)), lastVersion(std::move(the_lastVersion)),
extensions(std::move(the_extensions)), operands(std::move(the_operands)), desc(nullptr) { }
// For ValueEnum, the value from the JSON file.
@@ -178,7 +187,8 @@ public:
unsigned value;
std::string name;
EnumCaps capabilities;
std::string version;
std::string firstVersion;
std::string lastVersion;
// A feature only be enabled by certain extensions.
// An empty list means the feature does not require an extension.
// Normally, only Capability enums are enabled by extension. In turn,
@@ -233,10 +243,19 @@ public:
opDesc("TBD"),
opClass(0),
typePresent(has_type),
resultPresent(has_result) {}
resultPresent(has_result),
alias(this) { }
InstructionValue(const InstructionValue& v)
{
*this = v;
alias = this;
}
bool hasResult() const { return resultPresent != 0; }
bool hasType() const { return typePresent != 0; }
void setAlias(const InstructionValue& a) { alias = &a; }
const InstructionValue& getAlias() const { return *alias; }
bool isAlias() const { return alias != this; }
const char* opDesc;
int opClass;
@@ -244,6 +263,7 @@ public:
protected:
int typePresent : 1;
int resultPresent : 1;
const InstructionValue* alias; // correct only after discovering the aliases; otherwise points to this
};
using InstructionValues = EnumValuesContainer<InstructionValue>;

View File

@@ -156,6 +156,7 @@ SPVTOOLS_OPT_SRC_FILES := \
source/opt/scalar_replacement_pass.cpp \
source/opt/set_spec_constant_default_value_pass.cpp \
source/opt/simplification_pass.cpp \
source/opt/split_invalid_unreachable_pass.cpp \
source/opt/ssa_rewrite_pass.cpp \
source/opt/strength_reduction_pass.cpp \
source/opt/strip_atomic_counter_memory_pass.cpp \

View File

@@ -616,6 +616,8 @@ static_library("spvtools_opt") {
"source/opt/set_spec_constant_default_value_pass.h",
"source/opt/simplification_pass.cpp",
"source/opt/simplification_pass.h",
"source/opt/split_invalid_unreachable_pass.cpp",
"source/opt/split_invalid_unreachable_pass.h",
"source/opt/ssa_rewrite_pass.cpp",
"source/opt/ssa_rewrite_pass.h",
"source/opt/strength_reduction_pass.cpp",

View File

@@ -1,13 +1,22 @@
Revision history for SPIRV-Tools
v2019.3-dev 2019-04-03
v2019.4-dev 2019-05-15
- Start v2019.4-dev
v2019.3 2019-05-14
- General:
- Updated Python scripts to work for both Python 2 and Python 3.
- Require Python 3 since Python 2 will out of service soon.
- Add a continuous test that does memory checks using the address sanitizer.
- Fix the build files so the SPIRV_USE_SANITIZER=address build works.
- Packaging top of tree build artifacts again.
- Added support for SPIR-V 1.4. (#2550)
- Optimizer
- Remove duplicates from list of interface IDs in OpEntryPoint instruction (#2449)
- Bindless Validation: Descriptor Initialization Check (#2419)
- Add option to validate after each pass (#2462)
- Add legalization pass to fix mismatched pointer (#2430, #2535)
- Add error messages when the input contains unknown instructions. (#2487)
- Add pass to convert from WebGPU Spir-V to Vulkan Spir-V and back. (#2495)
Fixes:
- #2412: Dead memeber elimination should not change input and output variables.
- #2405: Fix OpDot folding of half float vectors.
@@ -18,6 +27,8 @@ v2019.3-dev 2019-04-03
- #2456: Handle dead infinite loops in DCE.
- #2458: Handle variable pointer in some optimizations.
- #2452: Fix dead branch elimination to handle unreachable blocks better.
- #2528: Fix undefined bit shift in sroa.
- #2539: Change implementation of post order CFG traversal.
- Validator
- Add validation of storage classes for WebGPU (#2446)
- Add validation for ExecutionMode in WebGPU (#2443)
@@ -32,6 +43,12 @@ v2019.3-dev 2019-04-03
- Handle function decls in Structured CFG analysis (#2474)
- Validate that OpUnreacahble is not statically reachable (#2473)
- Add pass to generate needed initializers for WebGPU (#2481)
- Allow images without format for OpenCL. (#2470)
- Remove unreachable block validation (#2525)
- Reduce runtime of array layout checks (#2534)
- Add validation specific to OpExecutionModeId (#2536)
- Validate sign of int types. (#2549)
- VK_KHR_uniform_buffer_standard_layout validation (#2562)
Fixes:
- #2439: Add missing DepthGreater case to Fragment only check.
- #2168: Disallow BufferBlock on StorageBuffer variables for Vulkan.
@@ -42,6 +59,7 @@ v2019.3-dev 2019-04-03
- Allows passing options to the validator. (#2401)
- Improve reducer algorithm and other changes (#2472)
- Add Pass to remove selections (#2485)
- Add passes to simplify branches (#2507)
Fixes:
- #2478: fix loop to selection pass for loops with combined header/continue block

View File

@@ -1,10 +1,5 @@
# SPIR-V Tools
[![Build status](https://ci.appveyor.com/api/projects/status/gpue87cesrx3pi0d/branch/master?svg=true)](https://ci.appveyor.com/project/Khronoswebmaster/spirv-tools/branch/master)
<img alt="Linux" src="kokoro/img/linux.png" width="20px" height="20px" hspace="2px"/>![Linux Build Status](https://storage.googleapis.com/spirv-tools/badges/build_status_linux_release.svg)
<img alt="MacOS" src="kokoro/img/macos.png" width="20px" height="20px" hspace="2px"/>![MacOS Build Status](https://storage.googleapis.com/spirv-tools/badges/build_status_macos_release.svg)
<img alt="Windows" src="kokoro/img/windows.png" width="20px" height="20px" hspace="2px"/>![Windows Build Status](https://storage.googleapis.com/spirv-tools/badges/build_status_windows_release.svg)
## Overview
The SPIR-V Tools project provides an API and commands for processing SPIR-V
@@ -24,6 +19,15 @@ SPIR-V is defined by the Khronos Group Inc.
See the [SPIR-V Registry][spirv-registry] for the SPIR-V specification,
headers, and XML registry.
## Downloads
[![Build status](https://ci.appveyor.com/api/projects/status/gpue87cesrx3pi0d/branch/master?svg=true)](https://ci.appveyor.com/project/Khronoswebmaster/spirv-tools/branch/master)
<img alt="Linux" src="kokoro/img/linux.png" width="20px" height="20px" hspace="2px"/>[![Linux Build Status](https://storage.googleapis.com/spirv-tools/badges/build_status_linux_clang_release.svg)](https://storage.googleapis.com/spirv-tools/badges/build_link_linux_clang_release.html)
<img alt="MacOS" src="kokoro/img/macos.png" width="20px" height="20px" hspace="2px"/>[![MacOS Build Status](https://storage.googleapis.com/spirv-tools/badges/build_status_macos_clang_release.svg)](https://storage.googleapis.com/spirv-tools/badges/build_link_macos_clang_release.html)
<img alt="Windows" src="kokoro/img/windows.png" width="20px" height="20px" hspace="2px"/>[![Windows Build Status](https://storage.googleapis.com/spirv-tools/badges/build_status_windows_release.svg)](https://storage.googleapis.com/spirv-tools/badges/build_link_windows_vs2017_release.html)
[More downloads](downloads.md)
## Versioning SPIRV-Tools
See [`CHANGES`](CHANGES) for a high level summary of recent changes, by version.

14
3rdparty/spirv-tools/downloads.md vendored Normal file
View File

@@ -0,0 +1,14 @@
# Downloads
Download the latest builds.
## Release
| Windows | Linux | MacOS |
| --- | --- | --- |
| [MSVC 2017](https://storage.googleapis.com/spirv-tools/badges/build_link_windows_vs2017_release.html) | [clang](https://storage.googleapis.com/spirv-tools/badges/build_link_linux_clang_release.html) | [clang](https://storage.googleapis.com/spirv-tools/badges/build_link_macos_clang_release.html) |
| | [gcc](https://storage.googleapis.com/spirv-tools/badges/build_link_linux_gcc_release.html) | |
## Debug
| Windows | Linux | MacOS |
| --- | --- | --- |
| [MSVC 2017](https://storage.googleapis.com/spirv-tools/badges/build_link_windows_vs2017_debug.html) | [clang](https://storage.googleapis.com/spirv-tools/badges/build_link_linux_clang_debug.html) | [clang](https://storage.googleapis.com/spirv-tools/badges/build_link_macos_clang_debug.html) |
| | [gcc](https://storage.googleapis.com/spirv-tools/badges/build_link_linux_gcc_debug.html) | |

View File

@@ -1 +1 @@
"v2019.3-dev", "SPIRV-Tools v2019.3-dev v2019.1-159-g5fc5303e"
"v2019.4-dev", "SPIRV-Tools v2019.4-dev v2019.3-6-g47741f0"

File diff suppressed because it is too large Load Diff

View File

@@ -40,6 +40,8 @@ const char* ExtensionToString(Extension extension) {
return "SPV_INTEL_device_side_avc_motion_estimation";
case Extension::kSPV_INTEL_media_block_io:
return "SPV_INTEL_media_block_io";
case Extension::kSPV_INTEL_shader_integer_functions2:
return "SPV_INTEL_shader_integer_functions2";
case Extension::kSPV_INTEL_subgroups:
return "SPV_INTEL_subgroups";
case Extension::kSPV_KHR_16bit_storage:
@@ -105,8 +107,8 @@ const char* ExtensionToString(Extension extension) {
bool GetExtensionFromString(const char* str, Extension* extension) {
static const char* known_ext_strs[] = { "SPV_AMD_gcn_shader", "SPV_AMD_gpu_shader_half_float", "SPV_AMD_gpu_shader_half_float_fetch", "SPV_AMD_gpu_shader_int16", "SPV_AMD_shader_ballot", "SPV_AMD_shader_explicit_vertex_parameter", "SPV_AMD_shader_fragment_mask", "SPV_AMD_shader_image_load_store_lod", "SPV_AMD_shader_trinary_minmax", "SPV_AMD_texture_gather_bias_lod", "SPV_EXT_descriptor_indexing", "SPV_EXT_fragment_fully_covered", "SPV_EXT_fragment_invocation_density", "SPV_EXT_physical_storage_buffer", "SPV_EXT_shader_stencil_export", "SPV_EXT_shader_viewport_index_layer", "SPV_GOOGLE_decorate_string", "SPV_GOOGLE_hlsl_functionality1", "SPV_INTEL_device_side_avc_motion_estimation", "SPV_INTEL_media_block_io", "SPV_INTEL_subgroups", "SPV_KHR_16bit_storage", "SPV_KHR_8bit_storage", "SPV_KHR_device_group", "SPV_KHR_float_controls", "SPV_KHR_multiview", "SPV_KHR_no_integer_wrap_decoration", "SPV_KHR_post_depth_coverage", "SPV_KHR_shader_atomic_counter_ops", "SPV_KHR_shader_ballot", "SPV_KHR_shader_draw_parameters", "SPV_KHR_storage_buffer_storage_class", "SPV_KHR_subgroup_vote", "SPV_KHR_variable_pointers", "SPV_KHR_vulkan_memory_model", "SPV_NVX_multiview_per_view_attributes", "SPV_NV_compute_shader_derivatives", "SPV_NV_cooperative_matrix", "SPV_NV_fragment_shader_barycentric", "SPV_NV_geometry_shader_passthrough", "SPV_NV_mesh_shader", "SPV_NV_ray_tracing", "SPV_NV_sample_mask_override_coverage", "SPV_NV_shader_image_footprint", "SPV_NV_shader_subgroup_partitioned", "SPV_NV_shading_rate", "SPV_NV_stereo_view_rendering", "SPV_NV_viewport_array2", "SPV_VALIDATOR_ignore_type_decl_unique" };
static const Extension known_ext_ids[] = { Extension::kSPV_AMD_gcn_shader, Extension::kSPV_AMD_gpu_shader_half_float, Extension::kSPV_AMD_gpu_shader_half_float_fetch, Extension::kSPV_AMD_gpu_shader_int16, Extension::kSPV_AMD_shader_ballot, Extension::kSPV_AMD_shader_explicit_vertex_parameter, Extension::kSPV_AMD_shader_fragment_mask, Extension::kSPV_AMD_shader_image_load_store_lod, Extension::kSPV_AMD_shader_trinary_minmax, Extension::kSPV_AMD_texture_gather_bias_lod, Extension::kSPV_EXT_descriptor_indexing, Extension::kSPV_EXT_fragment_fully_covered, Extension::kSPV_EXT_fragment_invocation_density, Extension::kSPV_EXT_physical_storage_buffer, Extension::kSPV_EXT_shader_stencil_export, Extension::kSPV_EXT_shader_viewport_index_layer, Extension::kSPV_GOOGLE_decorate_string, Extension::kSPV_GOOGLE_hlsl_functionality1, Extension::kSPV_INTEL_device_side_avc_motion_estimation, Extension::kSPV_INTEL_media_block_io, Extension::kSPV_INTEL_subgroups, Extension::kSPV_KHR_16bit_storage, Extension::kSPV_KHR_8bit_storage, Extension::kSPV_KHR_device_group, Extension::kSPV_KHR_float_controls, Extension::kSPV_KHR_multiview, Extension::kSPV_KHR_no_integer_wrap_decoration, Extension::kSPV_KHR_post_depth_coverage, Extension::kSPV_KHR_shader_atomic_counter_ops, Extension::kSPV_KHR_shader_ballot, Extension::kSPV_KHR_shader_draw_parameters, Extension::kSPV_KHR_storage_buffer_storage_class, Extension::kSPV_KHR_subgroup_vote, Extension::kSPV_KHR_variable_pointers, Extension::kSPV_KHR_vulkan_memory_model, Extension::kSPV_NVX_multiview_per_view_attributes, Extension::kSPV_NV_compute_shader_derivatives, Extension::kSPV_NV_cooperative_matrix, Extension::kSPV_NV_fragment_shader_barycentric, Extension::kSPV_NV_geometry_shader_passthrough, Extension::kSPV_NV_mesh_shader, Extension::kSPV_NV_ray_tracing, Extension::kSPV_NV_sample_mask_override_coverage, Extension::kSPV_NV_shader_image_footprint, Extension::kSPV_NV_shader_subgroup_partitioned, Extension::kSPV_NV_shading_rate, Extension::kSPV_NV_stereo_view_rendering, Extension::kSPV_NV_viewport_array2, Extension::kSPV_VALIDATOR_ignore_type_decl_unique };
static const char* known_ext_strs[] = { "SPV_AMD_gcn_shader", "SPV_AMD_gpu_shader_half_float", "SPV_AMD_gpu_shader_half_float_fetch", "SPV_AMD_gpu_shader_int16", "SPV_AMD_shader_ballot", "SPV_AMD_shader_explicit_vertex_parameter", "SPV_AMD_shader_fragment_mask", "SPV_AMD_shader_image_load_store_lod", "SPV_AMD_shader_trinary_minmax", "SPV_AMD_texture_gather_bias_lod", "SPV_EXT_descriptor_indexing", "SPV_EXT_fragment_fully_covered", "SPV_EXT_fragment_invocation_density", "SPV_EXT_physical_storage_buffer", "SPV_EXT_shader_stencil_export", "SPV_EXT_shader_viewport_index_layer", "SPV_GOOGLE_decorate_string", "SPV_GOOGLE_hlsl_functionality1", "SPV_INTEL_device_side_avc_motion_estimation", "SPV_INTEL_media_block_io", "SPV_INTEL_shader_integer_functions2", "SPV_INTEL_subgroups", "SPV_KHR_16bit_storage", "SPV_KHR_8bit_storage", "SPV_KHR_device_group", "SPV_KHR_float_controls", "SPV_KHR_multiview", "SPV_KHR_no_integer_wrap_decoration", "SPV_KHR_post_depth_coverage", "SPV_KHR_shader_atomic_counter_ops", "SPV_KHR_shader_ballot", "SPV_KHR_shader_draw_parameters", "SPV_KHR_storage_buffer_storage_class", "SPV_KHR_subgroup_vote", "SPV_KHR_variable_pointers", "SPV_KHR_vulkan_memory_model", "SPV_NVX_multiview_per_view_attributes", "SPV_NV_compute_shader_derivatives", "SPV_NV_cooperative_matrix", "SPV_NV_fragment_shader_barycentric", "SPV_NV_geometry_shader_passthrough", "SPV_NV_mesh_shader", "SPV_NV_ray_tracing", "SPV_NV_sample_mask_override_coverage", "SPV_NV_shader_image_footprint", "SPV_NV_shader_subgroup_partitioned", "SPV_NV_shading_rate", "SPV_NV_stereo_view_rendering", "SPV_NV_viewport_array2", "SPV_VALIDATOR_ignore_type_decl_unique" };
static const Extension known_ext_ids[] = { Extension::kSPV_AMD_gcn_shader, Extension::kSPV_AMD_gpu_shader_half_float, Extension::kSPV_AMD_gpu_shader_half_float_fetch, Extension::kSPV_AMD_gpu_shader_int16, Extension::kSPV_AMD_shader_ballot, Extension::kSPV_AMD_shader_explicit_vertex_parameter, Extension::kSPV_AMD_shader_fragment_mask, Extension::kSPV_AMD_shader_image_load_store_lod, Extension::kSPV_AMD_shader_trinary_minmax, Extension::kSPV_AMD_texture_gather_bias_lod, Extension::kSPV_EXT_descriptor_indexing, Extension::kSPV_EXT_fragment_fully_covered, Extension::kSPV_EXT_fragment_invocation_density, Extension::kSPV_EXT_physical_storage_buffer, Extension::kSPV_EXT_shader_stencil_export, Extension::kSPV_EXT_shader_viewport_index_layer, Extension::kSPV_GOOGLE_decorate_string, Extension::kSPV_GOOGLE_hlsl_functionality1, Extension::kSPV_INTEL_device_side_avc_motion_estimation, Extension::kSPV_INTEL_media_block_io, Extension::kSPV_INTEL_shader_integer_functions2, Extension::kSPV_INTEL_subgroups, Extension::kSPV_KHR_16bit_storage, Extension::kSPV_KHR_8bit_storage, Extension::kSPV_KHR_device_group, Extension::kSPV_KHR_float_controls, Extension::kSPV_KHR_multiview, Extension::kSPV_KHR_no_integer_wrap_decoration, Extension::kSPV_KHR_post_depth_coverage, Extension::kSPV_KHR_shader_atomic_counter_ops, Extension::kSPV_KHR_shader_ballot, Extension::kSPV_KHR_shader_draw_parameters, Extension::kSPV_KHR_storage_buffer_storage_class, Extension::kSPV_KHR_subgroup_vote, Extension::kSPV_KHR_variable_pointers, Extension::kSPV_KHR_vulkan_memory_model, Extension::kSPV_NVX_multiview_per_view_attributes, Extension::kSPV_NV_compute_shader_derivatives, Extension::kSPV_NV_cooperative_matrix, Extension::kSPV_NV_fragment_shader_barycentric, Extension::kSPV_NV_geometry_shader_passthrough, Extension::kSPV_NV_mesh_shader, Extension::kSPV_NV_ray_tracing, Extension::kSPV_NV_sample_mask_override_coverage, Extension::kSPV_NV_shader_image_footprint, Extension::kSPV_NV_shader_subgroup_partitioned, Extension::kSPV_NV_shading_rate, Extension::kSPV_NV_stereo_view_rendering, Extension::kSPV_NV_viewport_array2, Extension::kSPV_VALIDATOR_ignore_type_decl_unique };
const auto b = std::begin(known_ext_strs);
const auto e = std::end(known_ext_strs);
const auto found = std::equal_range(
@@ -358,6 +360,8 @@ const char* CapabilityToString(SpvCapability capability) {
return "SubgroupImageBlockIOINTEL";
case SpvCapabilitySubgroupImageMediaBlockIOINTEL:
return "SubgroupImageMediaBlockIOINTEL";
case SpvCapabilityIntegerFunctions2INTEL:
return "IntegerFunctions2INTEL";
case SpvCapabilitySubgroupAvcMotionEstimationINTEL:
return "SubgroupAvcMotionEstimationINTEL";
case SpvCapabilitySubgroupAvcMotionEstimationIntraINTEL:

View File

@@ -18,6 +18,7 @@ kSPV_GOOGLE_decorate_string,
kSPV_GOOGLE_hlsl_functionality1,
kSPV_INTEL_device_side_avc_motion_estimation,
kSPV_INTEL_media_block_io,
kSPV_INTEL_shader_integer_functions2,
kSPV_INTEL_subgroups,
kSPV_KHR_16bit_storage,
kSPV_KHR_8bit_storage,

View File

@@ -19,3 +19,4 @@
{18, "Wine", "VKD3D Shader Compiler", "Wine VKD3D Shader Compiler"},
{19, "Clay", "Clay Shader Compiler", "Clay Clay Shader Compiler"},
{20, "W3C WebGPU Group", "WHLSL Shader Translator", "W3C WebGPU Group WHLSL Shader Translator"},
{21, "Google", "Clspv", "Google Clspv"},

File diff suppressed because it is too large Load Diff

View File

@@ -427,6 +427,8 @@ typedef enum {
SPV_ENV_UNIVERSAL_1_3, // SPIR-V 1.3 latest revision, no other restrictions.
SPV_ENV_VULKAN_1_1, // Vulkan 1.1 latest revision.
SPV_ENV_WEBGPU_0, // Work in progress WebGPU 1.0.
SPV_ENV_UNIVERSAL_1_4, // SPIR-V 1.4 latest revision, no other restrictions.
SPV_ENV_VULKAN_1_1_SPIRV_1_4, // Vulkan 1.1 with SPIR-V 1.4 binary.
} spv_target_env;
// SPIR-V Validator can be parameterized with the following Universal Limits.
@@ -492,6 +494,20 @@ SPIRV_TOOLS_EXPORT void spvValidatorOptionsSetRelaxStoreStruct(
SPIRV_TOOLS_EXPORT void spvValidatorOptionsSetRelaxLogicalPointer(
spv_validator_options options, bool val);
// Records whether or not the validator should relax the rules because it is
// expected that the optimizations will make the code legal.
//
// When relaxed, it will allow the following:
// 1) It will allow relaxed logical pointers. Setting this option will also
// set that option.
// 2) Pointers that are pass as parameters to function calls do not have to
// match the storage class of the formal parameter.
// 3) Pointers that are actaul parameters on function calls do not have to point
// to the same type pointed as the formal parameter. The types just need to
// logically match.
SPIRV_TOOLS_EXPORT void spvValidatorOptionsSetBeforeHlslLegalization(
spv_validator_options options, bool val);
// Records whether the validator should use "relaxed" block layout rules.
// Relaxed layout rules are described by Vulkan extension
// VK_KHR_relaxed_block_layout, and they affect uniform blocks, storage blocks,
@@ -502,6 +518,11 @@ SPIRV_TOOLS_EXPORT void spvValidatorOptionsSetRelaxLogicalPointer(
SPIRV_TOOLS_EXPORT void spvValidatorOptionsSetRelaxBlockLayout(
spv_validator_options options, bool val);
// Records whether the validator should use standard block layout rules for
// uniform blocks.
SPIRV_TOOLS_EXPORT void spvValidatorOptionsSetUniformBufferStandardLayout(
spv_validator_options options, bool val);
// Records whether the validator should use "scalar" block layout rules.
// Scalar layout rules are more permissive than relaxed block layout.
//

View File

@@ -88,6 +88,12 @@ class ValidatorOptions {
spvValidatorOptionsSetRelaxBlockLayout(options_, val);
}
// Enables VK_KHR_uniform_buffer_standard_layout when validating standard
// uniform layout. If true, disables scalar block layout rules.
void SetUniformBufferStandardLayout(bool val) {
spvValidatorOptionsSetUniformBufferStandardLayout(options_, val);
}
// Enables VK_EXT_scalar_block_layout when validating standard
// uniform/storage buffer/push-constant layout. If true, disables
// relaxed block layout rules.
@@ -110,6 +116,21 @@ class ValidatorOptions {
spvValidatorOptionsSetRelaxLogicalPointer(options_, val);
}
// Records whether or not the validator should relax the rules because it is
// expected that the optimizations will make the code legal.
//
// When relaxed, it will allow the following:
// 1) It will allow relaxed logical pointers. Setting this option will also
// set that option.
// 2) Pointers that are pass as parameters to function calls do not have to
// match the storage class of the formal parameter.
// 3) Pointers that are actaul parameters on function calls do not have to
// point to the same type pointed as the formal parameter. The types just
// need to logically match.
void SetBeforeHlslLegalization(bool val) {
spvValidatorOptionsSetBeforeHlslLegalization(options_, val);
}
private:
spv_validator_options options_;
};

View File

@@ -772,6 +772,10 @@ Optimizer::PassToken CreateLegalizeVectorShufflePass();
// declaration and an initial store.
Optimizer::PassToken CreateDecomposeInitializedVariablesPass();
// Create a pass to attempt to split up invalid unreachable merge-blocks and
// continue-targets to legalize for WebGPU.
Optimizer::PassToken CreateSplitInvalidUnreachablePass();
} // namespace spvtools
#endif // INCLUDE_SPIRV_TOOLS_OPTIMIZER_HPP_

View File

@@ -30,6 +30,7 @@
#include "glsl.std.450.insts.inc"
#include "opencl.std.insts.inc"
#include "spirv-tools/libspirv.h"
#include "spv-amd-gcn-shader.insts.inc"
#include "spv-amd-shader-ballot.insts.inc"
#include "spv-amd-shader-explicit-vertex-parameter.insts.inc"
@@ -80,7 +81,9 @@ spv_result_t spvExtInstTableGet(spv_ext_inst_table* pExtInstTable,
case SPV_ENV_OPENGL_4_5:
case SPV_ENV_UNIVERSAL_1_3:
case SPV_ENV_VULKAN_1_1:
case SPV_ENV_VULKAN_1_1_SPIRV_1_4:
case SPV_ENV_WEBGPU_0:
case SPV_ENV_UNIVERSAL_1_4:
*pExtInstTable = &kTable_1_0;
return SPV_SUCCESS;
default:

View File

@@ -97,6 +97,7 @@ spv_result_t spvOpcodeTableNameLookup(spv_target_env env,
// preferable but the table requires sorting on the Opcode name, but it's
// static const initialized and matches the order of the spec.
const size_t nameLength = strlen(name);
const auto version = spvVersionForTargetEnv(env);
for (uint64_t opcodeIndex = 0; opcodeIndex < table->count; ++opcodeIndex) {
const spv_opcode_desc_t& entry = table->entries[opcodeIndex];
// We considers the current opcode as available as long as
@@ -107,7 +108,7 @@ spv_result_t spvOpcodeTableNameLookup(spv_target_env env,
// Note that the second rule assumes the extension enabling this instruction
// is indeed requested in the SPIR-V code; checking that should be
// validator's work.
if ((spvVersionForTargetEnv(env) >= entry.minVersion ||
if (((version >= entry.minVersion && version <= entry.lastVersion) ||
entry.numExtensions > 0u || entry.numCapabilities > 0u) &&
nameLength == strlen(entry.name) &&
!strncmp(name, entry.name, nameLength)) {
@@ -130,8 +131,8 @@ spv_result_t spvOpcodeTableValueLookup(spv_target_env env,
const auto beg = table->entries;
const auto end = table->entries + table->count;
spv_opcode_desc_t needle = {"", opcode, 0, nullptr, 0, {},
false, false, 0, nullptr, ~0u};
spv_opcode_desc_t needle = {"", opcode, 0, nullptr, 0, {},
false, false, 0, nullptr, ~0u, ~0u};
auto comp = [](const spv_opcode_desc_t& lhs, const spv_opcode_desc_t& rhs) {
return lhs.opcode < rhs.opcode;
@@ -142,6 +143,7 @@ spv_result_t spvOpcodeTableValueLookup(spv_target_env env,
// which means they can have different minimal version requirements.
// Assumes the underlying table is already sorted ascendingly according to
// opcode value.
const auto version = spvVersionForTargetEnv(env);
for (auto it = std::lower_bound(beg, end, needle, comp);
it != end && it->opcode == opcode; ++it) {
// We considers the current opcode as available as long as
@@ -152,7 +154,7 @@ spv_result_t spvOpcodeTableValueLookup(spv_target_env env,
// Note that the second rule assumes the extension enabling this instruction
// is indeed requested in the SPIR-V code; checking that should be
// validator's work.
if (spvVersionForTargetEnv(env) >= it->minVersion ||
if ((version >= it->minVersion && version <= it->lastVersion) ||
it->numExtensions > 0u || it->numCapabilities > 0u) {
*pEntry = it;
return SPV_SUCCESS;
@@ -182,8 +184,8 @@ void spvInstructionCopy(const uint32_t* words, const SpvOp opcode,
const char* spvOpcodeString(const SpvOp opcode) {
const auto beg = kOpcodeTableEntries;
const auto end = kOpcodeTableEntries + ARRAY_SIZE(kOpcodeTableEntries);
spv_opcode_desc_t needle = {"", opcode, 0, nullptr, 0, {},
false, false, 0, nullptr, ~0u};
spv_opcode_desc_t needle = {"", opcode, 0, nullptr, 0, {},
false, false, 0, nullptr, ~0u, ~0u};
auto comp = [](const spv_opcode_desc_t& lhs, const spv_opcode_desc_t& rhs) {
return lhs.opcode < rhs.opcode;
};

View File

@@ -16,6 +16,7 @@
#include <assert.h>
#include <string.h>
#include <algorithm>
#include "source/macro.h"
@@ -50,6 +51,7 @@ spv_result_t spvOperandTableNameLookup(spv_target_env env,
if (!table) return SPV_ERROR_INVALID_TABLE;
if (!name || !pEntry) return SPV_ERROR_INVALID_POINTER;
const auto version = spvVersionForTargetEnv(env);
for (uint64_t typeIndex = 0; typeIndex < table->count; ++typeIndex) {
const auto& group = table->types[typeIndex];
if (type != group.type) continue;
@@ -64,7 +66,7 @@ spv_result_t spvOperandTableNameLookup(spv_target_env env,
// Note that the second rule assumes the extension enabling this operand
// is indeed requested in the SPIR-V code; checking that should be
// validator's work.
if ((spvVersionForTargetEnv(env) >= entry.minVersion ||
if (((version >= entry.minVersion && version <= entry.lastVersion) ||
entry.numExtensions > 0u || entry.numCapabilities > 0u) &&
nameLength == strlen(entry.name) &&
!strncmp(entry.name, name, nameLength)) {
@@ -85,7 +87,7 @@ spv_result_t spvOperandTableValueLookup(spv_target_env env,
if (!table) return SPV_ERROR_INVALID_TABLE;
if (!pEntry) return SPV_ERROR_INVALID_POINTER;
spv_operand_desc_t needle = {"", value, 0, nullptr, 0, nullptr, {}, ~0u};
spv_operand_desc_t needle = {"", value, 0, nullptr, 0, nullptr, {}, ~0u, ~0u};
auto comp = [](const spv_operand_desc_t& lhs, const spv_operand_desc_t& rhs) {
return lhs.value < rhs.value;
@@ -108,6 +110,7 @@ spv_result_t spvOperandTableValueLookup(spv_target_env env,
// requirements.
// Assumes the underlying table is already sorted ascendingly according to
// opcode value.
const auto version = spvVersionForTargetEnv(env);
for (auto it = std::lower_bound(beg, end, needle, comp);
it != end && it->value == value; ++it) {
// We consider the current operand as available as long as
@@ -119,7 +122,7 @@ spv_result_t spvOperandTableValueLookup(spv_target_env env,
// Note that the second rule assumes the extension enabling this operand
// is indeed requested in the SPIR-V code; checking that should be
// validator's work.
if (spvVersionForTargetEnv(env) >= it->minVersion ||
if ((version >= it->minVersion && version <= it->lastVersion) ||
it->numExtensions > 0u || it->numCapabilities > 0u) {
*pEntry = it;
return SPV_SUCCESS;

View File

@@ -97,6 +97,7 @@ set(SPIRV_TOOLS_OPT_SOURCES
scalar_replacement_pass.h
set_spec_constant_default_value_pass.h
simplification_pass.h
split_invalid_unreachable_pass.h
ssa_rewrite_pass.h
strength_reduction_pass.h
strip_atomic_counter_memory_pass.h
@@ -195,6 +196,7 @@ set(SPIRV_TOOLS_OPT_SOURCES
scalar_replacement_pass.cpp
set_spec_constant_default_value_pass.cpp
simplification_pass.cpp
split_invalid_unreachable_pass.cpp
ssa_rewrite_pass.cpp
strength_reduction_pass.cpp
strip_atomic_counter_memory_pass.cpp

View File

@@ -24,6 +24,7 @@
#include "source/latest_version_glsl_std_450_header.h"
#include "source/opt/iterator.h"
#include "source/opt/reflect.h"
#include "source/spirv_constant.h"
namespace spvtools {
namespace opt {
@@ -548,7 +549,26 @@ void AggressiveDCEPass::InitializeModuleScopeLiveInstructions() {
}
// Keep all entry points.
for (auto& entry : get_module()->entry_points()) {
AddToWorklist(&entry);
if (get_module()->version() >= SPV_SPIRV_VERSION_WORD(1, 4)) {
// In SPIR-V 1.4 and later, entry points must list all global variables
// used. DCE can still remove non-input/output variables and update the
// interface list. Mark the entry point as live and inputs and outputs as
// live, but defer decisions all other interfaces.
live_insts_.Set(entry.unique_id());
// The actual function is live always.
AddToWorklist(
get_def_use_mgr()->GetDef(entry.GetSingleWordInOperand(1u)));
for (uint32_t i = 3; i < entry.NumInOperands(); ++i) {
auto* var = get_def_use_mgr()->GetDef(entry.GetSingleWordInOperand(i));
auto storage_class = var->GetSingleWordInOperand(0u);
if (storage_class == SpvStorageClassInput ||
storage_class == SpvStorageClassOutput) {
AddToWorklist(var);
}
}
} else {
AddToWorklist(&entry);
}
}
// Keep workgroup size.
for (auto& anno : get_module()->annotations()) {
@@ -780,6 +800,29 @@ bool AggressiveDCEPass::ProcessGlobalValues() {
}
}
if (get_module()->version() >= SPV_SPIRV_VERSION_WORD(1, 4)) {
// Remove the dead interface variables from the entry point interface list.
for (auto& entry : get_module()->entry_points()) {
std::vector<Operand> new_operands;
for (uint32_t i = 0; i < entry.NumInOperands(); ++i) {
if (i < 3) {
// Execution model, function id and name are always valid.
new_operands.push_back(entry.GetInOperand(i));
} else {
auto* var =
get_def_use_mgr()->GetDef(entry.GetSingleWordInOperand(i));
if (!IsDead(var)) {
new_operands.push_back(entry.GetInOperand(i));
}
}
}
if (new_operands.size() != entry.NumInOperands()) {
entry.SetInOperands(std::move(new_operands));
get_def_use_mgr()->UpdateDefUse(&entry);
}
}
}
return modified;
}

View File

@@ -167,6 +167,10 @@ Instruction* ConstantManager::BuildInstructionAndAddToModule(
const Constant* new_const, Module::inst_iterator* pos, uint32_t type_id) {
// TODO(1841): Handle id overflow.
uint32_t new_id = context()->TakeNextId();
if (new_id == 0) {
return nullptr;
}
auto new_inst = CreateInstruction(new_id, new_const, type_id);
if (!new_inst) {
return nullptr;

View File

@@ -147,6 +147,19 @@ BasicBlock* Function::InsertBasicBlockAfter(
return nullptr;
}
BasicBlock* Function::InsertBasicBlockBefore(
std::unique_ptr<BasicBlock>&& new_block, BasicBlock* position) {
for (auto bb_iter = begin(); bb_iter != end(); ++bb_iter) {
if (&*bb_iter == position) {
new_block->SetParent(this);
bb_iter = bb_iter.InsertBefore(std::move(new_block));
return &*bb_iter;
}
}
assert(false && "Could not find insertion point.");
return nullptr;
}
bool Function::IsRecursive() const {
IRContext* ctx = blocks_.front()->GetLabel()->context();
IRContext::ProcessFunction mark_visited = [this](Function* fp) {

View File

@@ -125,6 +125,9 @@ class Function {
BasicBlock* InsertBasicBlockAfter(std::unique_ptr<BasicBlock>&& new_block,
BasicBlock* position);
BasicBlock* InsertBasicBlockBefore(std::unique_ptr<BasicBlock>&& new_block,
BasicBlock* position);
// Return true if the function calls itself either directly or indirectly.
bool IsRecursive() const;

View File

@@ -29,6 +29,7 @@ static const int kSpvAccessChainIndex0IdInIdx = 1;
static const int kSpvTypePointerTypeIdInIdx = 1;
static const int kSpvTypeArrayLengthIdInIdx = 1;
static const int kSpvConstantValueInIdx = 0;
static const int kSpvVariableStorageClassInIdx = 0;
} // anonymous namespace
@@ -59,36 +60,42 @@ uint32_t InstBindlessCheckPass::GenDebugReadInit(uint32_t var_id,
uint32_t InstBindlessCheckPass::CloneOriginalReference(
ref_analysis* ref, InstructionBuilder* builder) {
// Clone descriptor load
Instruction* load_inst = get_def_use_mgr()->GetDef(ref->load_id);
Instruction* new_load_inst =
builder->AddLoad(load_inst->type_id(),
load_inst->GetSingleWordInOperand(kSpvLoadPtrIdInIdx));
uid2offset_[new_load_inst->unique_id()] = uid2offset_[load_inst->unique_id()];
uint32_t new_load_id = new_load_inst->result_id();
get_decoration_mgr()->CloneDecorations(load_inst->result_id(), new_load_id);
uint32_t new_image_id = new_load_id;
// Clone Image/SampledImage with new load, if needed
if (ref->image_id != 0) {
Instruction* image_inst = get_def_use_mgr()->GetDef(ref->image_id);
if (image_inst->opcode() == SpvOp::SpvOpSampledImage) {
Instruction* new_image_inst = builder->AddBinaryOp(
image_inst->type_id(), SpvOpSampledImage, new_load_id,
image_inst->GetSingleWordInOperand(kSpvSampledImageSamplerIdInIdx));
uid2offset_[new_image_inst->unique_id()] =
uid2offset_[image_inst->unique_id()];
new_image_id = new_image_inst->result_id();
} else {
assert(image_inst->opcode() == SpvOp::SpvOpImage && "expecting OpImage");
Instruction* new_image_inst =
builder->AddUnaryOp(image_inst->type_id(), SpvOpImage, new_load_id);
uid2offset_[new_image_inst->unique_id()] =
uid2offset_[image_inst->unique_id()];
new_image_id = new_image_inst->result_id();
// If original is image based, start by cloning descriptor load
uint32_t new_image_id = 0;
if (ref->desc_load_id != 0) {
Instruction* desc_load_inst = get_def_use_mgr()->GetDef(ref->desc_load_id);
Instruction* new_load_inst = builder->AddLoad(
desc_load_inst->type_id(),
desc_load_inst->GetSingleWordInOperand(kSpvLoadPtrIdInIdx));
uid2offset_[new_load_inst->unique_id()] =
uid2offset_[desc_load_inst->unique_id()];
uint32_t new_load_id = new_load_inst->result_id();
get_decoration_mgr()->CloneDecorations(desc_load_inst->result_id(),
new_load_id);
new_image_id = new_load_id;
// Clone Image/SampledImage with new load, if needed
if (ref->image_id != 0) {
Instruction* image_inst = get_def_use_mgr()->GetDef(ref->image_id);
if (image_inst->opcode() == SpvOp::SpvOpSampledImage) {
Instruction* new_image_inst = builder->AddBinaryOp(
image_inst->type_id(), SpvOpSampledImage, new_load_id,
image_inst->GetSingleWordInOperand(kSpvSampledImageSamplerIdInIdx));
uid2offset_[new_image_inst->unique_id()] =
uid2offset_[image_inst->unique_id()];
new_image_id = new_image_inst->result_id();
} else {
assert(image_inst->opcode() == SpvOp::SpvOpImage &&
"expecting OpImage");
Instruction* new_image_inst =
builder->AddUnaryOp(image_inst->type_id(), SpvOpImage, new_load_id);
uid2offset_[new_image_inst->unique_id()] =
uid2offset_[image_inst->unique_id()];
new_image_id = new_image_inst->result_id();
}
get_decoration_mgr()->CloneDecorations(ref->image_id, new_image_id);
}
get_decoration_mgr()->CloneDecorations(ref->image_id, new_image_id);
}
// Clone original reference using new image code
// Clone original reference
std::unique_ptr<Instruction> new_ref_inst(ref->ref_inst->Clone(context()));
uint32_t ref_result_id = ref->ref_inst->result_id();
uint32_t new_ref_id = 0;
@@ -96,7 +103,9 @@ uint32_t InstBindlessCheckPass::CloneOriginalReference(
new_ref_id = TakeNextId();
new_ref_inst->SetResultId(new_ref_id);
}
new_ref_inst->SetInOperand(kSpvImageSampleImageIdInIdx, {new_image_id});
// Update new ref with new image if created
if (new_image_id != 0)
new_ref_inst->SetInOperand(kSpvImageSampleImageIdInIdx, {new_image_id});
// Register new reference and add to new block
Instruction* added_inst = builder->AddInstruction(std::move(new_ref_inst));
uid2offset_[added_inst->unique_id()] =
@@ -106,7 +115,7 @@ uint32_t InstBindlessCheckPass::CloneOriginalReference(
return new_ref_id;
}
uint32_t InstBindlessCheckPass::GetDescriptorValueId(Instruction* inst) {
uint32_t InstBindlessCheckPass::GetImageId(Instruction* inst) {
switch (inst->opcode()) {
case SpvOp::SpvOpImageSampleImplicitLod:
case SpvOp::SpvOpImageSampleExplicitLod:
@@ -147,27 +156,77 @@ uint32_t InstBindlessCheckPass::GetDescriptorValueId(Instruction* inst) {
return 0;
}
Instruction* InstBindlessCheckPass::GetDescriptorTypeInst(
Instruction* var_inst) {
uint32_t var_type_id = var_inst->type_id();
Instruction* var_type_inst = get_def_use_mgr()->GetDef(var_type_id);
uint32_t desc_type_id =
var_type_inst->GetSingleWordInOperand(kSpvTypePointerTypeIdInIdx);
return get_def_use_mgr()->GetDef(desc_type_id);
}
bool InstBindlessCheckPass::AnalyzeDescriptorReference(Instruction* ref_inst,
ref_analysis* ref) {
ref->image_id = GetDescriptorValueId(ref_inst);
ref->ref_inst = ref_inst;
if (ref_inst->opcode() == SpvOpLoad || ref_inst->opcode() == SpvOpStore) {
ref->desc_load_id = 0;
ref->ptr_id = ref_inst->GetSingleWordInOperand(kSpvLoadPtrIdInIdx);
Instruction* ptr_inst = get_def_use_mgr()->GetDef(ref->ptr_id);
if (ptr_inst->opcode() != SpvOp::SpvOpAccessChain) return false;
ref->var_id = ptr_inst->GetSingleWordInOperand(kSpvAccessChainBaseIdInIdx);
Instruction* var_inst = get_def_use_mgr()->GetDef(ref->var_id);
if (var_inst->opcode() != SpvOp::SpvOpVariable) return false;
uint32_t storage_class =
var_inst->GetSingleWordInOperand(kSpvVariableStorageClassInIdx);
switch (storage_class) {
case SpvStorageClassUniform:
case SpvStorageClassUniformConstant:
case SpvStorageClassStorageBuffer:
break;
default:
return false;
break;
}
Instruction* desc_type_inst = GetDescriptorTypeInst(var_inst);
switch (desc_type_inst->opcode()) {
case SpvOpTypeArray:
case SpvOpTypeRuntimeArray:
// A load through a descriptor array will have at least 3 operands. We
// do not want to instrument loads of descriptors here which are part of
// an image-based reference.
if (ptr_inst->NumInOperands() < 3) return false;
ref->index_id =
ptr_inst->GetSingleWordInOperand(kSpvAccessChainIndex0IdInIdx);
break;
default:
ref->index_id = 0;
break;
}
return true;
}
// Reference is not load or store. If not an image-based reference, return.
ref->image_id = GetImageId(ref_inst);
if (ref->image_id == 0) return false;
Instruction* image_inst = get_def_use_mgr()->GetDef(ref->image_id);
Instruction* desc_load_inst = nullptr;
if (image_inst->opcode() == SpvOp::SpvOpSampledImage) {
ref->load_id =
ref->desc_load_id =
image_inst->GetSingleWordInOperand(kSpvSampledImageImageIdInIdx);
desc_load_inst = get_def_use_mgr()->GetDef(ref->desc_load_id);
} else if (image_inst->opcode() == SpvOp::SpvOpImage) {
ref->load_id =
ref->desc_load_id =
image_inst->GetSingleWordInOperand(kSpvImageSampledImageIdInIdx);
desc_load_inst = get_def_use_mgr()->GetDef(ref->desc_load_id);
} else {
ref->load_id = ref->image_id;
ref->desc_load_id = ref->image_id;
desc_load_inst = image_inst;
ref->image_id = 0;
}
Instruction* load_inst = get_def_use_mgr()->GetDef(ref->load_id);
if (load_inst->opcode() != SpvOp::SpvOpLoad) {
if (desc_load_inst->opcode() != SpvOp::SpvOpLoad) {
// TODO(greg-lunarg): Handle additional possibilities?
return false;
}
ref->ptr_id = load_inst->GetSingleWordInOperand(kSpvLoadPtrIdInIdx);
ref->ptr_id = desc_load_inst->GetSingleWordInOperand(kSpvLoadPtrIdInIdx);
Instruction* ptr_inst = get_def_use_mgr()->GetDef(ref->ptr_id);
if (ptr_inst->opcode() == SpvOp::SpvOpVariable) {
ref->index_id = 0;
@@ -189,7 +248,6 @@ bool InstBindlessCheckPass::AnalyzeDescriptorReference(Instruction* ref_inst,
// TODO(greg-lunarg): Handle additional possibilities?
return false;
}
ref->ref_inst = ref_inst;
return true;
}
@@ -260,11 +318,7 @@ void InstBindlessCheckPass::GenBoundsCheckCode(
// If index and bound both compile-time constants and index < bound,
// return without changing
Instruction* var_inst = get_def_use_mgr()->GetDef(ref.var_id);
uint32_t var_type_id = var_inst->type_id();
Instruction* var_type_inst = get_def_use_mgr()->GetDef(var_type_id);
uint32_t desc_type_id =
var_type_inst->GetSingleWordInOperand(kSpvTypePointerTypeIdInIdx);
Instruction* desc_type_inst = get_def_use_mgr()->GetDef(desc_type_id);
Instruction* desc_type_inst = GetDescriptorTypeInst(var_inst);
uint32_t length_id = 0;
if (desc_type_inst->opcode() == SpvOpTypeArray) {
length_id =

View File

@@ -118,6 +118,7 @@ class InstBindlessCheckPass : public InstrumentPass {
// AnalyzeDescriptorReference. It is necessary and sufficient for further
// analysis and regeneration of the reference.
typedef struct ref_analysis {
uint32_t desc_load_id;
uint32_t image_id;
uint32_t load_id;
uint32_t ptr_id;
@@ -131,9 +132,12 @@ class InstBindlessCheckPass : public InstrumentPass {
uint32_t CloneOriginalReference(ref_analysis* ref,
InstructionBuilder* builder);
// If |inst| references through a descriptor, (ie references into an image
// or buffer), return the id of the value it references. Else return 0.
uint32_t GetDescriptorValueId(Instruction* inst);
// If |inst| references through an image, return the id of the image it
// references through. Else return 0.
uint32_t GetImageId(Instruction* inst);
// Get descriptor type inst of variable |var_inst|.
Instruction* GetDescriptorTypeInst(Instruction* var_inst);
// Analyze descriptor reference |ref_inst| and save components into |ref|.
// Return true if |ref_inst| is a descriptor reference, false otherwise.

Some files were not shown because too many files have changed in this diff Show More