@@ -144,23 +144,44 @@ static void PlaygroundKeyCallback(GLFWwindow* window,
144
144
return false ;
145
145
}
146
146
147
- TextureDescriptor color0_tex;
148
- color0_tex.format = PixelFormat::kB8G8R8A8UNormInt ;
149
- color0_tex.size = {
147
+ TextureDescriptor msaa_tex_desc;
148
+ msaa_tex_desc.type = TextureType::k2DMultisample;
149
+ msaa_tex_desc.sample_count = SampleCount::kCount4 ;
150
+ msaa_tex_desc.format = PixelFormat::kB8G8R8A8UNormInt ;
151
+ msaa_tex_desc.size = {
150
152
static_cast <ISize::Type>(current_drawable.texture .width ),
151
153
static_cast <ISize::Type>(current_drawable.texture .height )};
152
- color0_tex.usage = static_cast <uint64_t >(TextureUsage::kRenderTarget );
154
+ msaa_tex_desc.usage = static_cast <uint64_t >(TextureUsage::kRenderTarget );
155
+
156
+ auto msaa_tex =
157
+ renderer_.GetContext ()->GetPermanentsAllocator ()->CreateTexture (
158
+ StorageMode::kDeviceTransient , msaa_tex_desc);
159
+ if (!msaa_tex) {
160
+ FML_LOG (ERROR) << " Could not allocate MSAA resolve texture." ;
161
+ return false ;
162
+ }
163
+
164
+ msaa_tex->SetLabel (" PlaygroundMainColor4xMSAA" );
165
+
166
+ TextureDescriptor onscreen_tex_desc;
167
+ onscreen_tex_desc.format = PixelFormat::kB8G8R8A8UNormInt ;
168
+ onscreen_tex_desc.size = msaa_tex_desc.size ;
169
+ onscreen_tex_desc.usage =
170
+ static_cast <uint64_t >(TextureUsage::kRenderTarget );
153
171
154
172
ColorAttachment color0;
155
- color0.texture =
156
- std::make_shared<TextureMTL>(color0_tex, current_drawable.texture );
173
+ color0.texture = msaa_tex;
157
174
color0.clear_color = Color::DarkSlateGray ();
158
175
color0.load_action = LoadAction::kClear ;
159
- color0.store_action = StoreAction::kStore ;
176
+ color0.store_action = StoreAction::kMultisampleResolve ;
177
+ color0.resolve_texture = std::make_shared<TextureMTL>(
178
+ onscreen_tex_desc, current_drawable.texture );
160
179
161
180
TextureDescriptor stencil0_tex;
181
+ stencil0_tex.type = TextureType::k2DMultisample;
182
+ stencil0_tex.sample_count = SampleCount::kCount4 ;
162
183
stencil0_tex.format = PixelFormat::kD32FloatS8UNormInt ;
163
- stencil0_tex.size = color0_tex .size ;
184
+ stencil0_tex.size = msaa_tex_desc .size ;
164
185
stencil0_tex.usage =
165
186
static_cast <TextureUsageMask>(TextureUsage::kRenderTarget );
166
187
auto stencil_texture =
0 commit comments