Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Addglobalconfig #350

Merged
merged 3 commits into from
Oct 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Runtime/editor/window_config.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Unity.UIWidgets.foundation;

namespace Unity.UIWidgets.editor {
public class WindowConfig {
public readonly bool disableRasterCache;

public static float MaxRasterImageSize = 4096;

static bool? _disableComputeBuffer = null;

public static bool disableComputeBuffer {
//disable compute buffer by default for now
get { return _disableComputeBuffer ?? true; }
set {
D.assert(_disableComputeBuffer == null
|| _disableComputeBuffer == value
, () => "The global settings of [disableComputeBuffer] cannot be initiated for multiple times!");

_disableComputeBuffer = value;
}
}

public WindowConfig(bool disableRasterCache) {
this.disableRasterCache = disableRasterCache;
}

public static readonly WindowConfig defaultConfig = new WindowConfig(
disableRasterCache: false
);
}
}
11 changes: 11 additions & 0 deletions Runtime/editor/window_config.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using Unity.UIWidgets.editor;
using UnityEngine;
using UnityEngine.Rendering;

namespace Unity.UIWidgets.ui {
static partial class CanvasShader {
const bool enableComputeBuffer = false;

const bool enableDebugLog = false;

public static bool supportComputeBuffer;
Expand All @@ -22,7 +21,7 @@ static bool IsShaderSupported() {
}

static void InitShaders() {
supportComputeBuffer = enableComputeBuffer && SystemInfo.supportsComputeShaders && IsShaderSupported();
supportComputeBuffer = !WindowConfig.disableComputeBuffer && SystemInfo.supportsComputeShaders && IsShaderSupported();

if (!supportComputeBuffer) {
DebugAssert(false, "init default shaders");
Expand Down
11 changes: 11 additions & 0 deletions Runtime/ui/renderer/compositeCanvas/flow/raster_cache.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Unity.UIWidgets.editor;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
Expand Down Expand Up @@ -210,6 +211,10 @@ static bool _canRasterizePicture(Picture picture) {
return false;
}

if (Window.instance.windowConfig.disableRasterCache) {
return false;
}

var bounds = picture.paintBounds;
if (bounds.isEmpty) {
return false;
Expand All @@ -223,6 +228,12 @@ static bool _canRasterizePicture(Picture picture) {
return false;
}

//https://forum.unity.com/threads/rendertexture-create-failed-rendertexture-too-big.58667/
if (picture.paintBounds.size.width > WindowConfig.MaxRasterImageSize ||
picture.paintBounds.size.height > WindowConfig.MaxRasterImageSize) {
return false;
}

return true;
}

Expand Down
4 changes: 3 additions & 1 deletion Runtime/ui/window.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Unity.UIWidgets.async;
using Unity.UIWidgets.editor;
using Unity.UIWidgets.foundation;
using UnityEngine;

Expand Down Expand Up @@ -148,11 +149,12 @@ public int antiAliasing {

protected int _antiAliasing = defaultAntiAliasing;


public Size physicalSize {
get { return this._physicalSize; }
}

public WindowConfig windowConfig = WindowConfig.defaultConfig;

protected Size _physicalSize = Size.zero;

public WindowPadding viewInsets {
Expand Down
1 change: 0 additions & 1 deletion Samples/UIWidgetsGallery/GalleryMain.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using UIWidgetsGallery.gallery;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.material;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
Expand Down