MCPcopy Create free account
hub / github.com/dfranx/ShaderDebugger / Sample

Method Sample

src/Texture.cpp:46–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44 memcpy(Data[0] + i * 4, (void*)glm::value_ptr(val), sizeof(float) * 4);
45 }
46 glm::vec4 Texture::Sample(float u, float v, float w, float mip)
47 {
48 // TODO: mipmaps
49 // TODO: filtering
50 // TODO: wrap
51
52 if (m_isInvalid())
53 return glm::vec4(1.0f);
54
55 // kind of "nearest" filtering
56 int x = u * Width;
57 int y = v * Height;
58 int z = w * Depth;
59 int m = mip * MipmapLevels;
60
61 // clamp (TODO: wrap)
62 x = std::min(Width, std::max(0, x));
63 y = std::min(Height, std::max(0, y));
64 z = std::min(Depth, std::max(0, z));
65
66 // clamp mipmap level
67 m = std::min(MipmapLevels, std::max(0, m));
68
69 float* mem = &Data[m][(x + Width * (y + Depth * z)) * 4];
70
71 return glm::vec4(mem[0], mem[1], mem[2], mem[3]);
72 }
73 glm::vec4 Texture::TexelFetch(int u, int v, int w, int mip)
74 {
75 if (m_isInvalid())

Callers 11

lib_hlsl_Texture_SampleFunction · 0.80
lib_glsl_textureFunction · 0.80
lib_glsl_textureGatherFunction · 0.80
lib_glsl_textureLodFunction · 0.80
lib_glsl_textureOffsetFunction · 0.80
lib_glsl_textureProjFunction · 0.80
lib_glsl_textureProjLodFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected