mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
graphicsdriver: Refactoring
This improved FPS on mobiles a little bit. Maybe now texture2D is called only when necessary, but not sure.
This commit is contained in:
parent
742bbb4ccd
commit
cbb0a1da95
@ -968,7 +968,7 @@ func TestImageStretch(t *testing.T) {
|
||||
want = color.RGBA{0xff, 0, 0, 0xff}
|
||||
}
|
||||
if got != want {
|
||||
t.Errorf("At(%d, %d) (i=%d): got: %#v, want: %#v", 0, i+j, i, got, want)
|
||||
t.Fatalf("At(%d, %d) (i=%d): got: %#v, want: %#v", 0, i+j, i, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,16 +120,15 @@ struct GetColorFromTexel;
|
||||
template<uint8_t address>
|
||||
struct GetColorFromTexel<FILTER_NEAREST, address> {
|
||||
inline float4 Do(VertexOut v, texture2d<float> texture, constant float2& source_size, float scale) {
|
||||
constexpr sampler texture_sampler(filter::nearest);
|
||||
|
||||
float2 p = AdjustTexelByAddress<address>(v.tex, v.tex_region);
|
||||
if (p.x < v.tex_region[0] ||
|
||||
p.y < v.tex_region[1] ||
|
||||
v.tex_region[2] <= p.x ||
|
||||
v.tex_region[3] <= p.y) {
|
||||
return 0.0;
|
||||
if (v.tex_region[0] <= p.x &&
|
||||
v.tex_region[1] <= p.y &&
|
||||
p.x < v.tex_region[2] &&
|
||||
p.y < v.tex_region[3]) {
|
||||
constexpr sampler texture_sampler(filter::nearest);
|
||||
return texture.sample(texture_sampler, p);
|
||||
}
|
||||
return texture.sample(texture_sampler, p);
|
||||
return 0.0;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -197,12 +197,12 @@ void main(void) {
|
||||
|
||||
#if defined(FILTER_NEAREST)
|
||||
pos = adjustTexelByAddress(pos, varying_tex_region);
|
||||
color = texture2D(texture, pos);
|
||||
if (pos.x < varying_tex_region[0] ||
|
||||
pos.y < varying_tex_region[1] ||
|
||||
varying_tex_region[2] <= pos.x ||
|
||||
varying_tex_region[3] <= pos.y) {
|
||||
color = vec4(0, 0, 0, 0);
|
||||
color = vec4(0, 0, 0, 0);
|
||||
if (varying_tex_region[0] <= pos.x &&
|
||||
varying_tex_region[1] <= pos.y &&
|
||||
pos.x < varying_tex_region[2] &&
|
||||
pos.y < varying_tex_region[3]) {
|
||||
color = texture2D(texture, pos);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user