Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add capability check.
  • Loading branch information
jonahwilliams committed Feb 13, 2024
commit e06eca853937377691d7605dfd31498806eeee63
2 changes: 1 addition & 1 deletion impeller/entity/shaders/glyph_atlas.frag
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ out f16vec4 frag_color;

void main() {
f16vec4 value = texture(glyph_atlas_sampler, v_uv);
frag_color = max(value.rrrr, value.aaaa) * v_text_color;
frag_color = vec4(max(value.r, value.a)) * v_text_color;
}
11 changes: 11 additions & 0 deletions impeller/renderer/backend/gles/capabilities_gles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "impeller/renderer/backend/gles/capabilities_gles.h"

#include "impeller/core/formats.h"
#include "impeller/renderer/backend/gles/proc_table_gles.h"

namespace impeller {
Expand Down Expand Up @@ -102,6 +103,12 @@ CapabilitiesGLES::CapabilitiesGLES(const ProcTableGLES& gl) {
num_shader_binary_formats = value;
}

if (desc->IsES()) {
default_glyph_atlas_format_ = PixelFormat::kA8UNormInt;
} else {
default_glyph_atlas_format_ = PixelFormat::kR8UNormInt;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jason-simmons I think this shoudl be enough to get desktop GL working.

}

supports_framebuffer_fetch_ = desc->HasExtension(kFramebufferFetchExt);

if (desc->HasExtension(kTextureBorderClampExt) ||
Expand Down Expand Up @@ -188,4 +195,8 @@ PixelFormat CapabilitiesGLES::GetDefaultDepthStencilFormat() const {
return PixelFormat::kD24UnormS8Uint;
}

PixelFormat CapabilitiesGLES::GetDefaultGlyphAtlasFormat() const {
return default_glyph_atlas_format_;
}

} // namespace impeller
6 changes: 6 additions & 0 deletions impeller/renderer/backend/gles/capabilities_gles.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <cstddef>

#include "impeller/base/backend_cast.h"
#include "impeller/core/formats.h"
#include "impeller/core/shader_types.h"
#include "impeller/geometry/size.h"
#include "impeller/renderer/capabilities.h"
Expand Down Expand Up @@ -116,11 +117,16 @@ class CapabilitiesGLES final
// |Capabilities|
PixelFormat GetDefaultDepthStencilFormat() const override;

// |Capabilities|
PixelFormat GetDefaultGlyphAtlasFormat() const override;

private:
bool supports_framebuffer_fetch_ = false;
bool supports_decal_sampler_address_mode_ = false;
bool supports_offscreen_msaa_ = false;
bool supports_implicit_msaa_ = false;

PixelFormat default_glyph_atlas_format_ = PixelFormat::kUnknown;
};

} // namespace impeller
Expand Down
1 change: 1 addition & 0 deletions impeller/renderer/backend/metal/context_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ static bool DeviceSupportsComputeSubgroups(id<MTLDevice> device) {
.SetSupportsComputeSubgroups(DeviceSupportsComputeSubgroups(device))
.SetSupportsReadFromResolve(true)
.SetSupportsDeviceTransientTextures(true)
.SetDefaultGlyphAtlasFormat(PixelFormat::kA8UNormInt)
.Build();
}

Expand Down
4 changes: 4 additions & 0 deletions impeller/renderer/backend/vulkan/capabilities_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -484,4 +484,8 @@ bool CapabilitiesVK::HasOptionalDeviceExtension(
optional_device_extensions_.end();
}

PixelFormat CapabilitiesVK::GetDefaultGlyphAtlasFormat() const {
return PixelFormat::kR8UNormInt;
}

} // namespace impeller
3 changes: 3 additions & 0 deletions impeller/renderer/backend/vulkan/capabilities_vk.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ class CapabilitiesVK final : public Capabilities,
// |Capabilities|
PixelFormat GetDefaultDepthStencilFormat() const override;

// |Capabilities|
PixelFormat GetDefaultGlyphAtlasFormat() const override;

private:
bool validations_enabled_ = false;
std::map<std::string, std::set<std::string>> exts_;
Expand Down
21 changes: 15 additions & 6 deletions impeller/renderer/capabilities_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,40 @@ CAPABILITY_TEST(SupportsDeviceTransientTextures, false);

TEST(CapabilitiesTest, DefaultColorFormat) {
auto defaults = CapabilitiesBuilder().Build();
ASSERT_EQ(defaults->GetDefaultColorFormat(), PixelFormat::kUnknown);
EXPECT_EQ(defaults->GetDefaultColorFormat(), PixelFormat::kUnknown);
auto mutated = CapabilitiesBuilder()
.SetDefaultColorFormat(PixelFormat::kB10G10R10A10XR)
.Build();
ASSERT_EQ(mutated->GetDefaultColorFormat(), PixelFormat::kB10G10R10A10XR);
EXPECT_EQ(mutated->GetDefaultColorFormat(), PixelFormat::kB10G10R10A10XR);
}

TEST(CapabilitiesTest, DefaultStencilFormat) {
auto defaults = CapabilitiesBuilder().Build();
ASSERT_EQ(defaults->GetDefaultStencilFormat(), PixelFormat::kUnknown);
EXPECT_EQ(defaults->GetDefaultStencilFormat(), PixelFormat::kUnknown);
auto mutated = CapabilitiesBuilder()
.SetDefaultStencilFormat(PixelFormat::kS8UInt)
.Build();
ASSERT_EQ(mutated->GetDefaultStencilFormat(), PixelFormat::kS8UInt);
EXPECT_EQ(mutated->GetDefaultStencilFormat(), PixelFormat::kS8UInt);
}

TEST(CapabilitiesTest, DefaultDepthStencilFormat) {
auto defaults = CapabilitiesBuilder().Build();
ASSERT_EQ(defaults->GetDefaultDepthStencilFormat(), PixelFormat::kUnknown);
EXPECT_EQ(defaults->GetDefaultDepthStencilFormat(), PixelFormat::kUnknown);
auto mutated = CapabilitiesBuilder()
.SetDefaultDepthStencilFormat(PixelFormat::kD32FloatS8UInt)
.Build();
ASSERT_EQ(mutated->GetDefaultDepthStencilFormat(),
EXPECT_EQ(mutated->GetDefaultDepthStencilFormat(),
PixelFormat::kD32FloatS8UInt);
}

TEST(CapabilitiesTest, DefaultGlyphAtlasFormat) {
auto defaults = CapabilitiesBuilder().Build();
EXPECT_EQ(defaults->GetDefaultGlyphAtlasFormat(), PixelFormat::kUnknown);
auto mutated = CapabilitiesBuilder()
.SetDefaultGlyphAtlasFormat(PixelFormat::kA8UNormInt)
.Build();
EXPECT_EQ(mutated->GetDefaultGlyphAtlasFormat(), PixelFormat::kA8UNormInt);
}

} // namespace testing
} // namespace impeller