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

Commit b39d79f

Browse files
author
Yuncong Zhang
authored
Merge pull request #292 from UnityTech/removehardwareMSAA
remove all hardware-MSAA related codes
2 parents 623540e + 5b4e40e commit b39d79f

File tree

13 files changed

+19
-91
lines changed

13 files changed

+19
-91
lines changed

Editor/UIWidgetsPanelEditor.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ public class UIWidgetsPanelEditor : RawImageEditor {
99
public override void OnInspectorGUI() {
1010
base.OnInspectorGUI();
1111
var pixelRatioProperty = this.serializedObject.FindProperty("devicePixelRatioOverride");
12-
var antiAliasingProperty = this.serializedObject.FindProperty("antiAliasingOverride");
1312
EditorGUILayout.PropertyField(pixelRatioProperty);
14-
EditorGUILayout.PropertyField(antiAliasingProperty);
1513
this.serializedObject.ApplyModifiedProperties();
1614
}
1715
}

Runtime/editor/editor_window.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ protected override float queryDevicePixelRatio() {
9292
return EditorGUIUtility.pixelsPerPoint;
9393
}
9494

95-
protected override int queryAntiAliasing() {
96-
return defaultAntiAliasing;
97-
}
98-
9995
protected override Vector2 queryWindowSize() {
10096
return this.editorWindow.position.size;
10197
}
@@ -192,7 +188,6 @@ public void onViewMetricsChanged() {
192188

193189
public void OnEnable() {
194190
this._devicePixelRatio = this.queryDevicePixelRatio();
195-
this._antiAliasing = this.queryAntiAliasing();
196191
this.updatePhysicalSize();
197192
this.updateSafeArea();
198193
D.assert(this._surface == null);
@@ -276,10 +271,6 @@ protected bool displayMetricsChanged() {
276271
return true;
277272
}
278273

279-
if (this._antiAliasing != this.queryAntiAliasing()) {
280-
return true;
281-
}
282-
283274
var size = this.queryWindowSize();
284275
if (this._lastWindowWidth != size.x
285276
|| this._lastWindowHeight != size.y) {
@@ -298,7 +289,6 @@ public virtual void OnGUI(Event evt = null) {
298289
using (this.getScope()) {
299290
if (this.displayMetricsChanged()) {
300291
this._devicePixelRatio = this.queryDevicePixelRatio();
301-
this._antiAliasing = this.queryAntiAliasing();
302292

303293
var size = this.queryWindowSize();
304294
this._lastWindowWidth = size.x;
@@ -323,7 +313,6 @@ public virtual GUIContent titleContent {
323313
}
324314

325315
protected abstract float queryDevicePixelRatio();
326-
protected abstract int queryAntiAliasing();
327316
protected abstract Vector2 queryWindowSize();
328317

329318
protected virtual Surface createSurface() {
@@ -520,7 +509,6 @@ public override void render(Scene scene) {
520509

521510
layerTree.frameSize = this._physicalSize;
522511
layerTree.devicePixelRatio = this._devicePixelRatio;
523-
layerTree.antiAliasing = this._antiAliasing;
524512
this._rasterizer.draw(layerTree);
525513
}
526514

Runtime/editor/rasterizer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ bool _drawToSurface(LayerTree layerTree) {
6363
D.assert(this._surface != null);
6464

6565
var frame = this._surface.acquireFrame(
66-
layerTree.frameSize, layerTree.devicePixelRatio, layerTree.antiAliasing);
66+
layerTree.frameSize, layerTree.devicePixelRatio);
6767
if (frame == null) {
6868
return false;
6969
}

Runtime/editor/surface.cs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ bool _performSubmit() {
5454
}
5555

5656
public interface Surface : IDisposable {
57-
SurfaceFrame acquireFrame(Size size, float devicePixelRatio, int antiAliasing);
57+
SurfaceFrame acquireFrame(Size size, float devicePixelRatio);
5858

5959
MeshPool getMeshPool();
6060
}
@@ -104,8 +104,8 @@ public WindowSurfaceImpl(DrawToTargetFunc drawToTargetFunc = null) {
104104
this._drawToTargetFunc = drawToTargetFunc;
105105
}
106106

107-
public SurfaceFrame acquireFrame(Size size, float devicePixelRatio, int antiAliasing) {
108-
this._createOrUpdateRenderTexture(size, devicePixelRatio, antiAliasing);
107+
public SurfaceFrame acquireFrame(Size size, float devicePixelRatio) {
108+
this._createOrUpdateRenderTexture(size, devicePixelRatio);
109109

110110
return new SurfaceFrame(this._surface,
111111
(frame, canvas) => this._presentSurface(canvas));
@@ -151,11 +151,10 @@ protected bool _presentSurface(Canvas canvas) {
151151
return true;
152152
}
153153

154-
void _createOrUpdateRenderTexture(Size size, float devicePixelRatio, int antiAliasing) {
154+
void _createOrUpdateRenderTexture(Size size, float devicePixelRatio) {
155155
if (this._surface != null
156156
&& this._surface.size == size
157157
&& this._surface.devicePixelRatio == devicePixelRatio
158-
&& this._surface.antiAliasing == antiAliasing
159158
&& this._surface.getRenderTexture() != null) {
160159
return;
161160
}
@@ -165,16 +164,14 @@ void _createOrUpdateRenderTexture(Size size, float devicePixelRatio, int antiAli
165164
this._surface = null;
166165
}
167166

168-
this._surface = new GrSurface(size, devicePixelRatio, antiAliasing, this._meshPool);
167+
this._surface = new GrSurface(size, devicePixelRatio, this._meshPool);
169168
}
170169
}
171170

172171
public class GrSurface : IDisposable {
173172
public readonly Size size;
174173

175174
public readonly float devicePixelRatio;
176-
177-
public readonly int antiAliasing;
178175

179176
readonly MeshPool _meshPool;
180177

@@ -195,10 +192,9 @@ public Canvas getCanvas() {
195192
return this._canvas;
196193
}
197194

198-
public GrSurface(Size size, float devicePixelRatio, int antiAliasing, MeshPool meshPool) {
195+
public GrSurface(Size size, float devicePixelRatio, MeshPool meshPool) {
199196
this.size = size;
200197
this.devicePixelRatio = devicePixelRatio;
201-
this.antiAliasing = antiAliasing;
202198

203199
var desc = new RenderTextureDescriptor(
204200
(int) this.size.width, (int) this.size.height,
@@ -207,10 +203,6 @@ public GrSurface(Size size, float devicePixelRatio, int antiAliasing, MeshPool m
207203
autoGenerateMips = false,
208204
};
209205

210-
if (antiAliasing != 0) {
211-
desc.msaaSamples = antiAliasing;
212-
}
213-
214206
this._renderTexture = new RenderTexture(desc);
215207
this._renderTexture.hideFlags = HideFlags.HideAndDontSave;
216208

Runtime/engine/UIWidgetsPanel.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ protected override float queryDevicePixelRatio() {
6666
return this._uiWidgetsPanel.devicePixelRatio;
6767
}
6868

69-
protected override int queryAntiAliasing() {
70-
return this._uiWidgetsPanel.antiAliasing;
71-
}
72-
7369
protected override Vector2 queryWindowSize() {
7470
var rect = this._uiWidgetsPanel.rectTransform.rect;
7571
// Here we use ReferenceEquals instead of "==" due to
@@ -111,7 +107,6 @@ public class UIWidgetsPanel : RawImage, IPointerDownHandler, IPointerUpHandler,
111107
static Event _repaintEvent;
112108

113109
[SerializeField] protected float devicePixelRatioOverride;
114-
[SerializeField] protected int antiAliasingOverride = Window.defaultAntiAliasing;
115110
WindowAdapter _windowAdapter;
116111
Texture _texture;
117112
Vector2 _lastMouseMove;
@@ -170,10 +165,6 @@ public float devicePixelRatio {
170165
}
171166
}
172167

173-
public int antiAliasing {
174-
get { return this.antiAliasingOverride >= 0 ? this.antiAliasingOverride : QualitySettings.antiAliasing; }
175-
}
176-
177168
public WindowPadding viewPadding {
178169
get { return this._displayMetrics.viewPadding; }
179170
}

Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_impl.cs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,7 @@ RenderLayer _createMaskLayer(RenderLayer parentLayer, uiRect maskBounds,
408408
width: textureWidth,
409409
height: textureHeight,
410410
layerBounds: maskBounds,
411-
filterMode: FilterMode.Bilinear,
412-
noMSAA: true
411+
filterMode: FilterMode.Bilinear
413412
);
414413

415414
parentLayer.addLayer(maskLayer);
@@ -449,8 +448,7 @@ RenderLayer _createBlurLayer(RenderLayer maskLayer, float sigmaX, float sigmaY,
449448
width: textureWidth,
450449
height: textureHeight,
451450
layerBounds: maskLayer.layerBounds,
452-
filterMode: FilterMode.Bilinear,
453-
noMSAA: true
451+
filterMode: FilterMode.Bilinear
454452
);
455453

456454
parentLayer.addLayer(blurXLayer);
@@ -460,8 +458,7 @@ RenderLayer _createBlurLayer(RenderLayer maskLayer, float sigmaX, float sigmaY,
460458
width: textureWidth,
461459
height: textureHeight,
462460
layerBounds: maskLayer.layerBounds,
463-
filterMode: FilterMode.Bilinear,
464-
noMSAA: true
461+
filterMode: FilterMode.Bilinear
465462
);
466463

467464
parentLayer.addLayer(blurYLayer);
@@ -1098,13 +1095,9 @@ void _drawLayer(RenderLayer layer, CommandBuffer cmdBuf) {
10981095
subLayer.width, subLayer.height,
10991096
RenderTextureFormat.Default, 24) {
11001097
useMipMap = false,
1101-
autoGenerateMips = false,
1098+
autoGenerateMips = false
11021099
};
11031100

1104-
if (this._renderTexture.antiAliasing != 0 && !subLayer.noMSAA) {
1105-
desc.msaaSamples = this._renderTexture.antiAliasing;
1106-
}
1107-
11081101
cmdBuf.GetTemporaryRT(subLayer.rtID, desc, subLayer.filterMode);
11091102
this._drawLayer(subLayer, cmdBuf);
11101103

Runtime/ui/renderer/cmdbufferCanvas/rendering/render_layer.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ internal class RenderLayer : PoolObject {
99
public int width;
1010
public int height;
1111
public FilterMode filterMode = FilterMode.Bilinear;
12-
public bool noMSAA = false;
1312
public uiRect layerBounds;
1413
public uiPaint? layerPaint;
1514
public readonly List<RenderCmd> draws = new List<RenderCmd>(128);
@@ -39,14 +38,13 @@ public Vector4 viewport {
3938

4039
public static RenderLayer create(int rtID = 0, int width = 0, int height = 0,
4140
FilterMode filterMode = FilterMode.Bilinear,
42-
bool noMSAA = false, uiRect? layerBounds = null, uiPaint? layerPaint = null, bool ignoreClip = true) {
41+
uiRect? layerBounds = null, uiPaint? layerPaint = null, bool ignoreClip = true) {
4342
D.assert(layerBounds != null);
4443
var newLayer = ObjectPool<RenderLayer>.alloc();
4544
newLayer.rtID = rtID;
4645
newLayer.width = width;
4746
newLayer.height = height;
4847
newLayer.filterMode = filterMode;
49-
newLayer.noMSAA = noMSAA;
5048
newLayer.layerBounds = layerBounds.Value;
5149
newLayer.layerPaint = layerPaint;
5250
newLayer.ignoreClip = ignoreClip;

Runtime/ui/renderer/compositeCanvas/flow/layer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ namespace Unity.UIWidgets.flow {
44
public class PrerollContext {
55
public RasterCache rasterCache;
66
public float devicePixelRatio;
7-
public int antiAliasing;
87
public Rect cullRect;
98
public Stopwatch frameTime;
109
}

Runtime/ui/renderer/compositeCanvas/flow/layer_tree.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,12 @@ public float devicePixelRatio {
2323
set { this._devicePixelRatio = value; }
2424
}
2525

26-
int _antiAliasing;
27-
28-
public int antiAliasing {
29-
get { return this._antiAliasing; }
30-
set { this._antiAliasing = value; }
31-
}
32-
3326
static readonly Matrix3 _identityMatrix = Matrix3.I();
3427

3528
public void preroll(CompositorContext.ScopedFrame frame, bool ignoreRasterCache = false) {
3629
var prerollContext = new PrerollContext {
3730
rasterCache = ignoreRasterCache ? null : frame.context().rasterCache(),
3831
devicePixelRatio = frame.canvas().getDevicePixelRatio(),
39-
antiAliasing = this.antiAliasing,
4032
cullRect = Rect.largest,
4133
frameTime = frame.context().frameTime()
4234
};

Runtime/ui/renderer/compositeCanvas/flow/picture_layer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public override void preroll(PrerollContext context, Matrix3 matrix) {
3838
ctm[5] = ctm[5].alignToPixel(context.devicePixelRatio);
3939

4040
this._rasterCacheResult = context.rasterCache.getPrerolledImage(
41-
this._picture, ctm, context.devicePixelRatio, context.antiAliasing, this._isComplex,
41+
this._picture, ctm, context.devicePixelRatio, this._isComplex,
4242
this._willChange);
4343
}
4444
else {

0 commit comments

Comments
 (0)