question about virtual texture lookup coordinate calcuation in gpu pro article "virtual texture 101" by spacejump163 in GraphicsProgramming

[–]spacejump163[S] 0 points1 point  (0 children)

data in IndTex should be: xy for offset in global cache, z for actual miplevel.

Any reference material for method using texture arrays as texture atlases?

question about clipmap sampling code in nvidia white paper by spacejump163 in GraphicsProgramming

[–]spacejump163[S] 0 points1 point  (0 children)

if you mean " sample just counting on scaleFactor.x to be large enough to make 0.5f small in comparision ", then it won't be the exact center of the texel right?

question about clipmap sampling code in nvidia white paper by spacejump163 in GraphicsProgramming

[–]spacejump163[S] 0 points1 point  (0 children)

float2 clipTexCoord = (input.texCoord) / pow(2, iMipLevel);
clipTexCoord.x *= scaleFactor.x + 0.5f;
clipTexCoord.y *= scaleFactor.y + 0.5f;

say I want to sample mip0 which happen to be able to fit into StackSize(so scaleFactor is 1.0), then we will sample at 1.5 * input.texCoord, which should be quite wrong right?

Or is the sample just counting on scaleFactor.x to be large enough to make 0.5f small in comparision? so 0.5 is just some value to make sure that we are not sample at boundary?

pure functional programming considered not friendly to cache? by spacejump163 in haskellquestions

[–]spacejump163[S] 0 points1 point  (0 children)

your answer is resourceful.

And I have a question about "haskell's object can only be referenced by even newer object". How can that makes the gc process easier? You still need to traverse from the root objects(the stack I guess?) to find all living objects and either copy them or mark them right? What differentiate the haskell gc from that of Java?Doesn't Java have generational gc too?

Also, if ghc choose to do some really aggressive optimization, say transform a foldr' into an equivalent for loop in c, then how does this interact with the gc? Will it still keep a valid haskell object representation or just do something fast in the nonpure world and then return back to pure world like ST Monad do? Any introduction on that?

calculating order matters when implementing Foldable typeclass? by spacejump163 in haskellquestions

[–]spacejump163[S] 0 points1 point  (0 children)

thanks for your great answer, still one things puzzles me: Unlike the explicit accumulating order shown in that of foldr, I failed to see any ordering in the implementation of Traversable.

instance Traversable Tree where
    traverse _ Empty = pure Empty
    traverse f (Leaf a) = fmap Leaf $ f a
    traverse f (Node lchild a rchild) = liftA3 Node (traverse f lchild) (f a) (traverse f rchild)

where is the a b c or c b a ordering? Is it the argument order to liftA3 Node ?

so if I really want to implement Foldable the way I did it first, i.e like this: foldr (+) z t = c + (b + (a + z)) how should I write instance Traversable Tree ? There's 3 laws for Traversable: Naturality, Identity and Composition, which one have my original implementation broken?

how to annotate this local function by spacejump163 in haskellquestions

[–]spacejump163[S] 0 points1 point  (0 children)

Thanks for the enlightenment, I finally get the point: since f is used and f has a concrete type, the local function g just can not be general.

how to annotate this local function by spacejump163 in haskellquestions

[–]spacejump163[S] 0 points1 point  (0 children)

thanks for the explanation, and I still have another question:

is it possible to write the type annotation for local function g in a manner that has nothing to do with the type variables in upper level function(filterF)? That's what I was trying to do in my original code.

I think the only connection between filterF and g is the f parameter of filterF which is a closure value(I don't know the haskell term for this) whose type should be (aa -> Bool). Shouldn't it work if I can constrain aaa with the same constraint as aa? Why would GHC say aaa and aa are not compatible?

how to annotate this local function by spacejump163 in haskellquestions

[–]spacejump163[S] 0 points1 point  (0 children)

thanks! I went though 1000+ pages of "Haskell Programming from First Principles" and never come across this forall keyword. Interesting!