[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[Impeller] change default sampler descriptor to use nearest mip level and remove kNone" #40481

Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion impeller/aiks/aiks_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ TEST_P(AiksTest, CanRenderTiledTexture) {
Entity::TileMode::kClamp, Entity::TileMode::kRepeat,
Entity::TileMode::kMirror, Entity::TileMode::kDecal};
const char* mip_filter_names[] = {"None", "Nearest", "Linear"};
const MipFilter mip_filters[] = {MipFilter::kNearest, MipFilter::kLinear};
const MipFilter mip_filters[] = {MipFilter::kNone, MipFilter::kNearest,
MipFilter::kLinear};
const char* min_mag_filter_names[] = {"Nearest", "Linear"};
const MinMagFilter min_mag_filters[] = {MinMagFilter::kNearest,
MinMagFilter::kLinear};
Expand Down
2 changes: 1 addition & 1 deletion impeller/entity/contents/text_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static bool CommonRender(
sampler_desc.min_filter = MinMagFilter::kLinear;
sampler_desc.mag_filter = MinMagFilter::kLinear;
}
sampler_desc.mip_filter = MipFilter::kNearest;
sampler_desc.mip_filter = MipFilter::kNone;

typename FS::FragInfo frag_info;
frag_info.text_color = ToVector(color.Premultiply());
Expand Down
34 changes: 12 additions & 22 deletions impeller/renderer/backend/gles/sampler_gles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// found in the LICENSE file.

#include "impeller/renderer/backend/gles/sampler_gles.h"
#include <iostream>

#include "impeller/renderer/backend/gles/formats_gles.h"
#include "impeller/renderer/backend/gles/proc_table_gles.h"
Expand All @@ -20,19 +19,15 @@ bool SamplerGLES::IsValid() const {
return true;
}

static GLint ToParam(MinMagFilter minmag_filter,
std::optional<MipFilter> mip_filter = std::nullopt) {
if (!mip_filter.has_value()) {
switch (minmag_filter) {
case MinMagFilter::kNearest:
return GL_NEAREST;
case MinMagFilter::kLinear:
return GL_LINEAR;
}
FML_UNREACHABLE();
}

switch (mip_filter.value()) {
static GLint ToParam(MinMagFilter minmag_filter, MipFilter mip_filter) {
switch (mip_filter) {
case MipFilter::kNone:
switch (minmag_filter) {
case MinMagFilter::kNearest:
return GL_NEAREST;
case MinMagFilter::kLinear:
return GL_LINEAR;
}
case MipFilter::kNearest:
switch (minmag_filter) {
case MinMagFilter::kNearest:
Expand Down Expand Up @@ -74,17 +69,12 @@ bool SamplerGLES::ConfigureBoundTexture(const TextureGLES& texture,
if (!target.has_value()) {
return false;
}
const auto& desc = GetDescriptor();

std::optional<MipFilter> mip_filter = std::nullopt;
if (texture.GetTextureDescriptor().mip_count > 1) {
mip_filter = desc.mip_filter;
}

const auto& desc = GetDescriptor();
gl.TexParameteri(target.value(), GL_TEXTURE_MIN_FILTER,
ToParam(desc.min_filter, mip_filter));
ToParam(desc.min_filter, desc.mip_filter));
gl.TexParameteri(target.value(), GL_TEXTURE_MAG_FILTER,
ToParam(desc.mag_filter));
ToParam(desc.mag_filter, MipFilter::kNone));
gl.TexParameteri(target.value(), GL_TEXTURE_WRAP_S,
ToAddressMode(desc.width_address_mode));
gl.TexParameteri(target.value(), GL_TEXTURE_WRAP_T,
Expand Down
2 changes: 2 additions & 0 deletions impeller/renderer/backend/metal/formats_mtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ constexpr MTLSamplerMinMagFilter ToMTLSamplerMinMagFilter(MinMagFilter filter) {

constexpr MTLSamplerMipFilter ToMTLSamplerMipFilter(MipFilter filter) {
switch (filter) {
case MipFilter::kNone:
return MTLSamplerMipFilterNotMipmapped;
case MipFilter::kNearest:
return MTLSamplerMipFilterNearest;
case MipFilter::kLinear:
Expand Down
2 changes: 2 additions & 0 deletions impeller/renderer/backend/vulkan/formats_vk.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ constexpr vk::SamplerMipmapMode ToVKSamplerMipmapMode(MipFilter filter) {
return vk::SamplerMipmapMode::eNearest;
case MipFilter::kLinear:
return vk::SamplerMipmapMode::eLinear;
case MipFilter::kNone:
return vk::SamplerMipmapMode::eNearest;
}

FML_UNREACHABLE();
Expand Down
2 changes: 2 additions & 0 deletions impeller/renderer/formats.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ enum class MinMagFilter {
};

enum class MipFilter {
/// Always sample from mip level 0. Other mip levels are ignored.
kNone,
/// Sample from the nearest mip level.
kNearest,
/// Sample from the two nearest mip levels and linearly interpolate between
Expand Down
7 changes: 4 additions & 3 deletions impeller/renderer/renderer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -724,14 +724,15 @@ TEST_P(RendererTest, CanGenerateMipmaps) {

bool first_frame = true;
Renderer::RenderCallback callback = [&](RenderTarget& render_target) {
const char* mip_filter_names[] = {"Nearest", "Linear"};
const MipFilter mip_filters[] = {MipFilter::kNearest, MipFilter::kLinear};
const char* mip_filter_names[] = {"None", "Nearest", "Linear"};
const MipFilter mip_filters[] = {MipFilter::kNone, MipFilter::kNearest,
MipFilter::kLinear};
const char* min_filter_names[] = {"Nearest", "Linear"};
const MinMagFilter min_filters[] = {MinMagFilter::kNearest,
MinMagFilter::kLinear};

// UI state.
static int selected_mip_filter = 1;
static int selected_mip_filter = 2;
static int selected_min_filter = 0;
static float lod = 4.5;

Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/sampler_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Context;
struct SamplerDescriptor final : public Comparable<SamplerDescriptor> {
MinMagFilter min_filter = MinMagFilter::kNearest;
MinMagFilter mag_filter = MinMagFilter::kNearest;
MipFilter mip_filter = MipFilter::kNearest;
MipFilter mip_filter = MipFilter::kNone;

SamplerAddressMode width_address_mode = SamplerAddressMode::kClampToEdge;
SamplerAddressMode height_address_mode = SamplerAddressMode::kClampToEdge;
Expand Down
2 changes: 1 addition & 1 deletion impeller/scene/geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void SkinnedVertexBufferGeometry::BindToCommand(
SamplerDescriptor sampler_desc;
sampler_desc.min_filter = MinMagFilter::kNearest;
sampler_desc.mag_filter = MinMagFilter::kNearest;
sampler_desc.mip_filter = MipFilter::kNearest;
sampler_desc.mip_filter = MipFilter::kNone;
sampler_desc.width_address_mode = SamplerAddressMode::kRepeat;
sampler_desc.label = "NN Repeat";

Expand Down