20 std::optional<MipFilter> mip_filter = std::nullopt) {
21 if (!mip_filter.has_value()) {
22 switch (minmag_filter) {
23 case MinMagFilter::kNearest:
25 case MinMagFilter::kLinear:
31 switch (mip_filter.value()) {
32 case MipFilter::kNearest:
33 switch (minmag_filter) {
34 case MinMagFilter::kNearest:
35 return GL_NEAREST_MIPMAP_NEAREST;
36 case MinMagFilter::kLinear:
37 return GL_LINEAR_MIPMAP_NEAREST;
39 case MipFilter::kLinear:
40 switch (minmag_filter) {
41 case MinMagFilter::kNearest:
42 return GL_NEAREST_MIPMAP_LINEAR;
43 case MinMagFilter::kLinear:
44 return GL_LINEAR_MIPMAP_LINEAR;
51 bool supports_decal_sampler_address_mode) {
53 case SamplerAddressMode::kClampToEdge:
54 return GL_CLAMP_TO_EDGE;
55 case SamplerAddressMode::kRepeat:
57 case SamplerAddressMode::kMirror:
58 return GL_MIRRORED_REPEAT;
59 case SamplerAddressMode::kDecal:
60 if (supports_decal_sampler_address_mode) {
63 return GL_CLAMP_TO_EDGE;
71 if (
texture.NeedsMipmapGeneration()) {
73 <<
"Texture mip count is > 1, but the mipmap has not been generated. "
74 "Texture can not be sampled safely.";
83 const auto& desc = GetDescriptor();
85 std::optional<MipFilter> mip_filter = std::nullopt;
86 if (
texture.GetTextureDescriptor().mip_count > 1) {
87 mip_filter = desc.mip_filter;
90 gl.TexParameteri(*
target, GL_TEXTURE_MIN_FILTER,
91 ToParam(desc.min_filter, mip_filter));
92 gl.TexParameteri(*
target, GL_TEXTURE_MAG_FILTER,
ToParam(desc.mag_filter));
94 const auto supports_decal_mode =
95 gl.GetCapabilities()->SupportsDecalSamplerAddressMode();
100 ToAddressMode(desc.height_address_mode, supports_decal_mode);
102 gl.TexParameteri(*
target, GL_TEXTURE_WRAP_S, wrap_s);
103 gl.TexParameteri(*
target, GL_TEXTURE_WRAP_T, wrap_t);
108 const GLfloat border_color[4] = {0.0f, 0.0f, 0.0f, 0.0f};