Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@dnfield
Copy link
Contributor

@dnfield dnfield commented Aug 26, 2022

Fixes flutter/flutter#109346

This doesn't really do anything yet.

still left:

  • Update impellerc to reflect right types when working with compute shaders
  • Write some tests
  • Figure out how to wire this up to the Context.

@dnfield
Copy link
Contributor Author

dnfield commented Aug 26, 2022

I guess it's .. kind of wired to context already, but will have to test to make sure it's working. Need impellerc in line first.

Copy link
Member

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So exciting! Everything looks great. I don't think we should attempt compute for ES though.


// |CommandBuffer|
std::shared_ptr<ComputePass> CommandBufferGLES::OnCreateComputePass() const {
if (!IsValid()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put the validity checks in the base class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if (!IsValid()) {
return nullptr;
}
// TODO(dnfield): implement compute for GLES.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't possible in GLES (anything < 3.2). So I think its best to just return nullptr with a comment here saying that compute passes aren't supported.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the idea that >= 3.2 will just have Vulkan anyway?

I was assuming we could use extension methods to check if it's available and if so, use them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Have a clear separation between a modern and legacy renderer with little effort made to update the legacy one.

fragment_bindings.buffers[slot.binding] = {&metadata, view};
return true;
case ShaderStage::kCompute:
FML_DCHECK(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FML_UNREACHABLE for WIP stuff so we don't miss it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@chinmaygarde chinmaygarde added the Work in progress (WIP) Not ready (yet) for review! label Aug 27, 2022
@chinmaygarde chinmaygarde changed the title [Impeller] Compute shader support (WIP) [Impeller] Compute shader support Aug 27, 2022
@dnfield
Copy link
Contributor Author

dnfield commented Aug 27, 2022

Vulkan is broken, I'll fix that up after I fix impellerc.

Copy link
Member

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet! Can wait to tinker on this.

}

// TODO(dnfield): Support non-serial dispatch type on higher iOS versions.
auto compute_command_encoder = [buffer_ computeCommandEncoder];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to support this use cases using just creating multiple compute passes. This, instead of relying on the Metal API feature. I think we can get rid of this TODO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My assumption is that Vulkan would have similar API for collecting compute information, using whatever necessary barriers, whether for use in a subsequent vertex shader or back on the host.

auto_pop_debug_marker.Release();
}

// TODO(dnfield): update the compute pipeline descriptor so that it can set
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File issues (in a later patch is fine) for these and cross reference them here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and elsewhere.

[encoder dispatchThreadgroups:MTLSizeMake(32, 32, 1)
threadsPerThreadgroup:MTLSizeMake(32, 32, 1)];

// TODO(dnfield): add some kind of completion handling logic for reading
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, this would need the addition of fences/events as a separate API that allows for resource synchronization between not only compute passes but compute and render passes as well.

fragment_bindings.buffers[slot.binding] = {&metadata, view};
return true;
case ShaderStage::kCompute:
FML_UNREACHABLE();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps just a validation log that returns false?

const ShaderUniformSlot& slot,
const ShaderMetadata& metadata,
BufferView view) {
FML_DCHECK(stage == ShaderStage::kCompute);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a DCHECK that is all but useless for non-engine developers, just return false?

@chinmaygarde chinmaygarde removed the Work in progress (WIP) Not ready (yet) for review! label Aug 30, 2022
@chinmaygarde
Copy link
Member

@dnfield Per your comment in the chat thread, marking this as a non-draft.

@chinmaygarde chinmaygarde marked this pull request as ready for review August 30, 2022 20:03
@dnfield dnfield added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 31, 2022
@auto-submit
Copy link
Contributor

auto-submit bot commented Aug 31, 2022

  • The status or check suite Mac Unopt has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 31, 2022
@dnfield dnfield added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 31, 2022
@auto-submit auto-submit bot merged commit fb067ea into flutter:main Aug 31, 2022
@dnfield dnfield deleted the compute branch August 31, 2022 19:07
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 31, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 31, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 31, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 31, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 31, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 31, 2022
zanderso pushed a commit to flutter/flutter that referenced this pull request Sep 1, 2022
…110727)

* 5a1a855b2 Roll Clang from 41d4067d0b7c to 039b969b32b6 (flutter/engine#35840)

* 3a1d6a9b0 Roll Skia from e0b87738eca7 to 45fe3b5a6710 (9 revisions) (flutter/engine#35841)

* fb067eab7 [Impeller] Compute shader support (flutter/engine#35750)

* a53384841 Roll Dart SDK from 5a2737b71877 to fec63626f078 (2 revisions) (flutter/engine#35844)

* 3dc4e4971 roll CanvasKit to 0.36.1 (attempt 2) (flutter/engine#35839)

* 9b14b25eb Reland: Adds a reusable FragmentShader (flutter/engine#35846)

* ac34d3e63 [fuchsia] Workflow scripts. (flutter/engine#35822)

* f0f8d10b8 Revert "Roll Dart SDK from 5a2737b71877 to fec63626f078 (2 revisions) (#35844)" (flutter/engine#35849)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App e: impeller

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

[Impeller] Support compute passes/shaders.

2 participants