This repository was archived by the owner on Apr 29, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +58
-5
lines changed
cmdbufferCanvas/rendering Expand file tree Collapse file tree 6 files changed +58
-5
lines changed Original file line number Diff line number Diff line change 1+ using Unity . UIWidgets . foundation ;
2+
3+ namespace Unity . UIWidgets . editor {
4+ public class WindowConfig {
5+ public readonly bool disableRasterCache ;
6+
7+ public static float MaxRasterImageSize = 4096 ;
8+
9+ static bool ? _disableComputeBuffer = null ;
10+
11+ public static bool disableComputeBuffer {
12+ //disable compute buffer by default for now
13+ get { return _disableComputeBuffer ?? true ; }
14+ set {
15+ D . assert ( _disableComputeBuffer == null
16+ || _disableComputeBuffer == value
17+ , ( ) => "The global settings of [disableComputeBuffer] cannot be initiated for multiple times!" ) ;
18+
19+ _disableComputeBuffer = value ;
20+ }
21+ }
22+
23+ public WindowConfig ( bool disableRasterCache ) {
24+ this . disableRasterCache = disableRasterCache ;
25+ }
26+
27+ public static readonly WindowConfig defaultConfig = new WindowConfig (
28+ disableRasterCache : false
29+ ) ;
30+ }
31+ }
Original file line number Diff line number Diff line change 1+ using Unity . UIWidgets . editor ;
12using UnityEngine ;
23using UnityEngine . Rendering ;
34
45namespace Unity . UIWidgets . ui {
56 static partial class CanvasShader {
6- const bool enableComputeBuffer = false ;
7-
87 const bool enableDebugLog = false ;
98
109 public static bool supportComputeBuffer ;
@@ -22,7 +21,7 @@ static bool IsShaderSupported() {
2221 }
2322
2423 static void InitShaders ( ) {
25- supportComputeBuffer = enableComputeBuffer && SystemInfo . supportsComputeShaders && IsShaderSupported ( ) ;
24+ supportComputeBuffer = ! WindowConfig . disableComputeBuffer && SystemInfo . supportsComputeShaders && IsShaderSupported ( ) ;
2625
2726 if ( ! supportComputeBuffer ) {
2827 DebugAssert ( false , "init default shaders" ) ;
Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
3+ using Unity . UIWidgets . editor ;
34using Unity . UIWidgets . foundation ;
45using Unity . UIWidgets . ui ;
56using UnityEngine ;
@@ -210,6 +211,10 @@ static bool _canRasterizePicture(Picture picture) {
210211 return false ;
211212 }
212213
214+ if ( Window . instance . windowConfig . disableRasterCache ) {
215+ return false ;
216+ }
217+
213218 var bounds = picture . paintBounds ;
214219 if ( bounds . isEmpty ) {
215220 return false ;
@@ -223,6 +228,12 @@ static bool _canRasterizePicture(Picture picture) {
223228 return false ;
224229 }
225230
231+ //https://forum.unity.com/threads/rendertexture-create-failed-rendertexture-too-big.58667/
232+ if ( picture . paintBounds . size . width > WindowConfig . MaxRasterImageSize ||
233+ picture . paintBounds . size . height > WindowConfig . MaxRasterImageSize ) {
234+ return false ;
235+ }
236+
226237 return true ;
227238 }
228239
Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
33using Unity . UIWidgets . async ;
4+ using Unity . UIWidgets . editor ;
45using Unity . UIWidgets . foundation ;
56using UnityEngine ;
67
@@ -148,11 +149,12 @@ public int antiAliasing {
148149
149150 protected int _antiAliasing = defaultAntiAliasing ;
150151
151-
152152 public Size physicalSize {
153153 get { return this . _physicalSize ; }
154154 }
155155
156+ public WindowConfig windowConfig = WindowConfig . defaultConfig ;
157+
156158 protected Size _physicalSize = Size . zero ;
157159
158160 public WindowPadding viewInsets {
Original file line number Diff line number Diff line change 11using UIWidgetsGallery . gallery ;
22using Unity . UIWidgets . engine ;
3- using Unity . UIWidgets . material ;
43using Unity . UIWidgets . ui ;
54using Unity . UIWidgets . widgets ;
65using UnityEngine ;
You can’t perform that action at this time.
0 commit comments