diff --git a/Apps/Playground/Scripts/experience.js b/Apps/Playground/Scripts/experience.js index 0d26d1e5a..d107b7196 100644 --- a/Apps/Playground/Scripts/experience.js +++ b/Apps/Playground/Scripts/experience.js @@ -148,6 +148,13 @@ CreateBoxAsync(scene).then(function () { context.lineTo(140, 140); context.stroke(); + // filter blur text + context.filter = "blur(1.25px)"; + context.fillStyle = "White"; + context.font = `bold ${50}px monospace`; + context.fillText("BLUR TEST BLUR TEST", 100, 246); + context.filter = "none"; + // Draw lines context.strokeStyle = "black"; ["butt", "round", "square"].forEach((lineCap, i) => { @@ -248,7 +255,6 @@ CreateBoxAsync(scene).then(function () { }); }, undefined, undefined, true); - // This creates and positions a free camera (non-mesh) scene.createDefaultCamera(true, true, true); scene.activeCamera.alpha += Math.PI; diff --git a/Polyfills/Canvas/CMakeLists.txt b/Polyfills/Canvas/CMakeLists.txt index 3eb7955b8..8171ac010 100644 --- a/Polyfills/Canvas/CMakeLists.txt +++ b/Polyfills/Canvas/CMakeLists.txt @@ -95,6 +95,8 @@ set(SOURCES "Source/Canvas.cpp" "Source/Canvas.h" "Source/Colors.h" + "Source/FrameBufferPool.cpp" + "Source/FrameBufferPool.h" "Source/Image.cpp" "Source/Image.h" "Source/ImageData.cpp" @@ -115,6 +117,8 @@ set(SOURCES "Source/nanovg/nanovg.h" "Source/nanovg/nanovg_babylon.cpp" "Source/nanovg/nanovg_babylon.h" + "Source/nanovg/nanovg_filterstack.cpp" + "Source/nanovg/nanovg_filterstack.h" ) file(GLOB SHADERS "Source/Shaders/*.sc" "Source/Shaders/*.sh") diff --git a/Polyfills/Canvas/Source/Canvas.cpp b/Polyfills/Canvas/Source/Canvas.cpp index fc96b488b..bef8311d2 100644 --- a/Polyfills/Canvas/Source/Canvas.cpp +++ b/Polyfills/Canvas/Source/Canvas.cpp @@ -159,17 +159,27 @@ namespace Babylon::Polyfills::Internal std::array attachments{}; for (size_t idx = 0; idx < attachments.size(); ++idx) { - attachments[idx].init(textures[idx]); + std::array textures{ + bgfx::createTexture2D(m_width, m_height, false, 1, bgfx::TextureFormat::RGBA8, BGFX_TEXTURE_RT) }; + + std::array attachments{}; + for (size_t idx = 0; idx < attachments.size(); ++idx) + { + attachments[idx].init(textures[idx]); + } + auto handle = bgfx::createFrameBuffer(static_cast(attachments.size()), attachments.data(), true); + assert(handle.idx != bgfx::kInvalidHandle); + m_frameBuffer = std::make_unique(m_graphicsContext, handle, m_width, m_height, false, false, false); + m_dirty = false; + + if (m_texture) + { + m_texture.reset(); + } } - auto handle = bgfx::createFrameBuffer(static_cast(attachments.size()), attachments.data(), true); - assert(handle.idx != bgfx::kInvalidHandle); - m_frameBuffer = std::make_unique(m_graphicsContext, handle, m_width, m_height, false, false, false); - m_dirty = false; - if (m_texture) - { - m_texture.reset(); - } + m_frameBufferPool.Clear(); + m_frameBufferPool.SetGraphicsContext(&m_graphicsContext); return true; } @@ -200,6 +210,7 @@ namespace Babylon::Polyfills::Internal { m_frameBuffer.reset(); m_texture.reset(); + m_frameBufferPool.Clear(); } void NativeCanvas::Dispose(const Napi::CallbackInfo& /*info*/) diff --git a/Polyfills/Canvas/Source/Canvas.h b/Polyfills/Canvas/Source/Canvas.h index e80aca2c4..2edb3914b 100644 --- a/Polyfills/Canvas/Source/Canvas.h +++ b/Polyfills/Canvas/Source/Canvas.h @@ -6,6 +6,8 @@ #include #include +#include "FrameBufferPool.h" + namespace Babylon::Polyfills { class Canvas::Impl final : public std::enable_shared_from_this @@ -67,6 +69,7 @@ namespace Babylon::Polyfills::Internal // returns true if frameBuffer size has changed bool UpdateRenderTarget(); Babylon::Graphics::FrameBuffer& GetFrameBuffer() { return *m_frameBuffer; } + FrameBufferPool m_frameBufferPool; Graphics::DeviceContext& GetGraphicsContext() { diff --git a/Polyfills/Canvas/Source/Context.cpp b/Polyfills/Canvas/Source/Context.cpp index db493b164..bbd6c5752 100644 --- a/Polyfills/Canvas/Source/Context.cpp +++ b/Polyfills/Canvas/Source/Context.cpp @@ -80,6 +80,7 @@ namespace Babylon::Polyfills::Internal InstanceAccessor("lineCap", &Context::GetLineCap, &Context::SetLineCap), InstanceAccessor("lineJoin", &Context::GetLineJoin, &Context::SetLineJoin), InstanceAccessor("miterLimit", &Context::GetMiterLimit, &Context::SetMiterLimit), + InstanceAccessor("filter", &Context::GetFilter, &Context::SetFilter), InstanceAccessor("font", &Context::GetFont, &Context::SetFont), InstanceAccessor("letterSpacing", &Context::GetLetterSpacing, &Context::SetLetterSpacing), InstanceAccessor("strokeStyle", &Context::GetStrokeStyle, &Context::SetStrokeStyle), @@ -173,6 +174,16 @@ namespace Babylon::Polyfills::Internal } } + void Context::SetFilterStack() + { + if (m_filter.length()) + { + nanovg_filterstack filterStack; + filterStack.ParseString(m_filter); + nvgFilterStack(*m_nvg, filterStack); // sets filterStack on nanovg + } + } + void Context::FillRect(const Napi::CallbackInfo& info) { auto left = info[0].As().FloatValue(); @@ -188,7 +199,8 @@ namespace Babylon::Polyfills::Internal nvgRect(*m_nvg, left, top, width, height); BindFillStyle(info, left, top, width, height); - + + SetFilterStack(); nvgFill(*m_nvg); SetDirty(); } @@ -249,6 +261,8 @@ namespace Babylon::Polyfills::Internal void Context::Fill(const Napi::CallbackInfo& info) { + SetFilterStack(); + const NativeCanvasPath2D* path = info.Length() >= 1 && info[0].IsObject() ? NativeCanvasPath2D::Unwrap(info[0].As()) : nullptr; @@ -429,6 +443,7 @@ namespace Babylon::Polyfills::Internal const auto height = info[3].As().FloatValue(); nvgRect(*m_nvg, left, top, width, height); + SetFilterStack(); nvgStroke(*m_nvg); SetDirty(); } @@ -505,6 +520,7 @@ namespace Babylon::Polyfills::Internal SetDirty(); } + SetFilterStack(); nvgStroke(*m_nvg); SetDirty(); } @@ -571,6 +587,13 @@ namespace Babylon::Polyfills::Internal { BindFillStyle(info, 0.f, 0.f, x, y); + if (m_filter.length()) + { + nanovg_filterstack filterStack; + filterStack.ParseString(m_filter); + nvgFilterStack(*m_nvg, filterStack); // sets filterStack on nanovg + } + nvgText(*m_nvg, x, y, text.c_str(), nullptr); SetDirty(); } @@ -605,10 +628,35 @@ namespace Babylon::Polyfills::Internal const auto width = m_canvas->GetWidth(); const auto height = m_canvas->GetHeight(); + for (auto& buffer : m_canvas->m_frameBufferPool.GetPoolBuffers()) + { + // sanity check no buffers should have been acquired yet + assert(buffer.isAvailable == true); + } + std::function acquire = [this, encoder]() -> Babylon::Graphics::FrameBuffer* { + Babylon::Graphics::FrameBuffer *frameBuffer = this->m_canvas->m_frameBufferPool.Acquire(); + frameBuffer->Bind(*encoder); + return frameBuffer; + }; + std::function release = [this, encoder](Babylon::Graphics::FrameBuffer* frameBuffer) -> void { + // clear framebuffer when released + frameBuffer->Clear(*encoder, BGFX_CLEAR_COLOR, 0, 0, 0); + this->m_canvas->m_frameBufferPool.Release(frameBuffer); + frameBuffer->Unbind(*encoder); + }; + nvgBeginFrame(*m_nvg, float(width), float(height), 1.0f); nvgSetFrameBufferAndEncoder(*m_nvg, frameBuffer, encoder); + nvgSetFrameBufferPool(*m_nvg, { acquire, release }); nvgEndFrame(*m_nvg); frameBuffer.Unbind(*encoder); + + for (auto& buffer : m_canvas->m_frameBufferPool.GetPoolBuffers()) + { + // sanity check no unreleased buffers + assert(buffer.isAvailable == true); + } + m_dirty = false; }).then(arcana::inline_scheduler, *m_cancellationSource, [this, cancellationSource{m_cancellationSource}](const arcana::expected& result) { if (!cancellationSource->cancelled() && result.has_error()) @@ -669,6 +717,7 @@ namespace Babylon::Polyfills::Internal nvgRect(*m_nvg, dx, dy, width, height); nvgFillPaint(*m_nvg, imagePaint); + SetFilterStack(); nvgFill(*m_nvg); SetDirty(); } @@ -688,6 +737,7 @@ namespace Babylon::Polyfills::Internal nvgRect(*m_nvg, dx, dy, dWidth, dHeight); nvgFillPaint(*m_nvg, imagePaint); + SetFilterStack(); nvgFill(*m_nvg); SetDirty(); } @@ -713,6 +763,7 @@ namespace Babylon::Polyfills::Internal nvgRect(*m_nvg, dx, dy, dWidth, dHeight); nvgFillPaint(*m_nvg, imagePaint); + SetFilterStack(); nvgFill(*m_nvg); SetDirty(); } @@ -853,6 +904,21 @@ namespace Babylon::Polyfills::Internal SetDirty(); } + Napi::Value Context::GetFilter(const Napi::CallbackInfo& info) + { + return Napi::Value::From(Env(), m_filter); + } + + void Context::SetFilter(const Napi::CallbackInfo& info, const Napi::Value& value) + { + std::string filterString = value.As().Utf8Value(); + // Keep existing filter if the new one is invalid + if (nanovg_filterstack::ValidString(filterString)) + { + m_filter = filterString; + } + } + Napi::Value Context::GetFont(const Napi::CallbackInfo& info) { return Napi::Value::From(Env(), static_cast(m_font)); diff --git a/Polyfills/Canvas/Source/Context.h b/Polyfills/Canvas/Source/Context.h index 5ab89aff4..541bbcb2a 100644 --- a/Polyfills/Canvas/Source/Context.h +++ b/Polyfills/Canvas/Source/Context.h @@ -6,6 +6,7 @@ #include "Image.h" #include "Path2D.h" #include "Font.h" +#include "nanovg/nanovg_filterstack.h" struct NVGcontext; @@ -68,6 +69,8 @@ namespace Babylon::Polyfills::Internal void SetLineJoin(const Napi::CallbackInfo&, const Napi::Value& value); Napi::Value GetMiterLimit(const Napi::CallbackInfo&); void SetMiterLimit(const Napi::CallbackInfo&, const Napi::Value& value); + Napi::Value GetFilter(const Napi::CallbackInfo& info); + void SetFilter(const Napi::CallbackInfo& info, const Napi::Value& value); Napi::Value GetFont(const Napi::CallbackInfo&); void SetFont(const Napi::CallbackInfo&, const Napi::Value& value); Napi::Value GetLetterSpacing(const Napi::CallbackInfo&); @@ -97,6 +100,7 @@ namespace Babylon::Polyfills::Internal std::string m_strokeStyle{}; std::string m_lineCap{}; // 'butt', 'round', 'square' std::string m_lineJoin{}; // 'round', 'bevel', 'miter' + std::string m_filter{}; float m_miterLimit{0.f}; float m_lineWidth{0.f}; float m_globalAlpha{1.f}; @@ -123,6 +127,7 @@ namespace Babylon::Polyfills::Internal void BindFillStyle(const Napi::CallbackInfo& info, float left, float top, float width, float height); void FlushGraphicResources() override; void PlayPath2D(const NativeCanvasPath2D* path); + void SetFilterStack(); friend class Canvas; }; diff --git a/Polyfills/Canvas/Source/FrameBufferPool.cpp b/Polyfills/Canvas/Source/FrameBufferPool.cpp new file mode 100644 index 000000000..f3b660daf --- /dev/null +++ b/Polyfills/Canvas/Source/FrameBufferPool.cpp @@ -0,0 +1,105 @@ +#include +#include +#include + +#include +#include +#include "FrameBufferPool.h" + +namespace Babylon::Polyfills +{ + const std::vector& FrameBufferPool::GetPoolBuffers() + { + return mPoolBuffers; + } + + // sets graphics context to be used for creating framebuffers + void FrameBufferPool::SetGraphicsContext(Graphics::DeviceContext* graphicsContext) + { + m_graphicsContext = graphicsContext; + } + + void FrameBufferPool::Add(int nBuffers) + { + if (m_graphicsContext == nullptr) + { + throw std::runtime_error("Cannot add framebuffer to pool. Graphics context is not set."); + } + + for (int i = 0; i < nBuffers; ++i) + { + bgfx::FrameBufferHandle TextBuffer{bgfx::kInvalidHandle}; + Graphics::FrameBuffer* FrameBuffer; + int width(256), height(256); + + // make sure render targets are filled with 0 : https://registry.khronos.org/webgl/specs/latest/1.0/#TEXIMAGE2D + bgfx::ReleaseFn releaseFn{[](void*, void* userData) { + bimg::imageFree(static_cast(userData)); + }}; + + bimg::ImageContainer* image = bimg::imageAlloc(&Babylon::Graphics::DeviceContext::GetDefaultAllocator(), bimg::TextureFormat::RGBA8, width, height, 1 /*depth*/, 1, false /*cubeMap*/, false /*hasMips*/); + const bgfx::Memory* mem = bgfx::makeRef(image->m_data, image->m_size, releaseFn, image); + bx::memSet(image->m_data, 0, image->m_size); + + std::array textures{ + bgfx::createTexture2D(width, height, false, 1, bgfx::TextureFormat::RGBA8, BGFX_TEXTURE_RT, mem)}; + + std::array attachments{}; + for (size_t idx = 0; idx < attachments.size(); ++idx) + { + attachments[idx].init(textures[idx]); + } + TextBuffer = bgfx::createFrameBuffer(static_cast(attachments.size()), attachments.data(), true); + + FrameBuffer = new Graphics::FrameBuffer(*m_graphicsContext, TextBuffer, width, height, false, false, false); + m_available++; + mPoolBuffers.push_back({FrameBuffer, true}); + } + } + + void FrameBufferPool::Clear() + { + for (auto& buffer : mPoolBuffers) + { + if (buffer.frameBuffer) + { + buffer.frameBuffer->Dispose(); + } + } + m_available = 0; + mPoolBuffers.clear(); + } + + Graphics::FrameBuffer* FrameBufferPool::Acquire() + { + // no buffers in pool, add one + if (m_available == 0) + { + Add(1); + } + + for (auto& buffer : mPoolBuffers) + { + if (buffer.isAvailable) + { + buffer.isAvailable = false; + m_available--; + return buffer.frameBuffer; + } + } + + throw std::runtime_error("No available frame buffer in pool."); + } + + void FrameBufferPool::Release(Graphics::FrameBuffer* frameBuffer) + { + for (auto& buffer : mPoolBuffers) + { + if (buffer.frameBuffer == frameBuffer) + { + buffer.isAvailable = true; + return; + } + } + } +} diff --git a/Polyfills/Canvas/Source/FrameBufferPool.h b/Polyfills/Canvas/Source/FrameBufferPool.h new file mode 100644 index 000000000..a756c4108 --- /dev/null +++ b/Polyfills/Canvas/Source/FrameBufferPool.h @@ -0,0 +1,30 @@ +#pragma once + +#include +#include + +namespace Babylon::Polyfills +{ + class FrameBufferPool final + { + public: + struct PoolBuffer + { + Graphics::FrameBuffer* frameBuffer; + bool isAvailable; + }; + // acquire a frame buffer from the pool, graphics context must be set + Graphics::FrameBuffer* Acquire(); + void Add(int nBuffers); + void Clear(); + void Release(Graphics::FrameBuffer* frameBuffer); + // sets graphics context to be used for creating framebuffers + void SetGraphicsContext(Graphics::DeviceContext *graphicsContext); + const std::vector& GetPoolBuffers(); + + private: + std::vector mPoolBuffers{}; + Graphics::DeviceContext* m_graphicsContext; + int m_available{0}; + }; +} diff --git a/Polyfills/Canvas/Source/Shaders/dx11/fs_gaussblur.h b/Polyfills/Canvas/Source/Shaders/dx11/fs_gaussblur.h new file mode 100644 index 000000000..775e1842e --- /dev/null +++ b/Polyfills/Canvas/Source/Shaders/dx11/fs_gaussblur.h @@ -0,0 +1,103 @@ +static const uint8_t fs_gaussblur_dx11[1585] = +{ + 0x46, 0x53, 0x48, 0x0b, 0xcf, 0xda, 0x1b, 0x94, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0a, 0x75, // FSH............u + 0x5f, 0x76, 0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // _viewSize....... + 0x00, 0x00, 0x00, 0x0b, 0x75, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, // ....u_direction. + 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x30, // ..........s_tex0 + 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x30, // ..........s_tex0 + 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x05, 0x00, 0x00, 0x44, 0x58, 0x42, // .............DXB + 0x43, 0x87, 0xf0, 0xab, 0x21, 0xf5, 0x28, 0x19, 0xa5, 0xb4, 0x55, 0x62, 0xc0, 0x96, 0x43, 0xf5, // C...!.(...Ub..C. + 0xe6, 0x01, 0x00, 0x00, 0x00, 0xd0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, // .............,.. + 0x00, 0x9c, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00, 0x49, 0x53, 0x47, 0x4e, 0x68, 0x00, 0x00, // .........ISGNh.. + 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .........P...... + 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, // ................ + 0x00, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // ................ + 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // ................ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x00, // ................ + 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x54, 0x45, 0x58, // .SV_POSITION.TEX + 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab, 0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, // COORD....OSGN,.. + 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ......... ...... + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, // ................ + 0x00, 0x53, 0x56, 0x5f, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x00, 0xab, 0xab, 0x53, 0x48, 0x45, // .SV_TARGET...SHE + 0x58, 0xf8, 0x04, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x3e, 0x01, 0x00, 0x00, 0x6a, 0x08, 0x00, // X....P...>...j.. + 0x01, 0x59, 0x00, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .Y...F. ........ + 0x00, 0x5a, 0x00, 0x00, 0x03, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x18, 0x00, // .Z....`......X.. + 0x04, 0x00, 0x70, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x62, 0x10, 0x00, // ..p......UU..b.. + 0x03, 0xc2, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, // .........e.... . + 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, // .....h.......E.. + 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, // .....CU......... + 0x00, 0xe6, 0x1a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, // .........F~..... + 0x00, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x0b, 0xf2, 0x00, 0x10, // ..`............. + 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, // ......@.....?... + 0x3f, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0x3f, 0x46, 0x84, 0x20, 0x00, 0x00, 0x00, 0x00, // ?...?...?F. .... + 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, // .....2...2...... + 0x00, 0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, // .F. ............ + 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x1a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, // .............E.. + 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, // .....CU......... + 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, // .F.......F~..... + 0x00, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, // ..`......8...... + 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, // .....F........@. + 0x00, 0x00, 0x00, 0x80, 0x3e, 0x00, 0x00, 0x80, 0x3e, 0x00, 0x00, 0x80, 0x3e, 0x00, 0x00, 0x80, // ....>...>...>... + 0x3e, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, // >2...........F.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x7b, 0x14, 0xae, 0x3e, 0x7b, 0x14, 0xae, // ......@..{..>{.. + 0x3e, 0x7b, 0x14, 0xae, 0x3e, 0x7b, 0x14, 0xae, 0x3e, 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, // >{..>{..>F...... + 0x00, 0x32, 0x00, 0x00, 0x0b, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x80, 0x20, // .2...2.......F. + 0x80, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, // .A.............. + 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x1a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, // .............8.. + 0x08, 0xf2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, // .........F...... + 0x00, 0x46, 0x84, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, // .F. .........E.. + 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, // .....CU......... + 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, // .F.......F~..... + 0x00, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, // ..`......2...... + 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, // .....F........@. + 0x00, 0x00, 0x00, 0x80, 0x3e, 0x00, 0x00, 0x80, 0x3e, 0x00, 0x00, 0x80, 0x3e, 0x00, 0x00, 0x80, // ....>...>...>... + 0x3e, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, // >F.......2...2.. + 0x00, 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, // ..............@. + 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ....@...@....... + 0x00, 0xe6, 0x1a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, // .........E...... + 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, // .CU..........F.. + 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x10, // .....F~.......`. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, // .....2.......... + 0x00, 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0xb8, 0x1e, 0x05, // .F........@..... + 0x3e, 0xb8, 0x1e, 0x05, 0x3e, 0xb8, 0x1e, 0x05, 0x3e, 0xb8, 0x1e, 0x05, 0x3e, 0x46, 0x0e, 0x10, // >...>...>...>F.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0d, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, // .....2...2...... + 0x00, 0xe6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, // .....A........@. + 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ....@...@....... + 0x00, 0xe6, 0x1a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, // .........E...... + 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, // .CU..........F.. + 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x10, // .....F~.......`. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, // .....2.......... + 0x00, 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0xb8, 0x1e, 0x05, // .F........@..... + 0x3e, 0xb8, 0x1e, 0x05, 0x3e, 0xb8, 0x1e, 0x05, 0x3e, 0xb8, 0x1e, 0x05, 0x3e, 0x46, 0x0e, 0x10, // >...>...>...>F.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, // .....2.......... + 0x00, 0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x40, // .F........@....@ + 0x40, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0xe6, 0x1e, 0x10, // @..@@...@...@... + 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0d, 0xf2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, // .....2.......... + 0x00, 0x46, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, // .F...A........@. + 0x00, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, // ...@@..@@...@... + 0x40, 0xe6, 0x1e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, // @........E...... + 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, // .CU..........F.. + 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x10, // .....F~.......`. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, // .....E.......CU. + 0x00, 0xf2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, // ................ + 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, // .F~.......`..... + 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, // .2...........F.. + 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x8f, 0xc2, 0x75, 0x3d, 0x8f, 0xc2, 0x75, // ......@....u=..u + 0x3d, 0x8f, 0xc2, 0x75, 0x3d, 0x8f, 0xc2, 0x75, 0x3d, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, // =..u=..u=F...... + 0x00, 0x45, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, // .E.......CU..... + 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, // .....F.......F~. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, // ......`......E.. + 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, // .....CU......... + 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, // .........F~..... + 0x00, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, // ..`......2...... + 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, // .....F........@. + 0x00, 0x8f, 0xc2, 0x75, 0x3d, 0x8f, 0xc2, 0x75, 0x3d, 0x8f, 0xc2, 0x75, 0x3d, 0x8f, 0xc2, 0x75, // ...u=..u=..u=..u + 0x3d, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, // =F.......2...... + 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, // .....F........@. + 0x00, 0x0a, 0xd7, 0xa3, 0x3c, 0x0a, 0xd7, 0xa3, 0x3c, 0x0a, 0xd7, 0xa3, 0x3c, 0x0a, 0xd7, 0xa3, // ....<...<...<... + 0x3c, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x20, 0x10, // ..... + 0x00, // . +}; diff --git a/Polyfills/Canvas/Source/Shaders/dx11/vs_fspass.h b/Polyfills/Canvas/Source/Shaders/dx11/vs_fspass.h new file mode 100644 index 000000000..38842b67a --- /dev/null +++ b/Polyfills/Canvas/Source/Shaders/dx11/vs_fspass.h @@ -0,0 +1,34 @@ +static const uint8_t vs_fspass_dx11[494] = +{ + 0x56, 0x53, 0x48, 0x0b, 0x00, 0x00, 0x00, 0x00, 0xcf, 0xda, 0x1b, 0x94, 0x00, 0x00, 0xd4, 0x01, // VSH............. + 0x00, 0x00, 0x44, 0x58, 0x42, 0x43, 0x2d, 0x40, 0xc0, 0xce, 0x39, 0x67, 0x5a, 0x73, 0x8a, 0xa9, // ..DXBC-@..9gZs.. + 0xd5, 0x79, 0x02, 0xcf, 0x9d, 0xb2, 0x01, 0x00, 0x00, 0x00, 0xd4, 0x01, 0x00, 0x00, 0x03, 0x00, // .y.............. + 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x49, 0x53, // ..,...........IS + 0x47, 0x4e, 0x4c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x38, 0x00, // GNL...........8. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // ................ + 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ......A......... + 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x50, 0x4f, // ..............PO + 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, // SITION.TEXCOORD. + 0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x68, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, // ..OSGNh......... + 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, // ..P............. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, // ................ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x0c, // ................ + 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, // ................ + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, // ..........SV_POS + 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab, // ITION.TEXCOORD.. + 0xab, 0xab, 0x53, 0x48, 0x45, 0x58, 0xdc, 0x00, 0x00, 0x00, 0x50, 0x00, 0x01, 0x00, 0x37, 0x00, // ..SHEX....P...7. + 0x00, 0x00, 0x6a, 0x08, 0x00, 0x01, 0x5f, 0x00, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x00, 0x00, // ..j..._...2..... + 0x00, 0x00, 0x67, 0x00, 0x00, 0x04, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, // ..g.... ........ + 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0x32, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, // ..e...2 ......e. + 0x00, 0x03, 0xc2, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, 0x32, 0x20, // ... ......2...2 + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, // ......F........@ + 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ....@@..@@...... + 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, // ...@............ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x08, 0xc2, 0x20, 0x10, 0x00, 0x00, 0x00, // ......6.... .... + 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ...@............ + 0x00, 0x3f, 0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x20, 0x10, 0x00, 0x01, 0x00, // .?...?2.... .... + 0x00, 0x00, 0x46, 0x14, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, // ..F........@.... + 0x80, 0x3f, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0xc0, 0xbf, 0x02, 0x40, // .?...?...?.....@ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, // .............?.. + 0x80, 0x3f, 0x3e, 0x00, 0x00, 0x01, 0x00, 0x02, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, // .?>........... +}; diff --git a/Polyfills/Canvas/Source/Shaders/essl/fs_gaussblur.h b/Polyfills/Canvas/Source/Shaders/essl/fs_gaussblur.h new file mode 100644 index 000000000..a252e325b --- /dev/null +++ b/Polyfills/Canvas/Source/Shaders/essl/fs_gaussblur.h @@ -0,0 +1,85 @@ +static const uint8_t fs_gaussblur_essl[1301] = +{ + 0x46, 0x53, 0x48, 0x0b, 0xcf, 0xda, 0x1b, 0x94, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x0a, 0x75, // FSH............u + 0x5f, 0x76, 0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x02, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, // _viewSize....... + 0x00, 0x00, 0x00, 0x0b, 0x75, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x02, // ....u_direction. + 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x00, // ..........s_tex. + 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc7, 0x04, 0x00, 0x00, 0x76, 0x61, 0x72, // .............var + 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, // ying highp vec2 + 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x75, 0x6e, 0x69, // v_texcoord0;.uni + 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, // form highp vec4 + 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, // u_viewSize;.unif + 0x6f, 0x72, 0x6d, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x75, // orm highp vec4 u + 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, // _direction;.unif + 0x6f, 0x72, 0x6d, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x73, 0x5f, // orm sampler2D s_ + 0x74, 0x65, 0x78, 0x3b, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x20, 0x28, // tex;.void main ( + 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x32, // ).{. highp vec2 + 0x20, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, // texelSize_1;. + 0x6c, 0x6f, 0x77, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, // lowp vec4 color_ + 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x3d, 0x20, 0x28, // 2;. color_2 = ( + 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x44, 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, // texture2D (s_tex + 0x2c, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x29, 0x20, 0x2a, // , v_texcoord0) * + 0x20, 0x30, 0x2e, 0x33, 0x34, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x53, // 0.34);. texelS + 0x69, 0x7a, 0x65, 0x5f, 0x31, 0x20, 0x3d, 0x20, 0x28, 0x31, 0x2e, 0x30, 0x2f, 0x28, 0x75, 0x5f, // ize_1 = (1.0/(u_ + 0x76, 0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x2e, 0x78, 0x79, 0x29, 0x29, 0x3b, 0x0a, 0x20, // viewSize.xy));. + 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x74, 0x6d, 0x70, 0x76, // highp vec2 tmpv + 0x61, 0x72, 0x5f, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, // ar_3;. tmpvar_3 + 0x20, 0x3d, 0x20, 0x28, 0x75, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, // = (u_direction. + 0x78, 0x79, 0x20, 0x2a, 0x20, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x5f, 0x31, // xy * texelSize_1 + 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x3d, 0x20, 0x28, // );. color_2 = ( + 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x2b, 0x20, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, // color_2 + (textu + 0x72, 0x65, 0x32, 0x44, 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x28, 0x76, 0x5f, // re2D (s_tex, (v_ + 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, 0x76, // texcoord0 + tmpv + 0x61, 0x72, 0x5f, 0x33, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x32, 0x35, 0x29, 0x29, 0x3b, // ar_3)) * 0.25)); + 0x0a, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x3d, 0x20, 0x28, 0x63, 0x6f, // . color_2 = (co + 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x2b, 0x20, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, // lor_2 + (texture + 0x32, 0x44, 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x28, 0x76, 0x5f, 0x74, 0x65, // 2D (s_tex, (v_te + 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x2d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // xcoord0 - tmpvar + 0x5f, 0x33, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x32, 0x35, 0x29, 0x29, 0x3b, 0x0a, 0x20, // _3)) * 0.25));. + 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x74, 0x6d, 0x70, 0x76, // highp vec2 tmpv + 0x61, 0x72, 0x5f, 0x34, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, // ar_4;. tmpvar_4 + 0x20, 0x3d, 0x20, 0x28, 0x28, 0x75, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, // = ((u_direction + 0x2e, 0x78, 0x79, 0x20, 0x2a, 0x20, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x5f, // .xy * texelSize_ + 0x31, 0x29, 0x20, 0x2a, 0x20, 0x32, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x63, 0x6f, 0x6c, // 1) * 2.0);. col + 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x3d, 0x20, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, // or_2 = (color_2 + 0x2b, 0x20, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x44, 0x20, 0x28, 0x73, 0x5f, // + (texture2D (s_ + 0x74, 0x65, 0x78, 0x2c, 0x20, 0x28, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, // tex, (v_texcoord + 0x30, 0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x29, 0x29, 0x20, 0x2a, // 0 + tmpvar_4)) * + 0x20, 0x30, 0x2e, 0x31, 0x33, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, // 0.13));. color + 0x5f, 0x32, 0x20, 0x3d, 0x20, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x2b, 0x20, // _2 = (color_2 + + 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x44, 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, // (texture2D (s_te + 0x78, 0x2c, 0x20, 0x28, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, // x, (v_texcoord0 + 0x2d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x30, // - tmpvar_4)) * 0 + 0x2e, 0x31, 0x33, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, // .13));. highp v + 0x65, 0x63, 0x32, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x3b, 0x0a, 0x20, 0x20, // ec2 tmpvar_5;. + 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x75, 0x5f, 0x64, // tmpvar_5 = ((u_d + 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x78, 0x79, 0x20, 0x2a, 0x20, 0x74, 0x65, // irection.xy * te + 0x78, 0x65, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x5f, 0x31, 0x29, 0x20, 0x2a, 0x20, 0x33, 0x2e, 0x30, // xelSize_1) * 3.0 + 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x3d, 0x20, 0x28, // );. color_2 = ( + 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x2b, 0x20, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, // color_2 + (textu + 0x72, 0x65, 0x32, 0x44, 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x28, 0x76, 0x5f, // re2D (s_tex, (v_ + 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, 0x76, // texcoord0 + tmpv + 0x61, 0x72, 0x5f, 0x35, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x30, 0x36, 0x29, 0x29, 0x3b, // ar_5)) * 0.06)); + 0x0a, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x3d, 0x20, 0x28, 0x63, 0x6f, // . color_2 = (co + 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x2b, 0x20, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, // lor_2 + (texture + 0x32, 0x44, 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x28, 0x76, 0x5f, 0x74, 0x65, // 2D (s_tex, (v_te + 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x2d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // xcoord0 - tmpvar + 0x5f, 0x35, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x30, 0x36, 0x29, 0x29, 0x3b, 0x0a, 0x20, // _5)) * 0.06));. + 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x74, 0x6d, 0x70, 0x76, // highp vec2 tmpv + 0x61, 0x72, 0x5f, 0x36, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, // ar_6;. tmpvar_6 + 0x20, 0x3d, 0x20, 0x28, 0x28, 0x75, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, // = ((u_direction + 0x2e, 0x78, 0x79, 0x20, 0x2a, 0x20, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x5f, // .xy * texelSize_ + 0x31, 0x29, 0x20, 0x2a, 0x20, 0x34, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x63, 0x6f, 0x6c, // 1) * 4.0);. col + 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x3d, 0x20, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, // or_2 = (color_2 + 0x2b, 0x20, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x44, 0x20, 0x28, 0x73, 0x5f, // + (texture2D (s_ + 0x74, 0x65, 0x78, 0x2c, 0x20, 0x28, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, // tex, (v_texcoord + 0x30, 0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x29, 0x29, 0x20, 0x2a, // 0 + tmpvar_6)) * + 0x20, 0x30, 0x2e, 0x30, 0x32, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, // 0.02));. color + 0x5f, 0x32, 0x20, 0x3d, 0x20, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x2b, 0x20, // _2 = (color_2 + + 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x44, 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, // (texture2D (s_te + 0x78, 0x2c, 0x20, 0x28, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, // x, (v_texcoord0 + 0x2d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x30, // - tmpvar_6)) * 0 + 0x2e, 0x30, 0x32, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, // .02));. gl_Frag + 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x3b, // Color = color_2; + 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // .}... +}; diff --git a/Polyfills/Canvas/Source/Shaders/essl/vs_fspass.h b/Polyfills/Canvas/Source/Shaders/essl/vs_fspass.h new file mode 100644 index 000000000..9e5f9354e --- /dev/null +++ b/Polyfills/Canvas/Source/Shaders/essl/vs_fspass.h @@ -0,0 +1,33 @@ +static const uint8_t vs_fspass_essl[480] = +{ + 0x56, 0x53, 0x48, 0x0b, 0x00, 0x00, 0x00, 0x00, 0xcf, 0xda, 0x1b, 0x94, 0x00, 0x00, 0xcd, 0x01, // VSH............. + 0x00, 0x00, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x68, 0x69, 0x67, 0x68, // ..attribute high + 0x70, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, // p vec2 a_positio + 0x6e, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, // n;.varying highp + 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x76, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, // vec2 v_position + 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, // ;.varying highp + 0x76, 0x65, 0x63, 0x32, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, // vec2 v_texcoord0 + 0x3b, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x29, 0x0a, 0x7b, // ;.void main ().{ + 0x0a, 0x20, 0x20, 0x76, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, // . v_position = + 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x68, 0x69, // a_position;. hi + 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // ghp vec2 tmpvar_ + 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x20, 0x3d, 0x20, // 1;. tmpvar_1 = + 0x28, 0x28, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x2a, 0x20, 0x33, // ((a_position * 3 + 0x2e, 0x30, 0x29, 0x20, 0x2d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, 0x30, 0x2c, 0x20, // .0) - vec2(0.0, + 0x31, 0x2e, 0x30, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, // 1.0));. highp v + 0x65, 0x63, 0x32, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x3b, 0x0a, 0x20, 0x20, // ec2 tmpvar_2;. + 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x2e, 0x78, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, // tmpvar_2.x = tmp + 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // var_1.x;. tmpva + 0x72, 0x5f, 0x32, 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x28, 0x31, 0x2e, 0x30, 0x20, 0x2d, 0x20, 0x74, // r_2.y = (1.0 - t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x79, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x5f, // mpvar_1.y);. v_ + 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x74, 0x6d, // texcoord0 = ((tm + 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x35, 0x29, 0x20, 0x2b, 0x20, // pvar_2 * 0.5) + + 0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, 0x35, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x29, 0x29, 0x3b, // vec2(0.5, 0.0)); + 0x0a, 0x20, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, // . highp vec4 tm + 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // pvar_3;. tmpvar + 0x5f, 0x33, 0x2e, 0x7a, 0x77, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, 0x35, // _3.zw = vec2(0.5 + 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // , 1.0);. tmpvar + 0x5f, 0x33, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, // _3.xy = tmpvar_1 + 0x3b, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, // ;. gl_Position + 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // = tmpvar_3;.}... +}; diff --git a/Polyfills/Canvas/Source/Shaders/fs_gaussblur.sc b/Polyfills/Canvas/Source/Shaders/fs_gaussblur.sc new file mode 100644 index 000000000..f8823eecc --- /dev/null +++ b/Polyfills/Canvas/Source/Shaders/fs_gaussblur.sc @@ -0,0 +1,40 @@ +$input v_position, v_texcoord0 + +#include "./common.sh" + +uniform vec4 u_viewSize; // vec4 (width, height, unused, unused) +uniform vec4 u_direction; // vec4 (x, y, unused, unused) + +SAMPLER2D(s_tex, 0); + +#if NEED_HALF_TEXEL +uniform vec4 u_halfTexel; +#endif // NEED_HALF_TEXEL + +void main() +{ +#if !NEED_HALF_TEXEL + vec4 u_halfTexel = vec4_splat(0.0); +#endif // !NEED_HALF_TEXEL + + // 9-tap weights + float weights[5]; + weights[0] = 0.340; // center + weights[1] = 0.250; + weights[2] = 0.130; + weights[3] = 0.060; + weights[4] = 0.020; + + vec2 texcoord0 = v_texcoord0 + u_halfTexel.xy; + vec4 color = texture2D(s_tex, texcoord0) * weights[0]; // center pixel + vec2 texelSize = vec2_splat(1.0) / u_viewSize.xy; + + for (int i = 1; i <= 4; i++) + { + vec2 offset = u_direction.xy * texelSize * float(i); + color += texture2D(s_tex, texcoord0 + offset) * weights[i]; + color += texture2D(s_tex, texcoord0 - offset) * weights[i]; + } + + gl_FragColor = color; +} diff --git a/Polyfills/Canvas/Source/Shaders/glsl/fs_gaussblur.h b/Polyfills/Canvas/Source/Shaders/glsl/fs_gaussblur.h new file mode 100644 index 000000000..8f50c8d29 --- /dev/null +++ b/Polyfills/Canvas/Source/Shaders/glsl/fs_gaussblur.h @@ -0,0 +1,80 @@ +static const uint8_t fs_gaussblur_glsl[1225] = +{ + 0x46, 0x53, 0x48, 0x0b, 0xcf, 0xda, 0x1b, 0x94, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x0a, 0x75, // FSH............u + 0x5f, 0x76, 0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x02, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, // _viewSize....... + 0x00, 0x00, 0x00, 0x0b, 0x75, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x02, // ....u_direction. + 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x00, // ..........s_tex. + 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, 0x04, 0x00, 0x00, 0x69, 0x6e, 0x20, // .........{...in + 0x76, 0x65, 0x63, 0x32, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, // vec2 v_texcoord0 + 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x75, // ;.uniform vec4 u + 0x5f, 0x76, 0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, // _viewSize;.unifo + 0x72, 0x6d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x75, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, // rm vec4 u_direct + 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x73, 0x61, 0x6d, // ion;.uniform sam + 0x70, 0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x3b, 0x0a, 0x76, 0x6f, // pler2D s_tex;.vo + 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x76, // id main ().{. v + 0x65, 0x63, 0x32, 0x20, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x5f, 0x31, 0x3b, // ec2 texelSize_1; + 0x0a, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x3b, // . vec4 color_2; + 0x0a, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x3d, 0x20, 0x28, 0x74, 0x65, // . color_2 = (te + 0x78, 0x74, 0x75, 0x72, 0x65, 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x76, 0x5f, // xture (s_tex, v_ + 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x33, // texcoord0) * 0.3 + 0x34, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x5f, // 4);. texelSize_ + 0x31, 0x20, 0x3d, 0x20, 0x28, 0x31, 0x2e, 0x30, 0x2f, 0x28, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, // 1 = (1.0/(u_view + 0x53, 0x69, 0x7a, 0x65, 0x2e, 0x78, 0x79, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x65, 0x63, // Size.xy));. vec + 0x32, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, // 2 tmpvar_3;. tm + 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x20, 0x3d, 0x20, 0x28, 0x75, 0x5f, 0x64, 0x69, 0x72, 0x65, // pvar_3 = (u_dire + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x78, 0x79, 0x20, 0x2a, 0x20, 0x74, 0x65, 0x78, 0x65, 0x6c, // ction.xy * texel + 0x53, 0x69, 0x7a, 0x65, 0x5f, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, // Size_1);. color + 0x5f, 0x32, 0x20, 0x3d, 0x20, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x2b, 0x20, // _2 = (color_2 + + 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x2c, // (texture (s_tex, + 0x20, 0x28, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x2b, 0x20, // (v_texcoord0 + + 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x32, // tmpvar_3)) * 0.2 + 0x35, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x3d, // 5));. color_2 = + 0x20, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x2b, 0x20, 0x28, 0x74, 0x65, 0x78, // (color_2 + (tex + 0x74, 0x75, 0x72, 0x65, 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x28, 0x76, 0x5f, // ture (s_tex, (v_ + 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x2d, 0x20, 0x74, 0x6d, 0x70, 0x76, // texcoord0 - tmpv + 0x61, 0x72, 0x5f, 0x33, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x32, 0x35, 0x29, 0x29, 0x3b, // ar_3)) * 0.25)); + 0x0a, 0x20, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, // . vec2 tmpvar_4 + 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x20, 0x3d, 0x20, 0x28, // ;. tmpvar_4 = ( + 0x28, 0x75, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x78, 0x79, 0x20, // (u_direction.xy + 0x2a, 0x20, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x5f, 0x31, 0x29, 0x20, 0x2a, // * texelSize_1) * + 0x20, 0x32, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, // 2.0);. color_2 + 0x20, 0x3d, 0x20, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x2b, 0x20, 0x28, 0x74, // = (color_2 + (t + 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x28, // exture (s_tex, ( + 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x2b, 0x20, 0x74, 0x6d, // v_texcoord0 + tm + 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x31, 0x33, 0x29, // pvar_4)) * 0.13) + 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x3d, 0x20, 0x28, // );. color_2 = ( + 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x2b, 0x20, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, // color_2 + (textu + 0x72, 0x65, 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x28, 0x76, 0x5f, 0x74, 0x65, // re (s_tex, (v_te + 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x2d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // xcoord0 - tmpvar + 0x5f, 0x34, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x31, 0x33, 0x29, 0x29, 0x3b, 0x0a, 0x20, // _4)) * 0.13));. + 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x3b, 0x0a, // vec2 tmpvar_5;. + 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x75, // tmpvar_5 = ((u + 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x78, 0x79, 0x20, 0x2a, 0x20, // _direction.xy * + 0x74, 0x65, 0x78, 0x65, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x5f, 0x31, 0x29, 0x20, 0x2a, 0x20, 0x33, // texelSize_1) * 3 + 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x3d, // .0);. color_2 = + 0x20, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x2b, 0x20, 0x28, 0x74, 0x65, 0x78, // (color_2 + (tex + 0x74, 0x75, 0x72, 0x65, 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x28, 0x76, 0x5f, // ture (s_tex, (v_ + 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, 0x76, // texcoord0 + tmpv + 0x61, 0x72, 0x5f, 0x35, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x30, 0x36, 0x29, 0x29, 0x3b, // ar_5)) * 0.06)); + 0x0a, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x3d, 0x20, 0x28, 0x63, 0x6f, // . color_2 = (co + 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x2b, 0x20, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, // lor_2 + (texture + 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x28, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, // (s_tex, (v_texc + 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x2d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, // oord0 - tmpvar_5 + 0x29, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x30, 0x36, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x76, // )) * 0.06));. v + 0x65, 0x63, 0x32, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x3b, 0x0a, 0x20, 0x20, // ec2 tmpvar_6;. + 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x75, 0x5f, 0x64, // tmpvar_6 = ((u_d + 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x78, 0x79, 0x20, 0x2a, 0x20, 0x74, 0x65, // irection.xy * te + 0x78, 0x65, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x5f, 0x31, 0x29, 0x20, 0x2a, 0x20, 0x34, 0x2e, 0x30, // xelSize_1) * 4.0 + 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x3d, 0x20, 0x28, // );. color_2 = ( + 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x2b, 0x20, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, // color_2 + (textu + 0x72, 0x65, 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x28, 0x76, 0x5f, 0x74, 0x65, // re (s_tex, (v_te + 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // xcoord0 + tmpvar + 0x5f, 0x36, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x30, 0x32, 0x29, 0x29, 0x3b, 0x0a, 0x20, // _6)) * 0.02));. + 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x32, 0x20, 0x3d, 0x20, 0x28, 0x63, 0x6f, 0x6c, 0x6f, // color_2 = (colo + 0x72, 0x5f, 0x32, 0x20, 0x2b, 0x20, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x20, 0x28, // r_2 + (texture ( + 0x73, 0x5f, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x28, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, // s_tex, (v_texcoo + 0x72, 0x64, 0x30, 0x20, 0x2d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x29, 0x29, // rd0 - tmpvar_6)) + 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x30, 0x32, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, // * 0.02));. gl_ + 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x63, 0x6f, 0x6c, 0x6f, // FragColor = colo + 0x72, 0x5f, 0x32, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // r_2;.}... +}; diff --git a/Polyfills/Canvas/Source/Shaders/glsl/vs_fspass.h b/Polyfills/Canvas/Source/Shaders/glsl/vs_fspass.h new file mode 100644 index 000000000..de5b90fdb --- /dev/null +++ b/Polyfills/Canvas/Source/Shaders/glsl/vs_fspass.h @@ -0,0 +1,30 @@ +static const uint8_t vs_fspass_glsl[429] = +{ + 0x56, 0x53, 0x48, 0x0b, 0x00, 0x00, 0x00, 0x00, 0xcf, 0xda, 0x1b, 0x94, 0x00, 0x00, 0x9a, 0x01, // VSH............. + 0x00, 0x00, 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, // ..in vec2 a_posi + 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x6f, 0x75, 0x74, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x76, // tion;.out vec2 v + 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x6f, 0x75, 0x74, 0x20, 0x76, // _position;.out v + 0x65, 0x63, 0x32, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, // ec2 v_texcoord0; + 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x29, 0x0a, 0x7b, 0x0a, // .void main ().{. + 0x20, 0x20, 0x76, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x61, // v_position = a + 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x65, 0x63, // _position;. vec + 0x32, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, // 2 tmpvar_1;. tm + 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x61, 0x5f, 0x70, 0x6f, 0x73, // pvar_1 = ((a_pos + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x2a, 0x20, 0x33, 0x2e, 0x30, 0x29, 0x20, 0x2d, 0x20, 0x76, // ition * 3.0) - v + 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x29, 0x3b, 0x0a, // ec2(0.0, 1.0));. + 0x20, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x3b, // vec2 tmpvar_2; + 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x2e, 0x78, 0x20, 0x3d, 0x20, // . tmpvar_2.x = + 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, // tmpvar_1.x;. tm + 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x28, 0x31, 0x2e, 0x30, 0x20, // pvar_2.y = (1.0 + 0x2d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x79, 0x29, 0x3b, 0x0a, 0x20, // - tmpvar_1.y);. + 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x3d, 0x20, 0x28, // v_texcoord0 = ( + 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x35, 0x29, // (tmpvar_2 * 0.5) + 0x20, 0x2b, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, 0x35, 0x2c, 0x20, 0x30, 0x2e, 0x30, // + vec2(0.5, 0.0 + 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // ));. vec4 tmpva + 0x72, 0x5f, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x2e, // r_3;. tmpvar_3. + 0x7a, 0x77, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, 0x35, 0x2c, 0x20, 0x31, // zw = vec2(0.5, 1 + 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x2e, // .0);. tmpvar_3. + 0x78, 0x79, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, // xy = tmpvar_1;. + 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x74, // gl_Position = t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // mpvar_3;.}... +}; diff --git a/Polyfills/Canvas/Source/Shaders/metal/fs_gaussblur.h b/Polyfills/Canvas/Source/Shaders/metal/fs_gaussblur.h new file mode 100644 index 000000000..5a093dc61 --- /dev/null +++ b/Polyfills/Canvas/Source/Shaders/metal/fs_gaussblur.h @@ -0,0 +1,147 @@ +static const uint8_t fs_gaussblur_mtl[2298] = +{ + 0x46, 0x53, 0x48, 0x0b, 0xcf, 0xda, 0x1b, 0x94, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x0c, 0x73, // FSH............s + 0x5f, 0x74, 0x65, 0x78, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x11, 0x01, 0xff, 0xff, 0x01, // _texSampler..... + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x54, 0x65, 0x78, 0x74, 0x75, // ......s_texTextu + 0x72, 0x65, 0x11, 0x01, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x75, 0x5f, 0x76, // re...........u_v + 0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, // iewSize......... + 0x00, 0x0b, 0x75, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x01, 0x10, // ..u_direction... + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x10, 0x00, 0x00, // ........s_tex... + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, 0x08, 0x00, 0x00, 0x23, 0x70, 0x72, 0x61, 0x67, // .......{...#prag + 0x6d, 0x61, 0x20, 0x63, 0x6c, 0x61, 0x6e, 0x67, 0x20, 0x64, 0x69, 0x61, 0x67, 0x6e, 0x6f, 0x73, // ma clang diagnos + 0x74, 0x69, 0x63, 0x20, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x64, 0x20, 0x22, 0x2d, 0x57, 0x6d, // tic ignored "-Wm + 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x74, 0x79, 0x70, 0x65, // issing-prototype + 0x73, 0x22, 0x0a, 0x23, 0x70, 0x72, 0x61, 0x67, 0x6d, 0x61, 0x20, 0x63, 0x6c, 0x61, 0x6e, 0x67, // s".#pragma clang + 0x20, 0x64, 0x69, 0x61, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x20, 0x69, 0x67, 0x6e, 0x6f, // diagnostic igno + 0x72, 0x65, 0x64, 0x20, 0x22, 0x2d, 0x57, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x2d, 0x62, // red "-Wmissing-b + 0x72, 0x61, 0x63, 0x65, 0x73, 0x22, 0x0a, 0x0a, 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, // races"..#include + 0x20, 0x3c, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x3e, 0x0a, // . + 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x73, 0x69, 0x6d, 0x64, 0x2f, 0x73, // #include ..using na + 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x0a, // mespace metal;.. + 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x3c, 0x74, 0x79, 0x70, 0x65, 0x6e, 0x61, 0x6d, // template + 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x73, 0x70, 0x76, 0x55, 0x6e, 0x73, 0x61, 0x66, // .struct spvUnsaf + 0x65, 0x41, 0x72, 0x72, 0x61, 0x79, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x54, 0x20, 0x65, // eArray.{. T e + 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x5b, 0x4e, 0x75, 0x6d, 0x20, 0x3f, 0x20, 0x4e, 0x75, // lements[Num ? Nu + 0x6d, 0x20, 0x3a, 0x20, 0x31, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, // m : 1];. . + 0x20, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x20, 0x54, 0x26, 0x20, 0x6f, 0x70, 0x65, 0x72, 0x61, // thread T& opera + 0x74, 0x6f, 0x72, 0x20, 0x5b, 0x5d, 0x20, 0x28, 0x73, 0x69, 0x7a, 0x65, 0x5f, 0x74, 0x20, 0x70, // tor [] (size_t p + 0x6f, 0x73, 0x29, 0x20, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7b, // os) thread. { + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, // . return + 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x5b, 0x70, 0x6f, 0x73, 0x5d, 0x3b, 0x0a, 0x20, // elements[pos];. + 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x65, 0x78, // }. constex + 0x70, 0x72, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x20, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x20, // pr const thread + 0x54, 0x26, 0x20, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x20, 0x5b, 0x5d, 0x20, 0x28, // T& operator [] ( + 0x73, 0x69, 0x7a, 0x65, 0x5f, 0x74, 0x20, 0x70, 0x6f, 0x73, 0x29, 0x20, 0x63, 0x6f, 0x6e, 0x73, // size_t pos) cons + 0x74, 0x20, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, // t thread. {. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x65, 0x6c, // return el + 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x5b, 0x70, 0x6f, 0x73, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, // ements[pos];. + 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x65, 0x76, 0x69, // }. . devi + 0x63, 0x65, 0x20, 0x54, 0x26, 0x20, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x20, 0x5b, // ce T& operator [ + 0x5d, 0x20, 0x28, 0x73, 0x69, 0x7a, 0x65, 0x5f, 0x74, 0x20, 0x70, 0x6f, 0x73, 0x29, 0x20, 0x64, // ] (size_t pos) d + 0x65, 0x76, 0x69, 0x63, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, // evice. {. + 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x65, 0x6c, 0x65, 0x6d, 0x65, // return eleme + 0x6e, 0x74, 0x73, 0x5b, 0x70, 0x6f, 0x73, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, // nts[pos];. }. + 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x65, 0x78, 0x70, 0x72, 0x20, 0x63, 0x6f, // constexpr co + 0x6e, 0x73, 0x74, 0x20, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x20, 0x54, 0x26, 0x20, 0x6f, 0x70, // nst device T& op + 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x20, 0x5b, 0x5d, 0x20, 0x28, 0x73, 0x69, 0x7a, 0x65, 0x5f, // erator [] (size_ + 0x74, 0x20, 0x70, 0x6f, 0x73, 0x29, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x20, 0x64, 0x65, 0x76, // t pos) const dev + 0x69, 0x63, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ice. {. + 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, // return element + 0x73, 0x5b, 0x70, 0x6f, 0x73, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, // s[pos];. }. + 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x65, 0x78, 0x70, 0x72, // . constexpr + 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x20, // const constant + 0x54, 0x26, 0x20, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x20, 0x5b, 0x5d, 0x20, 0x28, // T& operator [] ( + 0x73, 0x69, 0x7a, 0x65, 0x5f, 0x74, 0x20, 0x70, 0x6f, 0x73, 0x29, 0x20, 0x63, 0x6f, 0x6e, 0x73, // size_t pos) cons + 0x74, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7b, // t constant. { + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, // . return + 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x5b, 0x70, 0x6f, 0x73, 0x5d, 0x3b, 0x0a, 0x20, // elements[pos];. + 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x68, // }. . th + 0x72, 0x65, 0x61, 0x64, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x20, 0x54, 0x26, 0x20, 0x6f, 0x70, 0x65, // readgroup T& ope + 0x72, 0x61, 0x74, 0x6f, 0x72, 0x20, 0x5b, 0x5d, 0x20, 0x28, 0x73, 0x69, 0x7a, 0x65, 0x5f, 0x74, // rator [] (size_t + 0x20, 0x70, 0x6f, 0x73, 0x29, 0x20, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x67, 0x72, 0x6f, 0x75, // pos) threadgrou + 0x70, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // p. {. + 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x5b, // return elements[ + 0x70, 0x6f, 0x73, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, // pos];. }. + 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x65, 0x78, 0x70, 0x72, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x20, // constexpr const + 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x20, 0x54, 0x26, 0x20, 0x6f, // threadgroup T& o + 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x20, 0x5b, 0x5d, 0x20, 0x28, 0x73, 0x69, 0x7a, 0x65, // perator [] (size + 0x5f, 0x74, 0x20, 0x70, 0x6f, 0x73, 0x29, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x20, 0x74, 0x68, // _t pos) const th + 0x72, 0x65, 0x61, 0x64, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, // readgroup. {. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x65, // return e + 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x5b, 0x70, 0x6f, 0x73, 0x5d, 0x3b, 0x0a, 0x20, 0x20, // lements[pos];. + 0x20, 0x20, 0x7d, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x5f, // }.};..struct _ + 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, // Global.{. flo + 0x61, 0x74, 0x34, 0x20, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x3b, 0x0a, // at4 u_viewSize;. + 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x75, 0x5f, 0x64, 0x69, 0x72, // float4 u_dir + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, // ection;.};..stru + 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x5f, 0x6f, // ct xlatMtlMain_o + 0x75, 0x74, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, // ut.{. float4 + 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x30, 0x20, 0x5b, // bgfx_FragData0 [ + 0x5b, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, // [color(0)]];.};. + 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x4d, // .struct xlatMtlM + 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, // ain_in.{. flo + 0x61, 0x74, 0x32, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, // at2 v_texcoord0 + 0x5b, 0x5b, 0x75, 0x73, 0x65, 0x72, 0x28, 0x6c, 0x6f, 0x63, 0x6e, 0x31, 0x29, 0x5d, 0x5d, 0x3b, // [[user(locn1)]]; + 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x78, 0x6c, // .};..fragment xl + 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x78, 0x6c, // atMtlMain_out xl + 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x28, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, // atMtlMain(xlatMt + 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x20, 0x69, 0x6e, 0x20, 0x5b, 0x5b, 0x73, 0x74, // lMain_in in [[st + 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, // age_in]], consta + 0x6e, 0x74, 0x20, 0x5f, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x26, 0x20, 0x5f, 0x6d, 0x74, 0x6c, // nt _Global& _mtl + 0x5f, 0x75, 0x20, 0x5b, 0x5b, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, // _u [[buffer(0)]] + 0x2c, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x64, 0x3c, 0x66, 0x6c, 0x6f, 0x61, // , texture2d s_tex [[textu + 0x72, 0x65, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, // re(0)]], sampler + 0x20, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x20, 0x5b, 0x5b, // s_texSampler [[ + 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, // sampler(0)]]).{. + 0x20, 0x20, 0x20, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x5f, // xlatMtlMain_ + 0x6f, 0x75, 0x74, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x3b, 0x0a, 0x20, 0x20, // out out = {};. + 0x20, 0x20, 0x73, 0x70, 0x76, 0x55, 0x6e, 0x73, 0x61, 0x66, 0x65, 0x41, 0x72, 0x72, 0x61, 0x79, // spvUnsafeArray + 0x3c, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x2c, 0x20, 0x35, 0x3e, 0x20, 0x5f, 0x32, 0x31, 0x33, 0x3b, // _213; + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x32, 0x31, 0x33, 0x5b, 0x30, 0x5d, 0x20, 0x3d, 0x20, 0x30, // . _213[0] = 0 + 0x2e, 0x33, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x35, 0x37, 0x36, 0x32, 0x37, 0x38, // .340000003576278 + 0x36, 0x38, 0x36, 0x35, 0x32, 0x33, 0x34, 0x33, 0x37, 0x35, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, // 6865234375;. + 0x5f, 0x32, 0x31, 0x33, 0x5b, 0x31, 0x5d, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x32, 0x35, 0x3b, 0x0a, // _213[1] = 0.25;. + 0x20, 0x20, 0x20, 0x20, 0x5f, 0x32, 0x31, 0x33, 0x5b, 0x32, 0x5d, 0x20, 0x3d, 0x20, 0x30, 0x2e, // _213[2] = 0. + 0x31, 0x32, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x35, 0x32, 0x33, 0x31, 0x36, 0x32, 0x38, 0x34, // 1299999952316284 + 0x31, 0x37, 0x39, 0x36, 0x38, 0x37, 0x35, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x32, 0x31, // 1796875;. _21 + 0x33, 0x5b, 0x33, 0x5d, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x30, 0x35, 0x39, 0x39, 0x39, 0x39, 0x39, // 3[3] = 0.0599999 + 0x39, 0x38, 0x36, 0x35, 0x38, 0x38, 0x39, 0x35, 0x34, 0x39, 0x32, 0x35, 0x35, 0x33, 0x37, 0x31, // 9865889549255371 + 0x30, 0x39, 0x33, 0x37, 0x35, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x32, 0x31, 0x33, 0x5b, // 09375;. _213[ + 0x34, 0x5d, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x30, 0x31, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, // 4] = 0.019999999 + 0x35, 0x35, 0x32, 0x39, 0x36, 0x35, 0x31, 0x36, 0x34, 0x31, 0x38, 0x34, 0x35, 0x37, 0x30, 0x33, // 5529651641845703 + 0x31, 0x32, 0x35, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, // 125;. float2 + 0x5f, 0x32, 0x34, 0x38, 0x20, 0x3d, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x28, 0x31, 0x2e, // _248 = float2(1. + 0x30, 0x29, 0x20, 0x2f, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x2e, 0x75, 0x5f, 0x76, 0x69, // 0) / _mtl_u.u_vi + 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x2e, 0x78, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, // ewSize.xy;. f + 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x5f, 0x33, 0x34, 0x34, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, // loat4 _344;. + 0x5f, 0x33, 0x34, 0x34, 0x20, 0x3d, 0x20, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x2e, 0x73, 0x61, 0x6d, // _344 = s_tex.sam + 0x70, 0x6c, 0x65, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, // ple(s_texSampler + 0x2c, 0x20, 0x69, 0x6e, 0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, // , in.v_texcoord0 + 0x29, 0x20, 0x2a, 0x20, 0x5f, 0x32, 0x31, 0x33, 0x5b, 0x30, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, // ) * _213[0];. + 0x20, 0x66, 0x6f, 0x72, 0x20, 0x28, 0x69, 0x6e, 0x74, 0x20, 0x5f, 0x33, 0x34, 0x33, 0x20, 0x3d, // for (int _343 = + 0x20, 0x31, 0x3b, 0x20, 0x5f, 0x33, 0x34, 0x33, 0x20, 0x3c, 0x3d, 0x20, 0x34, 0x3b, 0x20, 0x29, // 1; _343 <= 4; ) + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, // . {. f + 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x5f, 0x32, 0x36, 0x31, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x6d, // loat2 _261 = (_m + 0x74, 0x6c, 0x5f, 0x75, 0x2e, 0x75, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, // tl_u.u_direction + 0x2e, 0x78, 0x79, 0x20, 0x2a, 0x20, 0x5f, 0x32, 0x34, 0x38, 0x29, 0x20, 0x2a, 0x20, 0x66, 0x6c, // .xy * _248) * fl + 0x6f, 0x61, 0x74, 0x28, 0x5f, 0x33, 0x34, 0x33, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, // oat(_343);. + 0x20, 0x20, 0x20, 0x5f, 0x33, 0x34, 0x34, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x33, 0x34, 0x34, 0x20, // _344 = (_344 + 0x2b, 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, // + (s_tex.sample( + 0x73, 0x5f, 0x74, 0x65, 0x78, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x2c, 0x20, 0x28, 0x69, // s_texSampler, (i + 0x6e, 0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x2b, 0x20, // n.v_texcoord0 + + 0x5f, 0x32, 0x36, 0x31, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x5f, 0x32, 0x31, 0x33, 0x5b, 0x5f, 0x33, // _261)) * _213[_3 + 0x34, 0x33, 0x5d, 0x29, 0x29, 0x20, 0x2b, 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x2e, 0x73, // 43])) + (s_tex.s + 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x53, 0x61, 0x6d, 0x70, 0x6c, // ample(s_texSampl + 0x65, 0x72, 0x2c, 0x20, 0x28, 0x69, 0x6e, 0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, // er, (in.v_texcoo + 0x72, 0x64, 0x30, 0x20, 0x2d, 0x20, 0x5f, 0x32, 0x36, 0x31, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x5f, // rd0 - _261)) * _ + 0x32, 0x31, 0x33, 0x5b, 0x5f, 0x33, 0x34, 0x33, 0x5d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, // 213[_343]);. + 0x20, 0x20, 0x20, 0x20, 0x5f, 0x33, 0x34, 0x33, 0x2b, 0x2b, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, // _343++;. + 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75, 0x65, 0x3b, 0x0a, 0x20, 0x20, // continue;. + 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x62, 0x67, 0x66, 0x78, // }. out.bgfx + 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x30, 0x20, 0x3d, 0x20, 0x5f, 0x33, 0x34, // _FragData0 = _34 + 0x34, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x75, // 4;. return ou + 0x74, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, 0x00, 0x40, 0x00, // t;.}....@. +}; diff --git a/Polyfills/Canvas/Source/Shaders/metal/vs_fspass.h b/Polyfills/Canvas/Source/Shaders/metal/vs_fspass.h new file mode 100644 index 000000000..0e2a624a7 --- /dev/null +++ b/Polyfills/Canvas/Source/Shaders/metal/vs_fspass.h @@ -0,0 +1,52 @@ +static const uint8_t vs_fspass_mtl[770] = +{ + 0x56, 0x53, 0x48, 0x0b, 0x00, 0x00, 0x00, 0x00, 0xcf, 0xda, 0x1b, 0x94, 0x00, 0x00, 0xe8, 0x02, // VSH............. + 0x00, 0x00, 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x6d, 0x65, 0x74, 0x61, // ..#include .#inclu + 0x64, 0x65, 0x20, 0x3c, 0x73, 0x69, 0x6d, 0x64, 0x2f, 0x73, 0x69, 0x6d, 0x64, 0x2e, 0x68, 0x3e, // de + 0x0a, 0x0a, 0x75, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, // ..using namespac + 0x65, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, // e metal;..struct + 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x5f, 0x6f, 0x75, 0x74, // xlatMtlMain_out + 0x0a, 0x7b, 0x0a, 0x09, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x6d, // .{..float bgfx_m + 0x65, 0x74, 0x61, 0x6c, 0x5f, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x53, 0x69, 0x7a, 0x65, 0x20, 0x5b, // etal_pointSize [ + 0x5b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x5d, 0x5d, 0x20, 0x3d, 0x20, // [point_size]] = + 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x5f, 0x65, // 1;. float2 _e + 0x6e, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x5f, // ntryPointOutput_ + 0x76, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x75, 0x73, 0x65, // v_position [[use + 0x72, 0x28, 0x6c, 0x6f, 0x63, 0x6e, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, // r(locn0)]];. + 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x5f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x69, // float2 _entryPoi + 0x6e, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x5f, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, // ntOutput_v_texco + 0x6f, 0x72, 0x64, 0x30, 0x20, 0x5b, 0x5b, 0x75, 0x73, 0x65, 0x72, 0x28, 0x6c, 0x6f, 0x63, 0x6e, // ord0 [[user(locn + 0x31, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, // 1)]];. float4 + 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x70, // gl_Position [[p + 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, // osition]];.};..s + 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x4d, 0x61, 0x69, // truct xlatMtlMai + 0x6e, 0x5f, 0x69, 0x6e, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, // n_in.{. float + 0x32, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x61, // 2 a_position [[a + 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, // ttribute(0)]];.} + 0x3b, 0x0a, 0x0a, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, // ;..vertex xlatMt + 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, // lMain_out xlatMt + 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x28, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x4d, 0x61, 0x69, // lMain(xlatMtlMai + 0x6e, 0x5f, 0x69, 0x6e, 0x20, 0x69, 0x6e, 0x20, 0x5b, 0x5b, 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, // n_in in [[stage_ + 0x69, 0x6e, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x78, 0x6c, 0x61, 0x74, // in]]).{. xlat + 0x4d, 0x74, 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6f, 0x75, 0x74, 0x20, // MtlMain_out out + 0x3d, 0x20, 0x7b, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, // = {};. float2 + 0x20, 0x5f, 0x31, 0x31, 0x33, 0x20, 0x3d, 0x20, 0x28, 0x69, 0x6e, 0x2e, 0x61, 0x5f, 0x70, 0x6f, // _113 = (in.a_po + 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x2a, 0x20, 0x33, 0x2e, 0x30, 0x29, 0x20, 0x2d, 0x20, // sition * 3.0) - + 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x28, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, // float2(0.0, 1.0) + 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, // ;. out.gl_Pos + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x28, 0x5f, // ition = float4(_ + 0x31, 0x31, 0x33, 0x2c, 0x20, 0x30, 0x2e, 0x35, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a, // 113, 0.5, 1.0);. + 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x5f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x50, 0x6f, // out._entryPo + 0x69, 0x6e, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x5f, 0x76, 0x5f, 0x70, 0x6f, 0x73, 0x69, // intOutput_v_posi + 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x2e, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, // tion = in.a_posi + 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x5f, 0x65, // tion;. out._e + 0x6e, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x5f, // ntryPointOutput_ + 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x3d, 0x20, 0x28, 0x66, // v_texcoord0 = (f + 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x28, 0x5f, 0x31, 0x31, 0x33, 0x2e, 0x78, 0x2c, 0x20, 0x31, 0x2e, // loat2(_113.x, 1. + 0x30, 0x20, 0x2d, 0x20, 0x5f, 0x31, 0x31, 0x33, 0x2e, 0x79, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, // 0 - _113.y) * 0. + 0x35, 0x29, 0x20, 0x2b, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x28, 0x30, 0x2e, 0x35, 0x2c, // 5) + float2(0.5, + 0x20, 0x30, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, // 0.0);. retur + 0x6e, 0x20, 0x6f, 0x75, 0x74, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, 0x02, 0x01, 0x00, 0x10, 0x00, // n out;.}........ + 0x00, 0x00, // .. +}; diff --git a/Polyfills/Canvas/Source/Shaders/spirv/fs_gaussblur.h b/Polyfills/Canvas/Source/Shaders/spirv/fs_gaussblur.h new file mode 100644 index 000000000..e5e80ee49 --- /dev/null +++ b/Polyfills/Canvas/Source/Shaders/spirv/fs_gaussblur.h @@ -0,0 +1,141 @@ +static const uint8_t fs_gaussblur_spv[2193] = +{ + 0x46, 0x53, 0x48, 0x0b, 0xcf, 0xda, 0x1b, 0x94, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x0a, 0x75, // FSH............u + 0x5f, 0x76, 0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, // _viewSize....... + 0x00, 0x00, 0x00, 0x0b, 0x75, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, // ....u_direction. + 0x01, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x30, // ..........s_tex0 + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x22, 0x00, 0x40, 0x08, 0x00, 0x00, 0x03, 0x02, 0x23, // .......".@.....# + 0x07, 0x00, 0x00, 0x01, 0x00, 0x0b, 0x00, 0x08, 0x00, 0x59, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // .........Y...... + 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, // ................ + 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, // .GLSL.std.450... + 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x07, // ................ + 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, // .........main... + 0x00, 0xb0, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, // ................ + 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0xf4, 0x01, 0x00, // ................ + 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, // .........main... + 0x00, 0x05, 0x00, 0x06, 0x00, 0x27, 0x00, 0x00, 0x00, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x53, 0x61, // .....'...s_texSa + 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x2a, 0x00, 0x00, // mpler........*.. + 0x00, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x00, 0x00, // .s_texTexture... + 0x00, 0x05, 0x00, 0x06, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, // .....o...Uniform + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x6f, 0x00, 0x00, // Block........o.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x00, // .....u_viewSize. + 0x00, 0x06, 0x00, 0x06, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x64, // .....o.......u_d + 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x05, 0x00, 0x03, 0x00, 0x71, 0x00, 0x00, // irection.....q.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x76, 0x5f, 0x74, // .............v_t + 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x00, 0x05, 0x00, 0x06, 0x00, 0xbd, 0x00, 0x00, // excoord0........ + 0x00, 0x62, 0x67, 0x66, 0x78, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x44, 0x61, 0x74, 0x61, 0x30, 0x00, // .bgfx_FragData0. + 0x00, 0x47, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, // .G...'...!...... + 0x00, 0x47, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .G...'..."...... + 0x00, 0x47, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // .G...*...!...... + 0x00, 0x47, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .G...*..."...... + 0x00, 0x47, 0x00, 0x03, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, // .G...o.......H.. + 0x00, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .o.......#...... + 0x00, 0x48, 0x00, 0x05, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, // .H...o.......#.. + 0x00, 0x10, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x71, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, // .....G...q...!.. + 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x71, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, // .....G...q...".. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G.......... + 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0xbd, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, // .....G.......... + 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, // .............!.. + 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x02, 0x00, 0x06, 0x00, 0x00, // ................ + 0x00, 0x16, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x19, 0x00, 0x09, // ......... ...... + 0x00, 0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................ + 0x00, 0x17, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // ................ + 0x00, 0x17, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // ................ + 0x00, 0x20, 0x00, 0x04, 0x00, 0x13, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, // . .............. + 0x00, 0x20, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, // . ...&.......... + 0x00, 0x3b, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .;...&...'...... + 0x00, 0x20, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // . ...).......... + 0x00, 0x3b, 0x00, 0x04, 0x00, 0x29, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .;...)...*...... + 0x00, 0x15, 0x00, 0x04, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .....-... ...... + 0x00, 0x2b, 0x00, 0x04, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .+...-.......... + 0x00, 0x2b, 0x00, 0x04, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .+...-...2...... + 0x00, 0x1b, 0x00, 0x03, 0x00, 0x36, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, // .....6.......... + 0x00, 0x4b, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .K... .......+.. + 0x00, 0x4b, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, // .K...L.......... + 0x00, 0x4d, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // .M.......L... .. + 0x00, 0x4e, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .N.......M...+.. + 0x00, 0x07, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x7b, 0x14, 0xae, 0x3e, 0x2b, 0x00, 0x04, // .....P...{..>+.. + 0x00, 0x07, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3e, 0x2b, 0x00, 0x04, // .....R......>+.. + 0x00, 0x2d, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .-...T.......+.. + 0x00, 0x07, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, 0xb8, 0x1e, 0x05, 0x3e, 0x2b, 0x00, 0x04, // .....U......>+.. + 0x00, 0x2d, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .-...W.......+.. + 0x00, 0x07, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x8f, 0xc2, 0x75, 0x3d, 0x2b, 0x00, 0x04, // .....X.....u=+.. + 0x00, 0x2d, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, // .-...Z.......+.. + 0x00, 0x07, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x0a, 0xd7, 0xa3, 0x3c, 0x2b, 0x00, 0x04, // .....[......<+.. + 0x00, 0x07, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x1e, 0x00, 0x04, // .....l......?... + 0x00, 0x6f, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // .o........... .. + 0x00, 0x70, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, // .p.......o...;.. + 0x00, 0x70, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // .p...q....... .. + 0x00, 0x72, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x14, 0x00, 0x02, // .r.............. + 0x00, 0x7f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0xac, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // ..... .......... + 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0xac, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, // .....;.......... + 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0xbc, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // ..... .......... + 0x00, 0x0d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0xbc, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, // .....;.......... + 0x00, 0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x56, 0x01, 0x00, // .....,.......V.. + 0x00, 0x6c, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, // .l...l...6...... + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, // ................ + 0x00, 0x05, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4e, 0x00, 0x00, 0x00, 0xd5, 0x00, 0x00, // .....;...N...... + 0x00, 0x07, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, // .....=.......(.. + 0x00, 0x27, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, // .'...=.......+.. + 0x00, 0x2a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xb1, 0x00, 0x00, // .*...=.......... + 0x00, 0xb0, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x13, 0x00, 0x00, 0x00, 0xe5, 0x00, 0x00, // .....A.......... + 0x00, 0xd5, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0xe5, 0x00, 0x00, // .....2...>...... + 0x00, 0x50, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x13, 0x00, 0x00, 0x00, 0xe6, 0x00, 0x00, // .P...A.......... + 0x00, 0xd5, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0xe6, 0x00, 0x00, // .........>...... + 0x00, 0x52, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x13, 0x00, 0x00, 0x00, 0xe7, 0x00, 0x00, // .R...A.......... + 0x00, 0xd5, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0xe7, 0x00, 0x00, // .....T...>...... + 0x00, 0x55, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x13, 0x00, 0x00, 0x00, 0xe8, 0x00, 0x00, // .U...A.......... + 0x00, 0xd5, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0xe8, 0x00, 0x00, // .....W...>...... + 0x00, 0x58, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x13, 0x00, 0x00, 0x00, 0xe9, 0x00, 0x00, // .X...A.......... + 0x00, 0xd5, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0xe9, 0x00, 0x00, // .....Z...>...... + 0x00, 0x5b, 0x00, 0x00, 0x00, 0x56, 0x00, 0x05, 0x00, 0x36, 0x00, 0x00, 0x00, 0x2f, 0x01, 0x00, // .[...V...6.../.. + 0x00, 0x2b, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x57, 0x00, 0x05, 0x00, 0x0d, 0x00, 0x00, // .+...(...W...... + 0x00, 0x31, 0x01, 0x00, 0x00, 0x2f, 0x01, 0x00, 0x00, 0xb1, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, // .1.../.......A.. + 0x00, 0x13, 0x00, 0x00, 0x00, 0xf1, 0x00, 0x00, 0x00, 0xd5, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, // .............2.. + 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0xf2, 0x00, 0x00, 0x00, 0xf1, 0x00, 0x00, // .=.............. + 0x00, 0x8e, 0x00, 0x05, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xf3, 0x00, 0x00, 0x00, 0x31, 0x01, 0x00, // .............1.. + 0x00, 0xf2, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x72, 0x00, 0x00, 0x00, 0xf5, 0x00, 0x00, // .....A...r...... + 0x00, 0x71, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, // .q...2...=...... + 0x00, 0xf6, 0x00, 0x00, 0x00, 0xf5, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x07, 0x00, 0x0b, 0x00, 0x00, // .........O...... + 0x00, 0xf7, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................ + 0x00, 0x01, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, // ................ + 0x00, 0x56, 0x01, 0x00, 0x00, 0xf7, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x02, 0x00, 0xf9, 0x00, 0x00, // .V.............. + 0x00, 0xf8, 0x00, 0x02, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf5, 0x00, 0x07, 0x00, 0x0d, 0x00, 0x00, // ................ + 0x00, 0x58, 0x01, 0x00, 0x00, 0xf3, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x1b, 0x01, 0x00, // .X.............. + 0x00, 0xfd, 0x00, 0x00, 0x00, 0xf5, 0x00, 0x07, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x57, 0x01, 0x00, // .........-...W.. + 0x00, 0x2e, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x1e, 0x01, 0x00, 0x00, 0xfd, 0x00, 0x00, // ................ + 0x00, 0xb3, 0x00, 0x05, 0x00, 0x7f, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x57, 0x01, 0x00, // .............W.. + 0x00, 0x5a, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x04, 0x00, 0x1f, 0x01, 0x00, 0x00, 0xfd, 0x00, 0x00, // .Z.............. + 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x04, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x00, // ................ + 0x00, 0x1f, 0x01, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0xfd, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, // .............A.. + 0x00, 0x72, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, // .r.......q...... + 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, // .=.............. + 0x00, 0x4f, 0x00, 0x07, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xff, 0x00, 0x00, // .O.............. + 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, // ................ + 0x00, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xf8, 0x00, 0x00, // ................ + 0x00, 0x6f, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0x57, 0x01, 0x00, // .o...........W.. + 0x00, 0x8e, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x05, 0x01, 0x00, 0x00, 0x02, 0x01, 0x00, // ................ + 0x00, 0x04, 0x01, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x08, 0x01, 0x00, // ................ + 0x00, 0xb1, 0x00, 0x00, 0x00, 0x05, 0x01, 0x00, 0x00, 0x56, 0x00, 0x05, 0x00, 0x36, 0x00, 0x00, // .........V...6.. + 0x00, 0x3c, 0x01, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x57, 0x00, 0x05, // .<...+...(...W.. + 0x00, 0x0d, 0x00, 0x00, 0x00, 0x3e, 0x01, 0x00, 0x00, 0x3c, 0x01, 0x00, 0x00, 0x08, 0x01, 0x00, // .....>...<...... + 0x00, 0x41, 0x00, 0x05, 0x00, 0x13, 0x00, 0x00, 0x00, 0x0c, 0x01, 0x00, 0x00, 0xd5, 0x00, 0x00, // .A.............. + 0x00, 0x57, 0x01, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0d, 0x01, 0x00, // .W...=.......... + 0x00, 0x0c, 0x01, 0x00, 0x00, 0x8e, 0x00, 0x05, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x0e, 0x01, 0x00, // ................ + 0x00, 0x3e, 0x01, 0x00, 0x00, 0x0d, 0x01, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x0d, 0x00, 0x00, // .>.............. + 0x00, 0x10, 0x01, 0x00, 0x00, 0x58, 0x01, 0x00, 0x00, 0x0e, 0x01, 0x00, 0x00, 0x83, 0x00, 0x05, // .....X.......... + 0x00, 0x0b, 0x00, 0x00, 0x00, 0x13, 0x01, 0x00, 0x00, 0xb1, 0x00, 0x00, 0x00, 0x05, 0x01, 0x00, // ................ + 0x00, 0x56, 0x00, 0x05, 0x00, 0x36, 0x00, 0x00, 0x00, 0x45, 0x01, 0x00, 0x00, 0x2b, 0x00, 0x00, // .V...6...E...+.. + 0x00, 0x28, 0x00, 0x00, 0x00, 0x57, 0x00, 0x05, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x47, 0x01, 0x00, // .(...W.......G.. + 0x00, 0x45, 0x01, 0x00, 0x00, 0x13, 0x01, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x13, 0x00, 0x00, // .E.......A...... + 0x00, 0x17, 0x01, 0x00, 0x00, 0xd5, 0x00, 0x00, 0x00, 0x57, 0x01, 0x00, 0x00, 0x3d, 0x00, 0x04, // .........W...=.. + 0x00, 0x07, 0x00, 0x00, 0x00, 0x18, 0x01, 0x00, 0x00, 0x17, 0x01, 0x00, 0x00, 0x8e, 0x00, 0x05, // ................ + 0x00, 0x0d, 0x00, 0x00, 0x00, 0x19, 0x01, 0x00, 0x00, 0x47, 0x01, 0x00, 0x00, 0x18, 0x01, 0x00, // .........G...... + 0x00, 0x81, 0x00, 0x05, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x1b, 0x01, 0x00, 0x00, 0x10, 0x01, 0x00, // ................ + 0x00, 0x19, 0x01, 0x00, 0x00, 0x80, 0x00, 0x05, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x1e, 0x01, 0x00, // .........-...... + 0x00, 0x57, 0x01, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x02, 0x00, 0xf9, 0x00, 0x00, // .W.............. + 0x00, 0xf8, 0x00, 0x02, 0x00, 0x1f, 0x01, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0xbd, 0x00, 0x00, // .........>...... + 0x00, 0x58, 0x01, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, // .X.......8..... + 0x00, // . +}; diff --git a/Polyfills/Canvas/Source/Shaders/spirv/vs_fspass.h b/Polyfills/Canvas/Source/Shaders/spirv/vs_fspass.h new file mode 100644 index 000000000..ced9913fe --- /dev/null +++ b/Polyfills/Canvas/Source/Shaders/spirv/vs_fspass.h @@ -0,0 +1,63 @@ +static const uint8_t vs_fspass_spv[954] = +{ + 0x56, 0x53, 0x48, 0x0b, 0x00, 0x00, 0x00, 0x00, 0xcf, 0xda, 0x1b, 0x94, 0x00, 0x00, 0xa0, 0x03, // VSH............. + 0x00, 0x00, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x0b, 0x00, 0x08, 0x00, 0x82, 0x00, // ....#........... + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, // ................ + 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, // ......GLSL.std.4 + 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, // 50.............. + 0x00, 0x00, 0x0f, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, // ..............ma + 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x4d, 0x00, // in....=...I...M. + 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0xf4, 0x01, // ..P............. + 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, // ..........main.. + 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, // ......=...a_posi + 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x49, 0x00, 0x00, 0x00, 0x40, 0x65, // tion......I...@e + 0x6e, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, // ntryPointOutput. + 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x05, 0x00, // gl_Position..... + 0x0a, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x40, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x69, 0x6e, // ..M...@entryPoin + 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x76, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, // tOutput.v_positi + 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x50, 0x00, 0x00, 0x00, 0x40, 0x65, // on........P...@e + 0x6e, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, // ntryPointOutput. + 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x00, 0x00, 0x00, 0x47, 0x00, // v_texcoord0...G. + 0x04, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, // ..=...........G. + 0x04, 0x00, 0x49, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, // ..I...........G. + 0x04, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, // ..M...........G. + 0x04, 0x00, 0x50, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x13, 0x00, // ..P............. + 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, // ......!......... + 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, // .......... ..... + 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x17, 0x00, // ................ + 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x2b, 0x00, // ..............+. + 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, // ..............+. + 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x2b, 0x00, // ............@@+. + 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x2c, 0x00, // .............?,. + 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x1f, 0x00, // ...... ......... + 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, // ..+.......,..... + 0x00, 0x3f, 0x2c, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x2c, 0x00, // .?,...........,. + 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x01, 0x00, // ...... ...<..... + 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x3d, 0x00, // ......;...<...=. + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, 0x00, 0x03, 0x00, // ...... ...H..... + 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, 0x00, 0x49, 0x00, // ......;...H...I. + 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x03, 0x00, // ...... ...L..... + 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x4d, 0x00, // ......;...L...M. + 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x50, 0x00, // ......;...L...P. + 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, // ......6......... + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, // ................ + 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x3d, 0x00, // ..=.......>...=. + 0x00, 0x00, 0x8e, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x3e, 0x00, // ..........s...>. + 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x74, 0x00, // ..............t. + 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, // ..s... ...Q..... + 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, // ..v...t.......Q. + 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x01, 0x00, // ......x...t..... + 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, 0x1f, 0x00, // ..........y..... + 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x50, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x7a, 0x00, // ..x...P.......z. + 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x05, 0x00, 0x07, 0x00, // ..v...y......... + 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x81, 0x00, // ..{...z...,..... + 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x2e, 0x00, // ......|...{..... + 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x74, 0x00, // ..Q...........t. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x80, 0x00, // ......Q......... + 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, 0x09, 0x00, // ..t.......P..... + 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x2c, 0x00, // ..............,. + 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x49, 0x00, 0x00, 0x00, 0x81, 0x00, // ......>...I..... + 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x3e, 0x00, // ..>...M...>...>. + 0x03, 0x00, 0x50, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, // ..P...|.......8. + 0x01, 0x00, 0x00, 0x02, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, // .......... +}; diff --git a/Polyfills/Canvas/Source/Shaders/vs_fspass.sc b/Polyfills/Canvas/Source/Shaders/vs_fspass.sc new file mode 100644 index 000000000..751312665 --- /dev/null +++ b/Polyfills/Canvas/Source/Shaders/vs_fspass.sc @@ -0,0 +1,24 @@ +$input a_position, a_texcoord0 +$output v_position, v_texcoord0 + +#include "./common.sh" + +#define NEED_HALF_TEXEL (BGFX_SHADER_LANGUAGE_HLSL < 400) + +uniform vec4 u_viewSize; + +#if NEED_HALF_TEXEL +uniform vec4 u_halfTexel; +#endif // NEED_HALF_TEXEL + +void main() +{ +#if !NEED_HALF_TEXEL + const vec4 u_halfTexel = vec4_splat(0.0); +#endif // !NEED_HALF_TEXEL + + v_position = a_position; + vec2 uv = a_position.xy*3. - vec2(0.,1); + v_texcoord0 = vec2(uv.x, 1.-uv.y) * 0.5 + vec2(0.5,0.); + gl_Position = vec4(uv, 0.5, 1.0); +} diff --git a/Polyfills/Canvas/Source/nanovg/nanovg.cpp b/Polyfills/Canvas/Source/nanovg/nanovg.cpp index 67c0cfa52..4baf6d80a 100644 --- a/Polyfills/Canvas/Source/nanovg/nanovg.cpp +++ b/Polyfills/Canvas/Source/nanovg/nanovg.cpp @@ -24,6 +24,7 @@ #include "nanovg.h" #include +#include "nanovg_filterstack.h" BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4701) // error C4701: potentially uninitialized local variable 'cint' used // -Wunused-function and 4505 must be file scope, can't be disabled between push/pop. @@ -94,6 +95,7 @@ struct NVGstate { float fontBlur; int textAlign; int fontId; + nanovg_filterstack m_filterStack; }; typedef struct NVGstate NVGstate; @@ -674,6 +676,7 @@ void nvgReset(NVGcontext* ctx) state->fontBlur = 0.0f; state->textAlign = NVG_ALIGN_LEFT | NVG_ALIGN_BASELINE; state->fontId = 0; + state->m_filterStack.Clear(); } // State setting @@ -792,6 +795,13 @@ void nvgFillColor(NVGcontext* ctx, NVGcolor color) nvg__setPaintColor(&state->fill, color); } +// should be set before a draw (eg. stroke, fill). a copy of filter stack is attached to the draw call for drawing filters +void nvgFilterStack(NVGcontext* ctx, nanovg_filterstack& filterStack) +{ + NVGstate* state = nvg__getState(ctx); + state->m_filterStack = filterStack; +} + void nvgFillPaint(NVGcontext* ctx, NVGpaint paint) { NVGstate* state = nvg__getState(ctx); @@ -2218,7 +2228,7 @@ void nvgFill(NVGcontext* ctx) fillPaint.image2 = 0; ctx->params.renderFill(ctx->params.userPtr, &fillPaint, state->compositeOperation, &state->scissor, ctx->fringeWidth, - ctx->cache->bounds, ctx->cache->paths, ctx->cache->npaths); + ctx->cache->bounds, ctx->cache->paths, ctx->cache->npaths, state->m_filterStack); // Count triangles for (i = 0; i < ctx->cache->npaths; i++) { @@ -2261,7 +2271,7 @@ void nvgStroke(NVGcontext* ctx) nvg__expandStroke(ctx, strokeWidth*0.5f, 0.0f, state->lineCap, state->lineJoin, state->miterLimit); ctx->params.renderStroke(ctx->params.userPtr, &strokePaint, state->compositeOperation, &state->scissor, ctx->fringeWidth, - strokeWidth, ctx->cache->paths, ctx->cache->npaths); + strokeWidth, ctx->cache->paths, ctx->cache->npaths, state->m_filterStack); // Count triangles for (i = 0; i < ctx->cache->npaths; i++) { @@ -2412,7 +2422,7 @@ static void nvg__renderText(NVGcontext* ctx, NVGpaint* paint, NVGvertex* verts, paint->innerColor.a *= state->alpha; paint->outerColor.a *= state->alpha; - ctx->params.renderTriangles(ctx->params.userPtr, paint, state->compositeOperation, &state->scissor, verts, nverts); + ctx->params.renderTriangles(ctx->params.userPtr, paint, state->compositeOperation, &state->scissor, verts, nverts, state->m_filterStack); ctx->drawCallCount++; ctx->textTriCount += nverts/3; diff --git a/Polyfills/Canvas/Source/nanovg/nanovg.h b/Polyfills/Canvas/Source/nanovg/nanovg.h index 8703237bb..9aaf1e387 100644 --- a/Polyfills/Canvas/Source/nanovg/nanovg.h +++ b/Polyfills/Canvas/Source/nanovg/nanovg.h @@ -30,6 +30,7 @@ extern "C" { #pragma warning(disable: 4201) // nonstandard extension used : nameless struct/union #endif +class nanovg_filterstack; typedef struct NVGcontext NVGcontext; struct NVGcolor { @@ -609,6 +610,7 @@ void nvgTextMetrics(NVGcontext* ctx, float* ascender, float* descender, float* l // Words longer than the max width are slit at nearest character (i.e. no hyphenation). int nvgTextBreakLines(NVGcontext* ctx, const char* string, const char* end, float breakRowWidth, NVGtextRow* rows, int maxRows); +void nvgFilterStack(NVGcontext* ctx, nanovg_filterstack& filterStack); // // Internal Render API // @@ -653,9 +655,9 @@ struct NVGparams { void (*renderViewport)(void* uptr, float width, float height, float devicePixelRatio); void (*renderCancel)(void* uptr); void (*renderFlush)(void* uptr); - void (*renderFill)(void* uptr, NVGpaint* paint, NVGcompositeOperationState compositeOperation, NVGscissor* scissor, float fringe, const float* bounds, const NVGpath* paths, int npaths); - void (*renderStroke)(void* uptr, NVGpaint* paint, NVGcompositeOperationState compositeOperation, NVGscissor* scissor, float fringe, float strokeWidth, const NVGpath* paths, int npaths); - void (*renderTriangles)(void* uptr, NVGpaint* paint, NVGcompositeOperationState compositeOperation, NVGscissor* scissor, const NVGvertex* verts, int nverts); + void (*renderFill)(void* uptr, NVGpaint* paint, NVGcompositeOperationState compositeOperation, NVGscissor* scissor, float fringe, const float* bounds, const NVGpath* paths, int npaths, nanovg_filterstack& filterStack); + void (*renderStroke)(void* uptr, NVGpaint* paint, NVGcompositeOperationState compositeOperation, NVGscissor* scissor, float fringe, float strokeWidth, const NVGpath* paths, int npaths, nanovg_filterstack& filterStack); + void (*renderTriangles)(void* uptr, NVGpaint* paint, NVGcompositeOperationState compositeOperation, NVGscissor* scissor, const NVGvertex* verts, int nverts, nanovg_filterstack& filterStack); void (*renderDelete)(void* uptr); }; typedef struct NVGparams NVGparams; diff --git a/Polyfills/Canvas/Source/nanovg/nanovg_babylon.cpp b/Polyfills/Canvas/Source/nanovg/nanovg_babylon.cpp index 0cf924928..5a8eeddc4 100644 --- a/Polyfills/Canvas/Source/nanovg/nanovg_babylon.cpp +++ b/Polyfills/Canvas/Source/nanovg/nanovg_babylon.cpp @@ -36,7 +36,7 @@ #include #include - +#include BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4244) // warning C4244: '=' : conversion from '' to '', possible loss of data #include "Shaders/dx11/vs_nanovg_fill.h" @@ -50,6 +50,85 @@ BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4244) // warning C4244: '=' : conversion from #include "Shaders/spirv/vs_nanovg_fill.h" #include "Shaders/spirv/fs_nanovg_fill.h" +#include "nanovg_filterstack.h" + +struct PosTexCoord0Vertex +{ + float m_x; + float m_y; + float m_z; + float m_u; + float m_v; + + static void init() + { + ms_layout + .begin() + .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) + .add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float) + .end(); + } + + static bgfx::VertexLayout ms_layout; +}; + +bgfx::VertexLayout PosTexCoord0Vertex::ms_layout; + +void screenSpaceQuad(bgfx::Encoder* encoder, bool _originBottomLeft, float _width = 1.0f, float _height = 1.0f) +{ + if (3 == bgfx::getAvailTransientVertexBuffer(3, PosTexCoord0Vertex::ms_layout)) + { + bgfx::TransientVertexBuffer vb; + bgfx::allocTransientVertexBuffer(&vb, 3, PosTexCoord0Vertex::ms_layout); + PosTexCoord0Vertex* vertex = (PosTexCoord0Vertex*)vb.data; + + const float minx = -_width; + const float maxx = _width; + const float miny = 0.0f; + const float maxy = _height * 2.0f; + + const float minu = -1.0f; + const float maxu = 1.0f; + + const float zz = 0.0f; + + float minv = 0.0f; + float maxv = 2.0f; + + if (_originBottomLeft) + { + float temp = minv; + minv = maxv; + maxv = temp; + + minv -= 1.0f; + maxv -= 1.0f; + } + + vertex[0].m_x = minx; + vertex[0].m_y = miny; + vertex[0].m_z = zz; + vertex[0].m_u = minu; + vertex[0].m_v = minv; + + vertex[1].m_x = maxx; + vertex[1].m_y = miny; + vertex[1].m_z = zz; + vertex[1].m_u = maxu; + vertex[1].m_v = minv; + + vertex[2].m_x = maxx; + vertex[2].m_y = maxy; + vertex[2].m_z = zz; + vertex[2].m_u = maxu; + vertex[2].m_v = maxv; + + //bgfx::setVertexBuffer(0, &vb); + encoder->setVertexBuffer(0, &vb); + } +} + + static const bgfx::EmbeddedShader s_embeddedShadersBabylon[] = { BGFX_EMBEDDED_SHADER(vs_nanovg_fill), @@ -111,6 +190,7 @@ namespace int vertexCount; int uniformOffset; GLNVGblend blendFunc; + nanovg_filterstack filterStack; }; struct GLNVGpath @@ -176,6 +256,7 @@ namespace bgfx::TransientVertexBuffer tvb; Babylon::Graphics::FrameBuffer* frameBuffer; + PoolInterface frameBufferPool; bgfx::Encoder* encoder; struct GLNVGtexture* textures; @@ -291,6 +372,7 @@ namespace gl->u_sdf = bgfx::createUniform("u_sdf", bgfx::UniformType::Vec4); gl->s_tex = bgfx::createUniform("s_tex", bgfx::UniformType::Sampler); gl->s_tex2 = bgfx::createUniform("s_tex2", bgfx::UniformType::Sampler); + nanovg_filterstack::InitBgfx(); // initialize filter stack uniforms + programs gl->u_halfTexel.idx = bgfx::kInvalidHandle; @@ -623,143 +705,220 @@ namespace static void glnvg__fill(struct GLNVGcontext* gl, struct GLNVGcall* call) { - struct GLNVGpath* paths = &gl->paths[call->pathOffset]; - int i, npaths = call->pathCount; + bgfx::ProgramHandle firstProg = gl->prog; + std::function setUniform = [gl](bgfx::UniformHandle u, const void *value) { + gl->encoder->setUniform(u, value); + }; + std::function firstPass = [gl, call](bgfx::ProgramHandle prog, Babylon::Graphics::FrameBuffer *outBuffer) { - // set bindpoint for solid loc - nvgRenderSetUniforms(gl, call->uniformOffset, 0, 0); + struct GLNVGpath* paths = &gl->paths[call->pathOffset]; + int i, npaths = call->pathCount; - for (i = 0; i < npaths; i++) - { - if (2 < paths[i].fillCount) + // set bindpoint for solid loc + nvgRenderSetUniforms(gl, call->uniformOffset, 0, 0); + + for (i = 0; i < npaths; i++) { - gl->encoder->setState(0); - gl->encoder->setStencil(0 - | BGFX_STENCIL_TEST_ALWAYS - | BGFX_STENCIL_FUNC_RMASK(0xff) - | BGFX_STENCIL_OP_FAIL_S_KEEP - | BGFX_STENCIL_OP_FAIL_Z_KEEP - | BGFX_STENCIL_OP_PASS_Z_INCR - , 0 - | BGFX_STENCIL_TEST_ALWAYS - | BGFX_STENCIL_FUNC_RMASK(0xff) - | BGFX_STENCIL_OP_FAIL_S_KEEP - | BGFX_STENCIL_OP_FAIL_Z_KEEP - | BGFX_STENCIL_OP_PASS_Z_DECR - ); - gl->encoder->setVertexBuffer(0, &gl->tvb); - gl->encoder->setTexture(0, gl->s_tex, gl->th); - gl->encoder->setTexture(1, gl->s_tex2, gl->th2); - fan(gl->encoder, paths[i].fillOffset, paths[i].fillCount); - gl->frameBuffer->Submit(*gl->encoder, gl->prog, BGFX_DISCARD_ALL); + if (2 < paths[i].fillCount) + { + gl->encoder->setState(0); + gl->encoder->setStencil(0 + | BGFX_STENCIL_TEST_ALWAYS + | BGFX_STENCIL_FUNC_RMASK(0xff) + | BGFX_STENCIL_OP_FAIL_S_KEEP + | BGFX_STENCIL_OP_FAIL_Z_KEEP + | BGFX_STENCIL_OP_PASS_Z_INCR + , 0 + | BGFX_STENCIL_TEST_ALWAYS + | BGFX_STENCIL_FUNC_RMASK(0xff) + | BGFX_STENCIL_OP_FAIL_S_KEEP + | BGFX_STENCIL_OP_FAIL_Z_KEEP + | BGFX_STENCIL_OP_PASS_Z_DECR + ); + gl->encoder->setVertexBuffer(0, &gl->tvb); + gl->encoder->setTexture(0, gl->s_tex, gl->th); + gl->encoder->setTexture(1, gl->s_tex2, gl->th2); + fan(gl->encoder, paths[i].fillOffset, paths[i].fillCount); + outBuffer->Submit(*gl->encoder, prog, BGFX_DISCARD_ALL); + } } - } - // Draw aliased off-pixels - nvgRenderSetUniforms(gl, call->uniformOffset + gl->fragSize, call->image, call->image2); + // Draw aliased off-pixels + nvgRenderSetUniforms(gl, call->uniformOffset + gl->fragSize, call->image, call->image2); - if (gl->edgeAntiAlias) - { - // Draw fringes - for (i = 0; i < npaths; i++) + if (gl->edgeAntiAlias) { - gl->encoder->setState(gl->state - | BGFX_STATE_PT_TRISTRIP - ); - gl->encoder->setStencil(0 - | BGFX_STENCIL_TEST_EQUAL - | BGFX_STENCIL_FUNC_RMASK(0xff) - | BGFX_STENCIL_OP_FAIL_S_KEEP - | BGFX_STENCIL_OP_FAIL_Z_KEEP - | BGFX_STENCIL_OP_PASS_Z_KEEP - ); - gl->encoder->setVertexBuffer(0, &gl->tvb, paths[i].strokeOffset, paths[i].strokeCount); - gl->encoder->setTexture(0, gl->s_tex, gl->th); - gl->encoder->setTexture(1, gl->s_tex2, gl->th2); - gl->frameBuffer->Submit(*gl->encoder, gl->prog, BGFX_DISCARD_ALL); + // Draw fringes + for (i = 0; i < npaths; i++) + { + gl->encoder->setState(gl->state + | BGFX_STATE_PT_TRISTRIP + ); + gl->encoder->setStencil(0 + | BGFX_STENCIL_TEST_EQUAL + | BGFX_STENCIL_FUNC_RMASK(0xff) + | BGFX_STENCIL_OP_FAIL_S_KEEP + | BGFX_STENCIL_OP_FAIL_Z_KEEP + | BGFX_STENCIL_OP_PASS_Z_KEEP + ); + gl->encoder->setVertexBuffer(0, &gl->tvb, paths[i].strokeOffset, paths[i].strokeCount); + gl->encoder->setTexture(0, gl->s_tex, gl->th); + gl->encoder->setTexture(1, gl->s_tex2, gl->th2); + outBuffer->Submit(*gl->encoder, prog, BGFX_DISCARD_ALL); + } } - } - // Draw fill - gl->encoder->setState(gl->state); - gl->encoder->setVertexBuffer(0, &gl->tvb, call->vertexOffset, call->vertexCount); - gl->encoder->setTexture(0, gl->s_tex, gl->th); - gl->encoder->setTexture(1, gl->s_tex2, gl->th2); - gl->encoder->setStencil(0 - | BGFX_STENCIL_TEST_NOTEQUAL - | BGFX_STENCIL_FUNC_RMASK(0xff) - | BGFX_STENCIL_OP_FAIL_S_ZERO - | BGFX_STENCIL_OP_FAIL_Z_ZERO - | BGFX_STENCIL_OP_PASS_Z_ZERO - ); - gl->frameBuffer->Submit(*gl->encoder, gl->prog, BGFX_DISCARD_ALL); + // Draw fill + gl->encoder->setState(gl->state); + gl->encoder->setVertexBuffer(0, &gl->tvb, call->vertexOffset, call->vertexCount); + gl->encoder->setTexture(0, gl->s_tex, gl->th); + gl->encoder->setTexture(1, gl->s_tex2, gl->th2); + gl->encoder->setStencil(0 + | BGFX_STENCIL_TEST_NOTEQUAL + | BGFX_STENCIL_FUNC_RMASK(0xff) + | BGFX_STENCIL_OP_FAIL_S_ZERO + | BGFX_STENCIL_OP_FAIL_Z_ZERO + | BGFX_STENCIL_OP_PASS_Z_ZERO + ); + outBuffer->Submit(*gl->encoder, prog, BGFX_DISCARD_ALL); + }; + std::function filterPass = [gl, call](bgfx::ProgramHandle prog, Babylon::Graphics::FrameBuffer *inBuffer, Babylon::Graphics::FrameBuffer *outBuffer) { + gl->encoder->setUniform(gl->u_viewSize, gl->view); // TODO: also set other common uniforms + gl->encoder->setState(BGFX_STATE_WRITE_RGB | BGFX_STATE_WRITE_A + | BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_INV_SRC_ALPHA) + | BGFX_STATE_BLEND_EQUATION(BGFX_STATE_BLEND_EQUATION_ADD)); + gl->encoder->setTexture(0, gl->s_tex, bgfx::getTexture(inBuffer->Handle())); + bool s_originBottomLeft = bgfx::getCaps()->originBottomLeft; + screenSpaceQuad(gl->encoder, s_originBottomLeft); + outBuffer->Submit(*gl->encoder, prog, BGFX_DISCARD_ALL); + }; + Babylon::Graphics::FrameBuffer *finalFrameBuffer = gl->frameBuffer; + finalFrameBuffer->Bind(*gl->encoder); // Should this be bound elsewhere? + + call->filterStack.Render(firstProg, setUniform, firstPass, filterPass, finalFrameBuffer, gl->frameBufferPool.acquire, gl->frameBufferPool.release); } static void glnvg__convexFill(struct GLNVGcontext* gl, struct GLNVGcall* call) { - struct GLNVGpath* paths = &gl->paths[call->pathOffset]; - int i, npaths = call->pathCount; - - nvgRenderSetUniforms(gl, call->uniformOffset, call->image, call->image2); + bgfx::ProgramHandle firstProg = gl->prog; + std::function setUniform = [gl](bgfx::UniformHandle u, const void *value) { + gl->encoder->setUniform(u, value); + }; + std::function firstPass = [gl, call](bgfx::ProgramHandle prog, Babylon::Graphics::FrameBuffer *outBuffer) { + struct GLNVGpath* paths = &gl->paths[call->pathOffset]; + int i, npaths = call->pathCount; - for (i = 0; i < npaths; i++) - { - if (paths[i].fillCount == 0) continue; - gl->encoder->setState(gl->state); - gl->encoder->setVertexBuffer(0, &gl->tvb); - gl->encoder->setTexture(0, gl->s_tex, gl->th); - gl->encoder->setTexture(1, gl->s_tex2, gl->th2); - fan(gl->encoder, paths[i].fillOffset, paths[i].fillCount); - gl->frameBuffer->Submit(*gl->encoder, gl->prog, BGFX_DISCARD_ALL); - } + nvgRenderSetUniforms(gl, call->uniformOffset, call->image, call->image2); - if (gl->edgeAntiAlias) - { - // Draw fringes for (i = 0; i < npaths; i++) { - gl->encoder->setState(gl->state - | BGFX_STATE_PT_TRISTRIP - ); - gl->encoder->setVertexBuffer(0, &gl->tvb, paths[i].strokeOffset, paths[i].strokeCount); + if (paths[i].fillCount == 0) continue; + gl->encoder->setState(gl->state); + gl->encoder->setVertexBuffer(0, &gl->tvb); gl->encoder->setTexture(0, gl->s_tex, gl->th); gl->encoder->setTexture(1, gl->s_tex2, gl->th2); - gl->frameBuffer->Submit(*gl->encoder, gl->prog, BGFX_DISCARD_ALL); + fan(gl->encoder, paths[i].fillOffset, paths[i].fillCount); + outBuffer->Submit(*gl->encoder, prog, BGFX_DISCARD_ALL); } - } + + if (gl->edgeAntiAlias) + { + // Draw fringes + for (i = 0; i < npaths; i++) + { + gl->encoder->setState(gl->state + | BGFX_STATE_PT_TRISTRIP + ); + gl->encoder->setVertexBuffer(0, &gl->tvb, paths[i].strokeOffset, paths[i].strokeCount); + gl->encoder->setTexture(0, gl->s_tex, gl->th); + gl->encoder->setTexture(1, gl->s_tex2, gl->th2); + outBuffer->Submit(*gl->encoder, prog, BGFX_DISCARD_ALL); + } + } + }; + std::function filterPass = [gl, call](bgfx::ProgramHandle prog, Babylon::Graphics::FrameBuffer *inBuffer, Babylon::Graphics::FrameBuffer *outBuffer) { + gl->encoder->setUniform(gl->u_viewSize, gl->view); // TODO: also set other common uniforms + gl->encoder->setState(BGFX_STATE_WRITE_RGB | BGFX_STATE_WRITE_A + | BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_INV_SRC_ALPHA) + | BGFX_STATE_BLEND_EQUATION(BGFX_STATE_BLEND_EQUATION_ADD)); + gl->encoder->setTexture(0, gl->s_tex, bgfx::getTexture(inBuffer->Handle())); + bool s_originBottomLeft = bgfx::getCaps()->originBottomLeft; + screenSpaceQuad(gl->encoder, s_originBottomLeft); + outBuffer->Submit(*gl->encoder, prog, BGFX_DISCARD_ALL); + }; + Babylon::Graphics::FrameBuffer *finalFrameBuffer = gl->frameBuffer; + finalFrameBuffer->Bind(*gl->encoder); // Should this be bound elsewhere? + + call->filterStack.Render(firstProg, setUniform, firstPass, filterPass, finalFrameBuffer, gl->frameBufferPool.acquire, gl->frameBufferPool.release); } static void glnvg__stroke(struct GLNVGcontext* gl, struct GLNVGcall* call) { - struct GLNVGpath* paths = &gl->paths[call->pathOffset]; - int npaths = call->pathCount, i; - - nvgRenderSetUniforms(gl, call->uniformOffset, call->image, call->image2); + bgfx::ProgramHandle firstProg = gl->prog; + std::function setUniform = [gl](bgfx::UniformHandle u, const void *value) { + gl->encoder->setUniform(u, value); + }; + std::function firstPass = [gl, call](bgfx::ProgramHandle prog, Babylon::Graphics::FrameBuffer *outBuffer) { + // Draw Strokes + struct GLNVGpath* paths = &gl->paths[call->pathOffset]; + int npaths = call->pathCount, i; + for (i = 0; i < npaths; i++) + { + nvgRenderSetUniforms(gl, call->uniformOffset, call->image, call->image2); - // Draw Strokes - for (i = 0; i < npaths; i++) - { - gl->encoder->setState(gl->state - | BGFX_STATE_PT_TRISTRIP - ); - gl->encoder->setVertexBuffer(0, &gl->tvb, paths[i].strokeOffset, paths[i].strokeCount); - gl->encoder->setTexture(0, gl->s_tex, gl->th); - gl->encoder->setTexture(1, gl->s_tex2, gl->th2); - gl->frameBuffer->Submit(*gl->encoder, gl->prog, BGFX_DISCARD_ALL); - } + gl->encoder->setState(gl->state | BGFX_STATE_PT_TRISTRIP ); + gl->encoder->setVertexBuffer(0, &gl->tvb, paths[i].strokeOffset, paths[i].strokeCount); + gl->encoder->setTexture(0, gl->s_tex, gl->th); + gl->encoder->setTexture(1, gl->s_tex2, gl->th2); + outBuffer->Submit(*gl->encoder, prog, BGFX_DISCARD_ALL); + } + }; + std::function filterPass = [gl, call](bgfx::ProgramHandle prog, Babylon::Graphics::FrameBuffer *inBuffer, Babylon::Graphics::FrameBuffer *outBuffer) { + gl->encoder->setUniform(gl->u_viewSize, gl->view); // TODO: also set other common uniforms + gl->encoder->setState(BGFX_STATE_WRITE_RGB | BGFX_STATE_WRITE_A + | BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_INV_SRC_ALPHA) + | BGFX_STATE_BLEND_EQUATION(BGFX_STATE_BLEND_EQUATION_ADD)); + gl->encoder->setTexture(0, gl->s_tex, bgfx::getTexture(inBuffer->Handle())); + bool s_originBottomLeft = bgfx::getCaps()->originBottomLeft; + screenSpaceQuad(gl->encoder, s_originBottomLeft); + outBuffer->Submit(*gl->encoder, prog, BGFX_DISCARD_ALL); + }; + Babylon::Graphics::FrameBuffer *finalFrameBuffer = gl->frameBuffer; + finalFrameBuffer->Bind(*gl->encoder); // Should this be bound elsewhere? + + call->filterStack.Render(firstProg, setUniform, firstPass, filterPass, finalFrameBuffer, gl->frameBufferPool.acquire, gl->frameBufferPool.release); } static void glnvg__triangles(struct GLNVGcontext* gl, struct GLNVGcall* call) { if (3 <= call->vertexCount) { - nvgRenderSetUniforms(gl, call->uniformOffset, call->image, call->image2); - - gl->encoder->setState(gl->state); - gl->encoder->setVertexBuffer(0, &gl->tvb, call->vertexOffset, call->vertexCount); - gl->encoder->setTexture(0, gl->s_tex, gl->th); - gl->encoder->setTexture(1, gl->s_tex2, gl->th2); - gl->frameBuffer->Submit(*gl->encoder, gl->prog, BGFX_DISCARD_ALL); + bgfx::ProgramHandle firstProg = gl->prog; + std::function setUniform = [gl](bgfx::UniformHandle u, const void *value) { + gl->encoder->setUniform(u, value); + }; + std::function firstPass = [gl, call](bgfx::ProgramHandle prog, Babylon::Graphics::FrameBuffer *outBuffer) { + nvgRenderSetUniforms(gl, call->uniformOffset, call->image, call->image2); + gl->encoder->setState(gl->state); + gl->encoder->setVertexBuffer(0, &gl->tvb, call->vertexOffset, call->vertexCount); + gl->encoder->setTexture(0, gl->s_tex, gl->th); + gl->encoder->setTexture(1, gl->s_tex2, gl->th2); + outBuffer->Submit(*gl->encoder, prog, BGFX_DISCARD_ALL); + }; + std::function filterPass = [gl, call](bgfx::ProgramHandle prog, Babylon::Graphics::FrameBuffer *inBuffer, Babylon::Graphics::FrameBuffer *outBuffer) { + gl->encoder->setUniform(gl->u_viewSize, gl->view); // TODO: also set other common uniforms + gl->encoder->setState(BGFX_STATE_WRITE_RGB | BGFX_STATE_WRITE_A + | BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_INV_SRC_ALPHA) + | BGFX_STATE_BLEND_EQUATION(BGFX_STATE_BLEND_EQUATION_ADD)); + gl->encoder->setTexture(0, gl->s_tex, bgfx::getTexture(inBuffer->Handle())); + bool s_originBottomLeft = bgfx::getCaps()->originBottomLeft; + screenSpaceQuad(gl->encoder, s_originBottomLeft); + outBuffer->Submit(*gl->encoder, prog, BGFX_DISCARD_ALL); + }; + Babylon::Graphics::FrameBuffer *finalFrameBuffer = gl->frameBuffer; + finalFrameBuffer->Bind(*gl->encoder); // Should this be bound elsewhere? + + call->filterStack.Render(firstProg, setUniform, firstPass, filterPass, finalFrameBuffer, gl->frameBufferPool.acquire, gl->frameBufferPool.release); } } @@ -814,6 +973,9 @@ namespace , bgfx::createEmbeddedShader(s_embeddedShadersBabylon, type, "fs_nanovg_fill") , true ); + + // Vertex layout + PosTexCoord0Vertex::init(); } if (gl->ncalls > 0) @@ -835,6 +997,8 @@ namespace for (uint32_t ii = 0, num = gl->ncalls; ii < num; ++ii) { struct GLNVGcall* call = &gl->calls[ii]; + nanovg_filterstack fs = call->filterStack; // CHECK: did we want to do something with this? + const GLNVGblend* blend = &call->blendFunc; gl->state = BGFX_STATE_BLEND_FUNC_SEPARATE(blend->srcRGB, blend->dstRGB, blend->srcAlpha, blend->dstAlpha) | BGFX_STATE_WRITE_RGB @@ -957,6 +1121,7 @@ namespace , const float* bounds , const NVGpath* paths , int npaths + , nanovg_filterstack& filterStack ) { struct GLNVGcontext* gl = (struct GLNVGcontext*)_userPtr; @@ -972,6 +1137,7 @@ namespace call->image = paint->image; call->image2 = paint->image2; call->blendFunc = glnvg__blendCompositeOperation(compositeOperation); + call->filterStack = filterStack; if (npaths == 1 && paths[0].convex) { @@ -1044,6 +1210,7 @@ namespace , float strokeWidth , const struct NVGpath* paths , int npaths + , nanovg_filterstack& filterStack ) { struct GLNVGcontext* gl = (struct GLNVGcontext*)_userPtr; @@ -1057,6 +1224,7 @@ namespace call->image = paint->image; call->image2 = paint->image2; call->blendFunc = glnvg__blendCompositeOperation(compositeOperation); + call->filterStack = filterStack; // Allocate vertices for all the paths. maxverts = glnvg__maxVertCount(paths, npaths); @@ -1082,7 +1250,7 @@ namespace } static void nvgRenderTriangles(void* _userPtr, struct NVGpaint* paint, NVGcompositeOperationState compositeOperation, struct NVGscissor* scissor, - const struct NVGvertex* verts, int nverts) + const struct NVGvertex* verts, int nverts, nanovg_filterstack& filterStack) { struct GLNVGcontext* gl = (struct GLNVGcontext*)_userPtr; struct GLNVGcall* call = glnvg__allocCall(gl); @@ -1092,6 +1260,7 @@ namespace call->image = paint->image; call->image2 = paint->image2; call->blendFunc = glnvg__blendCompositeOperation(compositeOperation); + call->filterStack = filterStack; // Allocate vertices for all the paths. call->vertexOffset = glnvg__allocVerts(gl, nverts); @@ -1131,6 +1300,7 @@ namespace bgfx::destroy(gl->u_params); bgfx::destroy(gl->s_tex); bgfx::destroy(gl->s_tex2); + nanovg_filterstack::DisposeBgfx(); if (bgfx::isValid(gl->u_halfTexel) ) { @@ -1206,6 +1376,12 @@ NVGcontext* nvgCreate(int32_t _edgeaa, bx::AllocatorI* _allocator) return NULL; } +void nvgSetFrameBufferPool(NVGcontext* _ctx, PoolInterface pool) +{ + struct GLNVGcontext* gl = (GLNVGcontext*)nvgInternalParams(_ctx)->userPtr; + gl->frameBufferPool = pool; +} + void nvgSetFrameBufferAndEncoder(NVGcontext* _ctx, Babylon::Graphics::FrameBuffer& frameBuffer, bgfx::Encoder* encoder) { struct GLNVGcontext* gl = (GLNVGcontext*)nvgInternalParams(_ctx)->userPtr; diff --git a/Polyfills/Canvas/Source/nanovg/nanovg_babylon.h b/Polyfills/Canvas/Source/nanovg/nanovg_babylon.h index 8b7800490..18800babe 100644 --- a/Polyfills/Canvas/Source/nanovg/nanovg_babylon.h +++ b/Polyfills/Canvas/Source/nanovg/nanovg_babylon.h @@ -6,6 +6,7 @@ #ifndef NANOVG_BABYLON_H_HEADER_GUARD #define NANOVG_BABYLON_H_HEADER_GUARD +#include #include #include namespace bx @@ -21,6 +22,13 @@ NVGcontext* nvgCreate(int32_t _edgeaa, bx::AllocatorI* _allocator); /// NVGcontext* nvgCreate(int32_t _edgeaa); +struct PoolInterface +{ + std::function acquire; + std::function release; +}; + +void nvgSetFrameBufferPool(NVGcontext* _ctx, PoolInterface pool); void nvgSetFrameBufferAndEncoder(NVGcontext* _ctx, Babylon::Graphics::FrameBuffer& frameBuffer, bgfx::Encoder* encoder); /// diff --git a/Polyfills/Canvas/Source/nanovg/nanovg_filterstack.cpp b/Polyfills/Canvas/Source/nanovg/nanovg_filterstack.cpp new file mode 100644 index 000000000..70643fcec --- /dev/null +++ b/Polyfills/Canvas/Source/nanovg/nanovg_filterstack.cpp @@ -0,0 +1,176 @@ +#include "nanovg_filterstack.h" +#include +#include + +#include +#include + +std::regex blurRegex(R"(blur\((\d*\.?\d+)(px|rem)?\)|blur\(\))"); +std::regex noneRegex(R"(^\s*none\s*$)"); + +#define BLUR_ITERATIONS 3 + +#include "Shaders/dx11/vs_fspass.h" +#include "Shaders/metal/vs_fspass.h" +#include "Shaders/glsl/vs_fspass.h" +#include "Shaders/essl/vs_fspass.h" +#include "Shaders/spirv/vs_fspass.h" + +#include "Shaders/dx11/fs_gaussblur.h" +#include "Shaders/metal/fs_gaussblur.h" +#include "Shaders/glsl/fs_gaussblur.h" +#include "Shaders/essl/fs_gaussblur.h" +#include "Shaders/spirv/fs_gaussblur.h" + +static const bgfx::EmbeddedShader s_embeddedShadersFilterStack[] = +{ + BGFX_EMBEDDED_SHADER(vs_fspass), + BGFX_EMBEDDED_SHADER(fs_gaussblur), + BGFX_EMBEDDED_SHADER_END() +}; + +nanovg_filterstack::nanovg_filterstack() +{ +} + +void nanovg_filterstack::InitBgfx() +{ + m_uniforms.u_strength = bgfx::createUniform("u_strength", bgfx::UniformType::Vec4); + m_uniforms.u_direction = bgfx::createUniform("u_direction", bgfx::UniformType::Vec4); + + // create shaders used by the different elements + bgfx::RendererType::Enum type = bgfx::getRendererType(); + blurProg = bgfx::createProgram( + bgfx::createEmbeddedShader(s_embeddedShadersFilterStack, type, "vs_fspass") + , bgfx::createEmbeddedShader(s_embeddedShadersFilterStack, type, "fs_gaussblur") + , true + ); +} + +void nanovg_filterstack::DisposeBgfx() +{ + // check if uniforms + programs are valid before destroying + if (m_uniforms.u_strength.idx != bgfx::kInvalidHandle) + bgfx::destroy(m_uniforms.u_strength); + if (m_uniforms.u_direction.idx != bgfx::kInvalidHandle) + bgfx::destroy(m_uniforms.u_direction); + if (blurProg.idx != bgfx::kInvalidHandle) + bgfx::destroy(blurProg); +} + +bool nanovg_filterstack::ValidString(const std::string& string) +{ + std::smatch match; + return std::regex_match(string, match, noneRegex) || std::regex_match(string, match, blurRegex); +} + +void nanovg_filterstack::ParseString(const std::string& string) +{ + stackElements.clear(); + + std::smatch match; + if (std::regex_match(string, match, blurRegex)) + { + if ( match.size() > 1 && match[1].matched) + { + int radius = std::stoi(match[1].str()); + std::string unit = match[2].matched ? match[2].str() : "px"; + std::transform(unit.begin(), unit.end(), unit.begin(), ::tolower); + + if (unit != "px") + { + // TODO: convert non-px radius + } + + for (int i = 0; i < BLUR_ITERATIONS; i++) + { + StackElement element = {}; + element.type = SE_BLUR; + element.blurElement = {radius, radius}; + stackElements.push_back(element); + } + } + else + { + // defaults to blur(0), which is no blur + } + } +} + +void nanovg_filterstack::Render(std::function element) +{ + element(); +} + +void nanovg_filterstack::Render( + bgfx::ProgramHandle firstProg, + std::function setUniform, + std::function firstPass, + std::function filterPass, + Babylon::Graphics::FrameBuffer* finalFrameBuffer, + std::function acquire, + std::function release +) +{ + if (stackElements.empty()) + { + // no filter, render straight into final framebuffer + firstPass(firstProg, finalFrameBuffer); + } + else + { + assert(stackElements.size() > 0); + + Babylon::Graphics::FrameBuffer* prevBuf = nullptr; + Babylon::Graphics::FrameBuffer* nextBuf = acquire(); + bgfx::ProgramHandle lastProg = firstProg; + + // first pass + firstPass(firstProg, nextBuf); + prevBuf = nextBuf; + nextBuf = nullptr; + + int i = 0; + for (auto& element : stackElements) + { + assert(prevBuf != nullptr); + assert(nextBuf == nullptr); + + const bool last = (i == stackElements.size() - 1); + + if (element.type == SE_BLUR) + { + // Horizontal Pass + float horizontal[4] = {element.blurElement.horizontal * 1.f, 0.f, 0.f, 0.f}; // scale by element.blurElement.horizontal + setUniform(m_uniforms.u_direction, horizontal); + + nextBuf = acquire(); + filterPass(blurProg, prevBuf, nextBuf); + release(prevBuf); + prevBuf = nextBuf; + nextBuf = nullptr; + + // Vertical Pass + float vertical[4] = {0.f, element.blurElement.vertical * 1.f, 0.f, 0.f}; // scale by element.blurElement.vertical + setUniform(m_uniforms.u_direction, vertical); + if (last) + { + lastProg = blurProg; + break; // last pass will write to finalFrameBuffer + } + nextBuf = acquire(); + filterPass(blurProg, prevBuf, nextBuf); + release(prevBuf); + prevBuf = nextBuf; + nextBuf = nullptr; + } + i++; + } + + assert(prevBuf != nullptr); + assert(nextBuf == nullptr); + + filterPass(lastProg, prevBuf, finalFrameBuffer); + release(prevBuf); + } +} \ No newline at end of file diff --git a/Polyfills/Canvas/Source/nanovg/nanovg_filterstack.h b/Polyfills/Canvas/Source/nanovg/nanovg_filterstack.h new file mode 100644 index 000000000..246873687 --- /dev/null +++ b/Polyfills/Canvas/Source/nanovg/nanovg_filterstack.h @@ -0,0 +1,76 @@ +#pragma once +#include +#include +#include "Babylon/Graphics/FrameBuffer.h" + +class nanovg_filterstack +{ +public: + nanovg_filterstack(); + + static void InitBgfx(); + static void DisposeBgfx(); + inline static bgfx::ProgramHandle fspassProg; + inline static bgfx::ProgramHandle blurProg; + inline struct Uniforms + { + bgfx::UniformHandle u_strength; + bgfx::UniformHandle u_direction; + } static m_uniforms; + + void AddSepia(float strength) {} + void AddContrast(float strength) {} + void AddBlur(int horizontal, int vertical) {} + + void Render( + bgfx::ProgramHandle firstProg, + std::function setUniform, + std::function firstPass, + std::function filterPass, + Babylon::Graphics::FrameBuffer* finalFrameBuffer, + std::function acquire, + std::function release + ); + void Render(std::function element); + + void ParseString(const std::string& string); + static bool ValidString(const std::string& string); + + void AddDropShadow() + { + // break down shadow as blur + color + } + void Clear() { stackElements.clear(); } +protected: + + enum StackElementTypes + { + SE_SEPIA = 0, + SE_CONTRAST = 1, + SE_BLUR = 2, + }; + + struct SepiaElement + { + float strength; + }; + struct Contrast + { + float strength; + }; + struct Blur + { + int horizontal, vertical; // blur strength (in px) + }; + struct StackElement + { + StackElementTypes type; + union + { + SepiaElement sepiaElement; + Contrast contrastElement; + Blur blurElement; + }; + }; + std::vector stackElements; +}; \ No newline at end of file