From 2a156795c55d7b8bdce1dae27de4d43924a3b4ff Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 18 Oct 2009 16:34:44 -0500 Subject: [PATCH 1/4] update vshuffle docs --- basis/math/vectors/vectors-docs.factor | 31 ++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/basis/math/vectors/vectors-docs.factor b/basis/math/vectors/vectors-docs.factor index 7a9aff49b6..27940f9f6c 100644 --- a/basis/math/vectors/vectors-docs.factor +++ b/basis/math/vectors/vectors-docs.factor @@ -416,8 +416,12 @@ HELP: vbroadcast } ; HELP: vshuffle -{ $values { "u" "a SIMD array" } { "perm" "an array of integers" } { "v" "a SIMD array" } } -{ $description "Permutes the elements of a SIMD array. Duplicate entries are allowed in the permutation." } +{ $values { "u" "a SIMD array" } { "perm" "an array of integers, or a byte-array" } { "v" "a SIMD array" } } +{ $description "Permutes the elements of a SIMD array. Duplicate entries are allowed in the permutation. The " { $snippet "perm" } " argument can have one of two forms:" +{ $list +{ "A literal array of integers of the same length as the vector. This will perform a static, elementwise shuffle." } +{ "A byte array or SIMD vector of the same byte length as the vector. This will perform a variable bytewise shuffle." } +} } { $examples { $example "USING: alien.c-types math.vectors math.vectors.simd" "prettyprint ;" @@ -425,6 +429,29 @@ HELP: vshuffle "int-4{ 69 42 911 13 } { 1 3 2 3 } vshuffle ." "int-4{ 42 13 911 13 }" } + { $example + "USING: alien.c-types combinators math.vectors math.vectors.simd" + "namespaces prettyprint prettyprint.config ;" + "SIMDS: int uchar ;" + "IN: scratchpad" + "" + ": endian-swap ( size -- vector )" + " {" + " { 1 [ uchar-16{ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 } ] }" + " { 2 [ uchar-16{ 1 0 3 2 5 4 7 6 9 8 11 10 13 12 15 14 } ] }" + " { 4 [ uchar-16{ 3 2 1 0 7 6 5 4 11 10 9 8 15 14 13 12 } ] }" + " } case ;" + "" + "int-4{ HEX: 11223344 HEX: 11223344 HEX: 11223344 HEX: 11223344 }" + "4 endian-swap vshuffle" + "16 number-base [ . ] with-variable" + """int-4{ + HEX: 44332211 + HEX: 44332211 + HEX: 44332211 + HEX: 44332211 +}""" + } } ; HELP: norm-sq From 08768d0e2f233281b0aaa32846bb4d3d2691eab6 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 18 Oct 2009 18:31:38 -0500 Subject: [PATCH 2/4] gpu.render: factor out and make public a "bind-uniforms" word for binding a uniform-tuple to a program-instance independent of a render-set --- extra/gpu/render/render-docs.factor | 5 +++++ extra/gpu/render/render.factor | 19 +++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/extra/gpu/render/render-docs.factor b/extra/gpu/render/render-docs.factor index fdaa510e02..629a3ad662 100755 --- a/extra/gpu/render/render-docs.factor +++ b/extra/gpu/render/render-docs.factor @@ -226,6 +226,11 @@ HELP: render-set } } { $notes "User-created framebuffers require OpenGL 3.0 or one of the " { $snippet "GL_EXT_framebuffer_object" } " or " { $snippet "GL_ARB_framebuffer_object" } " extensions. Disabling rasterization requires OpenGL 3.0 or the " { $snippet "GL_EXT_transform_feedback" } " extension. Named output-attachment values are available in GLSL 1.30 or later, and GLSL 1.20 and earlier using the " { $snippet "GL_EXT_gpu_shader4" } " extension. Transform feedback requires OpenGL 3.0 or one of the " { $snippet "GL_EXT_transform_feedback" } " or " { $snippet "GL_ARB_transform_feedback" } " extensions." } ; +HELP: bind-uniforms +{ $values { "program-instance" program-instance } { "uniforms" uniform-tuple } } +{ $description "Binds the uniform shader parameters for " { $snippet "program-instance" } " using values from the given uniform tuple." } +{ $notes "The " { $link render } " word uses this word. Calling this word directly is only necessary if uniform parameters need to be bound independently of a " { $snippet "render" } " operation." } ; + { render render-set } related-words HELP: texture-uniform diff --git a/extra/gpu/render/render.factor b/extra/gpu/render/render.factor index 4f2437c0c1..5f92cf3dbf 100644 --- a/extra/gpu/render/render.factor +++ b/extra/gpu/render/render.factor @@ -168,12 +168,12 @@ M: multi-index-elements render-vertex-indexes : (bind-texture-unit) ( texture texture-unit -- ) swap [ GL_TEXTURE0 + glActiveTexture ] [ bind-texture drop ] bi* ; inline -GENERIC: bind-uniform-textures ( program-instance uniform-tuple -- ) -GENERIC: bind-uniforms ( program-instance uniform-tuple -- ) +GENERIC: (bind-uniform-textures) ( program-instance uniform-tuple -- ) +GENERIC: (bind-uniforms) ( program-instance uniform-tuple -- ) -M: uniform-tuple bind-uniform-textures +M: uniform-tuple (bind-uniform-textures) 2drop ; -M: uniform-tuple bind-uniforms +M: uniform-tuple (bind-uniforms) 2drop ; : uniform-slot-type ( uniform -- type ) @@ -363,7 +363,7 @@ DEFER: [bind-uniform-tuple] :: [bind-uniforms] ( superclass uniforms -- quot ) superclass "uniform-tuple-texture-units" word-prop 0 or :> first-texture-unit - superclass \ bind-uniforms method :> next-method + superclass \ (bind-uniforms) method :> next-method first-texture-unit uniforms "" [bind-uniform-tuple] nip :> bind-quot { 2dup next-method } bind-quot [ ] append-as ; @@ -371,10 +371,10 @@ DEFER: [bind-uniform-tuple] : define-uniform-tuple-methods ( class superclass uniforms -- ) [ 2drop - [ \ bind-uniform-textures create-method-in ] + [ \ (bind-uniform-textures) create-method-in ] [ [bind-uniform-textures] ] bi define ] [ - [ \ bind-uniforms create-method-in ] 2dip + [ \ (bind-uniforms) create-method-in ] 2dip [bind-uniforms] define ] 3bi ; @@ -481,12 +481,15 @@ TUPLE: render-set : 3 ( x y z quot-assoc -- render-set ) render-set swap 3make-tuple ; inline +: bind-uniforms ( program-instance uniforms -- ) + [ (bind-uniform-textures) ] [ (bind-uniforms) ] 2bi ; inline + : render ( render-set -- ) { [ vertex-array>> program-instance>> handle>> glUseProgram ] [ [ vertex-array>> program-instance>> ] [ uniforms>> ] bi - [ bind-uniform-textures ] [ bind-uniforms ] 2bi + bind-uniforms ] [ framebuffer>> From fca550d567943190b43788b59be2c0281733d3fa Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 18 Oct 2009 21:25:09 -0500 Subject: [PATCH 3/4] math.vectors.conversion docs --- .../vectors/conversion/conversion-docs.factor | 75 +++++++++++++++++++ basis/math/vectors/vectors-docs.factor | 15 ++-- 2 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 basis/math/vectors/conversion/conversion-docs.factor diff --git a/basis/math/vectors/conversion/conversion-docs.factor b/basis/math/vectors/conversion/conversion-docs.factor new file mode 100644 index 0000000000..9fe5ac4c17 --- /dev/null +++ b/basis/math/vectors/conversion/conversion-docs.factor @@ -0,0 +1,75 @@ +! (c)2009 Joe Groff bsd license +USING: classes help.markup help.syntax kernel quotations ; +IN: math.vectors.conversion + +HELP: bad-vconvert +{ $values + { "from-type" "a SIMD type" } { "to-type" "a SIMD type" } +} +{ $description "This error is thrown when " { $link vconvert } " is given two SIMD types it cannot directly convert." } ; + +HELP: bad-vconvert-input +{ $values + { "value" object } { "expected-type" class } +} +{ $description "This error is thrown when an input to " { $link vconvert } " does not match the expected " { $snippet "from-type" } "." } ; + +{ bad-vconvert bad-vconvert-input } related-words + +HELP: vconvert +{ $values + { "from-type" "a SIMD type" } { "to-type" "a SIMD type" } +} +{ $description "Converts SIMD vectors of " { $snippet "from-type" } " to " { $snippet "to-type" } ". The number of inputs and outputs depends on the relationship of the two types:" +{ $list +{ "If " { $snippet "to-type" } " is a floating-point vector type with the same byte length and element count as the integer vector type " { $snippet "from-type" } " (for example, from " { $snippet "int-8" } " to " { $snippet "float-8" } " or from " { $snippet "longlong-2" } " to " { $snippet "double-2" } "), " { $snippet "vconvert" } " takes one vector of " { $snippet "from-type" } " and converts its elements to floating-point, outputting one vector of " { $snippet "to-type" } "." } +{ "Likewise, if " { $snippet "to-type" } " is an integer vector type with the same byte length and element count as the floating-point vector type " { $snippet "from-type" } ", " { $snippet "vconvert" } " takes one vector of " { $snippet "from-type" } " and truncates its elements to integers, outputting one vector of " { $snippet "to-type" } "." } +{ "If " { $snippet "to-type" } " is a vector type with the same byte length as and twice the element count of the vector type " { $snippet "from-type" } " (for example, from " { $snippet "int-4" } " to " { $snippet "ushort-8" } ", from " { $snippet "double-2" } " to " { $snippet "float-4" } ", or from " { $snippet "short-8" } " to " { $snippet "char-16" } "), " { $snippet "vconvert" } " takes two vectors of " { $snippet "from-type" } " and packs them into one vector of " { $snippet "to-type" } ", saturating values too large or small to be representable as elements of " { $snippet "to-type" } "." } +{ "If " { $snippet "to-type" } " is a vector type with the same byte length as and half the element count of the vector type " { $snippet "from-type" } " (for example, from " { $snippet "ushort-8" } " to " { $snippet "int-4" } ", from " { $snippet "float-4" } " to " { $snippet "double-2" } ", or from " { $snippet "char-16" } " to " { $snippet "short-8" } "), " { $snippet "vconvert" } " takes one vector of " { $snippet "from-type" } " and unpacks it into two vectors of " { $snippet "to-type" } "." } +} +{ $snippet "from-type" } " and " { $snippet "to-type" } " must adhere to the following restrictions; a " { $link bad-vconvert } " error will be thrown otherwise:" +{ $list +{ { $snippet "from-type" } " and " { $snippet "to-type" } " must have the same byte length. You cannot currently convert between 128- and 256-bit vector types." } +{ "For conversions between floating-point and integer vectors, " { $snippet "from-type" } " and " { $snippet "to-type" } " must have the same element length." } +{ "For packing conversions, " { $snippet "from-type" } " and " { $snippet "to-type" } " must be both floating-point or both integer types. Integer types can be packed from signed to unsigned or from unsigned to unsigned types. Unsigned to signed packing is invalid." } +{ "For unpacking conversions, " { $snippet "from-type" } " and " { $snippet "to-type" } " must be both floating-point or both integer types. Integer types can be unpacked from unsigned to signed or from unsigned to unsigned types. Signed to unsigned unpacking is invalid." } +} +} +{ $examples +"Conversion between integer and float vectors:" +{ $example """USING: alien.c-types math.vectors.conversion math.vectors.simd +prettyprint ; +SIMDS: int float longlong double ; + +int-8{ 0 1 2 3 4 5 6 7 } int-8 float-8 vconvert . +double-2{ 1.25 3.75 } double-2 longlong-2 vconvert .""" +"""float-8{ 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 } +longlong-2{ 1 3 }""" } +"Packing conversions:" +{ $example """USING: alien.c-types math.vectors.conversion math.vectors.simd +prettyprint ; +SIMDS: ushort int float double ; + +int-4{ -8 70000 6000 50 } int-4{ 4 3 2 -1 } int-4 ushort-8 vconvert . +double-4{ 0.0 1.5 1.0e100 2.0 } +double-4{ -1.0e100 0.0 1.0 2.0 } double-4 float-8 vconvert .""" +"""ushort-8{ 0 65535 6000 50 4 3 2 0 } +float-8{ 0.0 1.5 1/0. 2.0 -1/0. 0.0 1.0 2.0 }""" } +"Unpacking conversions:" +{ $example """USING: alien.c-types kernel math.vectors.conversion +math.vectors.simd prettyprint ; +SIMDS: uchar short ; + +uchar-16{ 8 70 60 50 4 30 200 1 9 10 110 102 133 143 115 0 } +uchar-16 short-8 vconvert [ . ] bi@""" +"""short-8{ 8 70 60 50 4 30 200 1 } +short-8{ 9 10 110 102 133 143 115 0 }""" } +} ; + +ARTICLE: "math.vectors.conversion" "SIMD vector conversion" +"The " { $vocab-link "math.vectors.conversion" } " vocabulary provides facilities for converting SIMD vectors between floating-point and integer representations and between different-sized integer representations." +{ $subsections + vconvert +} ; + +ABOUT: "math.vectors.conversion" diff --git a/basis/math/vectors/vectors-docs.factor b/basis/math/vectors/vectors-docs.factor index 27940f9f6c..71e86417f5 100644 --- a/basis/math/vectors/vectors-docs.factor +++ b/basis/math/vectors/vectors-docs.factor @@ -55,12 +55,15 @@ ARTICLE: "math-vectors-shuffle" "Vector shuffling, packing, and unpacking" "These operations are primarily meant to be used with " { $vocab-link "math.vectors.simd" } " types. The software fallbacks for types not supported by hardware will not perform well." } $nl -{ $subsection vshuffle } -{ $subsection vbroadcast } -{ $subsection hlshift } -{ $subsection hrshift } -{ $subsection vmerge } -{ $subsection (vmerge) } ; +{ $subsections + vshuffle + vbroadcast + hlshift + hrshift + vmerge + (vmerge) +} +"See the " { $vocab-link "math.vectors.conversion" } " vocabulary for packing, unpacking, and converting vectors." ; ARTICLE: "math-vectors-logic" "Vector component- and bit-wise logic" { $notes From 8ef0d411ac8fb6032422978b925afeb1c6105156 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 19 Oct 2009 00:16:32 -0500 Subject: [PATCH 4/4] vm: cleanup --- vm/aging_collector.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vm/aging_collector.cpp b/vm/aging_collector.cpp index 6e3e61412a..5e284be587 100644 --- a/vm/aging_collector.cpp +++ b/vm/aging_collector.cpp @@ -3,12 +3,12 @@ namespace factor { -aging_collector::aging_collector(factor_vm *myvm_) : +aging_collector::aging_collector(factor_vm *parent_) : copying_collector( - myvm_, - &myvm_->gc_stats.aging_stats, - myvm_->data->aging, - aging_policy(myvm_)) {} + parent_, + &parent_->gc_stats.aging_stats, + parent_->data->aging, + aging_policy(parent_)) {} void factor_vm::collect_aging() {