From 10496badaa84d6a999f24a25646fe8217ded6a15 Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Tue, 23 Jul 2019 09:38:32 +0700 Subject: [PATCH] remove unsupported mipmap and cubemap filtration options --- headers/enduro2d/core/render.hpp | 11 ++------ sources/enduro2d/core/render.cpp | 15 ++--------- .../core/render_impl/render_opengl.cpp | 16 +---------- .../core/render_impl/render_opengl_base.cpp | 6 +---- .../enduro2d/high/assets/material_asset.cpp | 27 ++----------------- untests/bin/library/material.json | 5 ++-- untests/sources/untests_core/render.cpp | 4 +-- untests/sources/untests_high/library.cpp | 3 +-- 8 files changed, 12 insertions(+), 75 deletions(-) diff --git a/headers/enduro2d/core/render.hpp b/headers/enduro2d/core/render.hpp index 34820a83..cdafeb1c 100644 --- a/headers/enduro2d/core/render.hpp +++ b/headers/enduro2d/core/render.hpp @@ -426,11 +426,7 @@ namespace e2d enum class sampler_min_filter : u8 { nearest, - linear, - nearest_mipmap_nearest, - linear_mipmap_nearest, - nearest_mipmap_linear, - linear_mipmap_linear + linear }; enum class sampler_mag_filter : u8 { @@ -585,7 +581,6 @@ namespace e2d sampler_state& wrap(sampler_wrap st) noexcept; sampler_state& s_wrap(sampler_wrap s) noexcept; sampler_state& t_wrap(sampler_wrap t) noexcept; - sampler_state& r_wrap(sampler_wrap t) noexcept; sampler_state& filter(sampler_min_filter min, sampler_mag_filter mag) noexcept; sampler_state& min_filter(sampler_min_filter min) noexcept; @@ -595,7 +590,6 @@ namespace e2d sampler_wrap s_wrap() const noexcept; sampler_wrap t_wrap() const noexcept; - sampler_wrap r_wrap() const noexcept; sampler_min_filter min_filter() const noexcept; sampler_mag_filter mag_filter() const noexcept; @@ -603,8 +597,7 @@ namespace e2d texture_ptr texture_; sampler_wrap s_wrap_ = sampler_wrap::repeat; sampler_wrap t_wrap_ = sampler_wrap::repeat; - sampler_wrap r_wrap_ = sampler_wrap::repeat; - sampler_min_filter min_filter_ = sampler_min_filter::nearest_mipmap_linear; + sampler_min_filter min_filter_ = sampler_min_filter::linear; sampler_mag_filter mag_filter_ = sampler_mag_filter::linear; }; diff --git a/sources/enduro2d/core/render.cpp b/sources/enduro2d/core/render.cpp index 8a79b5ad..d837acd4 100644 --- a/sources/enduro2d/core/render.cpp +++ b/sources/enduro2d/core/render.cpp @@ -26,7 +26,7 @@ namespace {"depth24", 24, false, true, false, pixel_declaration::pixel_type::depth24, false, v2u(1)}, {"depth32", 32, false, true, false, pixel_declaration::pixel_type::depth32, false, v2u(1)}, {"depth24_stencil8", 32, false, true, true, pixel_declaration::pixel_type::depth24_stencil8, false, v2u(1)}, - + {"g8", 8, true, false, false, pixel_declaration::pixel_type::g8, false, v2u(1)}, {"ga8", 16, true, false, false, pixel_declaration::pixel_type::ga8, false, v2u(1)}, {"rgb8", 24, true, false, false, pixel_declaration::pixel_type::rgb8, false, v2u(1)}, @@ -163,7 +163,7 @@ namespace e2d std::size_t pixel_declaration::bits_per_pixel() const noexcept { return get_pixel_type_description(type_).bits_per_pixel; } - + v2u pixel_declaration::compressed_block_size() const noexcept { return get_pixel_type_description(type_).block_size; } @@ -654,7 +654,6 @@ namespace e2d render::sampler_state& render::sampler_state::wrap(sampler_wrap st) noexcept { s_wrap(st); t_wrap(st); - r_wrap(st); return *this; } @@ -668,11 +667,6 @@ namespace e2d return *this; } - render::sampler_state& render::sampler_state::r_wrap(sampler_wrap r) noexcept { - r_wrap_ = r; - return *this; - } - render::sampler_state& render::sampler_state::filter(sampler_min_filter min, sampler_mag_filter mag) noexcept { min_filter(min); mag_filter(mag); @@ -701,10 +695,6 @@ namespace e2d return t_wrap_; } - render::sampler_wrap render::sampler_state::r_wrap() const noexcept { - return r_wrap_; - } - render::sampler_min_filter render::sampler_state::min_filter() const noexcept { return min_filter_; } @@ -1239,7 +1229,6 @@ namespace e2d return l.texture() == r.texture() && l.s_wrap() == r.s_wrap() && l.t_wrap() == r.t_wrap() - && l.r_wrap() == r.r_wrap() && l.min_filter() == r.min_filter() && l.mag_filter() == r.mag_filter(); } diff --git a/sources/enduro2d/core/render_impl/render_opengl.cpp b/sources/enduro2d/core/render_impl/render_opengl.cpp index 8d003ea0..a1e667d0 100644 --- a/sources/enduro2d/core/render_impl/render_opengl.cpp +++ b/sources/enduro2d/core/render_impl/render_opengl.cpp @@ -136,10 +136,6 @@ namespace texture_id.target(), GL_TEXTURE_WRAP_T, convert_sampler_wrap(sampler.t_wrap()))); - GL_CHECK_CODE(debug, glTexParameteri( - texture_id.target(), - GL_TEXTURE_WRAP_R, - convert_sampler_wrap(sampler.r_wrap()))); GL_CHECK_CODE(debug, glTexParameteri( texture_id.target(), GL_TEXTURE_MIN_FILTER, @@ -544,16 +540,6 @@ namespace e2d convert_image_data_format_to_external_data_type(image.format()), image.data().data())); } - #if E2D_RENDER_MODE == E2D_RENDER_MODE_OPENGL - GL_CHECK_CODE(state_->dbg(), glTexParameteri( - id.target(), - GL_TEXTURE_MAX_LEVEL, - 0)); - GL_CHECK_CODE(state_->dbg(), glTexParameteri( - id.target(), - GL_TEXTURE_BASE_LEVEL, - 0)); - #endif }); return std::make_shared( @@ -972,7 +958,7 @@ namespace e2d return *this; } - + render& render::update_buffer( const index_buffer_ptr& ibuffer, buffer_view indices, diff --git a/sources/enduro2d/core/render_impl/render_opengl_base.cpp b/sources/enduro2d/core/render_impl/render_opengl_base.cpp index d5a15088..469dae04 100644 --- a/sources/enduro2d/core/render_impl/render_opengl_base.cpp +++ b/sources/enduro2d/core/render_impl/render_opengl_base.cpp @@ -759,7 +759,7 @@ namespace e2d::opengl DEFINE_CASE(depth24, GL_DEPTH_COMPONENT24); DEFINE_CASE(depth32, GL_DEPTH_COMPONENT32); DEFINE_CASE(depth24_stencil8, GL_DEPTH24_STENCIL8); - + DEFINE_CASE(g8, GL_ALPHA); DEFINE_CASE(ga8, GL_LUMINANCE_ALPHA); DEFINE_CASE(rgb8, GL_RGB); @@ -909,10 +909,6 @@ namespace e2d::opengl switch ( f ) { DEFINE_CASE(nearest, GL_NEAREST); DEFINE_CASE(linear, GL_LINEAR); - DEFINE_CASE(nearest_mipmap_nearest, GL_NEAREST_MIPMAP_NEAREST); - DEFINE_CASE(linear_mipmap_nearest, GL_LINEAR_MIPMAP_NEAREST); - DEFINE_CASE(nearest_mipmap_linear, GL_NEAREST_MIPMAP_LINEAR); - DEFINE_CASE(linear_mipmap_linear, GL_LINEAR_MIPMAP_LINEAR); default: E2D_ASSERT_MSG(false, "unexpected sampler min filter"); return 0; diff --git a/sources/enduro2d/high/assets/material_asset.cpp b/sources/enduro2d/high/assets/material_asset.cpp index 918a4933..245aa798 100644 --- a/sources/enduro2d/high/assets/material_asset.cpp +++ b/sources/enduro2d/high/assets/material_asset.cpp @@ -179,8 +179,7 @@ namespace "additionalProperties" : false, "properties" : { "s" : { "$ref" : "#/definitions/sampler_wrap" }, - "t" : { "$ref" : "#/definitions/sampler_wrap" }, - "r" : { "$ref" : "#/definitions/sampler_wrap" } + "t" : { "$ref" : "#/definitions/sampler_wrap" } } }, { "$ref" : "#/definitions/sampler_wrap" @@ -333,11 +332,7 @@ namespace "type" : "string", "enum" : [ "nearest", - "linear", - "nearest_mipmap_nearest", - "linear_mipmap_nearest", - "nearest_mipmap_linear", - "linear_mipmap_linear" + "linear" ] } } @@ -471,10 +466,6 @@ namespace #define DEFINE_IF(x) if ( str == #x ) { filter = render::sampler_min_filter::x; return true; } DEFINE_IF(nearest); DEFINE_IF(linear); - DEFINE_IF(nearest_mipmap_nearest); - DEFINE_IF(linear_mipmap_nearest); - DEFINE_IF(nearest_mipmap_linear); - DEFINE_IF(linear_mipmap_linear); #undef DEFINE_IF return false; } @@ -483,10 +474,6 @@ namespace #define DEFINE_IF(x,y) if ( str == #x ) { filter = render::sampler_mag_filter::y; return true; } DEFINE_IF(nearest, nearest); DEFINE_IF(linear, linear); - DEFINE_IF(nearest_mipmap_nearest, nearest); - DEFINE_IF(linear_mipmap_nearest, linear); - DEFINE_IF(nearest_mipmap_linear, nearest); - DEFINE_IF(linear_mipmap_linear, linear); #undef DEFINE_IF return false; } @@ -555,16 +542,6 @@ namespace E2D_ASSERT_MSG(false, "unexpected sampler wrap"); } } - - if ( wrap_json.HasMember("r") ) { - E2D_ASSERT(wrap_json["r"].IsString()); - auto wrap = content.r_wrap(); - if ( parse_sampler_wrap(wrap_json["r"].GetString(), wrap) ) { - content.r_wrap(wrap); - } else { - E2D_ASSERT_MSG(false, "unexpected sampler wrap"); - } - } } else if ( wrap_json.IsString() ) { auto wrap = content.s_wrap(); if ( parse_sampler_wrap(wrap_json.GetString(), wrap) ) { diff --git a/untests/bin/library/material.json b/untests/bin/library/material.json index c0429e3f..da24ff5e 100644 --- a/untests/bin/library/material.json +++ b/untests/bin/library/material.json @@ -55,11 +55,10 @@ "texture" : "image.png", "wrap" : { "s" : "clamp", - "t" : "repeat", - "r" : "mirror" + "t" : "repeat" }, "filter" : { - "min" : "linear_mipmap_linear", + "min" : "linear", "mag" : "linear" } }], diff --git a/untests/sources/untests_core/render.cpp b/untests/sources/untests_core/render.cpp index 07c93118..bcf3a3c3 100644 --- a/untests/sources/untests_core/render.cpp +++ b/untests/sources/untests_core/render.cpp @@ -33,8 +33,7 @@ TEST_CASE("render"){ REQUIRE_FALSE(ss.texture()); REQUIRE(ss.s_wrap() == render::sampler_wrap::repeat); REQUIRE(ss.t_wrap() == render::sampler_wrap::repeat); - REQUIRE(ss.r_wrap() == render::sampler_wrap::repeat); - REQUIRE(ss.min_filter() == render::sampler_min_filter::nearest_mipmap_linear); + REQUIRE(ss.min_filter() == render::sampler_min_filter::linear); REQUIRE(ss.mag_filter() == render::sampler_mag_filter::linear); } { @@ -43,7 +42,6 @@ TEST_CASE("render"){ .filter(render::sampler_min_filter::linear, render::sampler_mag_filter::nearest); REQUIRE(ss.s_wrap() == render::sampler_wrap::clamp); REQUIRE(ss.t_wrap() == render::sampler_wrap::clamp); - REQUIRE(ss.r_wrap() == render::sampler_wrap::clamp); REQUIRE(ss.min_filter() == render::sampler_min_filter::linear); REQUIRE(ss.mag_filter() == render::sampler_mag_filter::nearest); } diff --git a/untests/sources/untests_high/library.cpp b/untests/sources/untests_high/library.cpp index 57796782..316eba4d 100644 --- a/untests/sources/untests_high/library.cpp +++ b/untests/sources/untests_high/library.cpp @@ -264,8 +264,7 @@ TEST_CASE("library"){ REQUIRE(sampler); REQUIRE(sampler->s_wrap() == render::sampler_wrap::clamp); REQUIRE(sampler->t_wrap() == render::sampler_wrap::repeat); - REQUIRE(sampler->r_wrap() == render::sampler_wrap::mirror); - REQUIRE(sampler->min_filter() == render::sampler_min_filter::linear_mipmap_linear); + REQUIRE(sampler->min_filter() == render::sampler_min_filter::linear); REQUIRE(sampler->mag_filter() == render::sampler_mag_filter::linear); REQUIRE(texture_res->content() == sampler->texture()); }