John Kessenich [Sun, 4 Jun 2017 19:05:50 +0000 (13:05 -0600)]
GLSL: Error when using location on an arrayed block.
This implements a recent change to the GLSL specification to enforce
this ill-defined situation.
John Kessenich [Sat, 3 Jun 2017 21:29:06 +0000 (15:29 -0600)]
Merge pull request #899 from antiagainst/rm-empty-cpps
Remove empty cpp files
John Kessenich [Sat, 3 Jun 2017 21:28:11 +0000 (15:28 -0600)]
Merge pull request #915 from LoopDawg/subvec4-intrinsic
HLSL: add test coverage for sub-vec4 texture intrinsics
John Kessenich [Sat, 3 Jun 2017 00:48:26 +0000 (18:48 -0600)]
Merge pull request #905 from KhronosGroup/flatten-opaque-structs
SPV: When passing structs of opaque types, flatten and pass the membe…
John Kessenich [Fri, 2 Jun 2017 22:28:39 +0000 (16:28 -0600)]
HLSL: Convert run-time sampler assignments to compile-time aliases.
For "s.m = t", a sampler member assigned a sampler, make t an alias
for s.m, and when s.m is flattened, it will flatten to the alias t.
Normally, assignments to samplers are disallowed.
John Kessenich [Fri, 26 May 2017 06:01:36 +0000 (00:01 -0600)]
SPV: When passing structs of opaque types, flatten and pass the members instead.
This avoids either A) needing uniformConstant struct, or
B) initializing a struct with opaque members, as writing them is not
allowed.
John Kessenich [Fri, 2 Jun 2017 00:16:33 +0000 (18:16 -0600)]
HLSL: iomapper: Fix #914. Tolerate user aliasing of bindings.
Because it is valid in HLSL to alias bindings:
A) remove validation that aliasing is not done
B) make the algorithms tolerate aliasing
LoopDawg [Thu, 1 Jun 2017 19:10:25 +0000 (13:10 -0600)]
HLSL: add test coverage for sub-vec4 texture intrinsics
This changes no functional code. There was a bit of a testing hole
in that textures templatized on sub-vec4 types were not being exercised
with any intrinsics. This adds some basic sanity coverage of that case.
John Kessenich [Thu, 1 Jun 2017 18:37:52 +0000 (12:37 -0600)]
Merge pull request #907 from KhronosGroup/include
HLSL: Add an Includer to handle #include for local HLSL paths.
John Kessenich [Thu, 1 Jun 2017 18:36:21 +0000 (12:36 -0600)]
Merge pull request #913 from amdrexu/bugfix
Parser: Add missing codes for float16
John Kessenich [Mon, 22 May 2017 21:00:42 +0000 (15:00 -0600)]
HLSL: Add an Includer to handle #include.
Rex Xu [Thu, 1 Jun 2017 11:58:54 +0000 (19:58 +0800)]
Parser: Add missing codes for float16
John Kessenich [Thu, 1 Jun 2017 04:47:28 +0000 (22:47 -0600)]
Merge pull request #911 from KhronosGroup/debug-info
SPV: Add OpSource shader source code and file name.
John Kessenich [Thu, 1 Jun 2017 00:50:53 +0000 (18:50 -0600)]
SPV: Debug output: Include OpLine information for execution path.
Note that declaratives are not handled, only procedurals.
John Kessenich [Wed, 31 May 2017 23:11:16 +0000 (17:11 -0600)]
SPV: Add OpSource shader source code and file name.
John Kessenich [Mon, 29 May 2017 17:40:43 +0000 (11:40 -0600)]
Merge pull request #856 from TiemoJung/texture_upgrade
Pure Texture to Sampled Texture Transform
t.jung [Tue, 25 Apr 2017 21:31:03 +0000 (23:31 +0200)]
Pure Texture to Sampled Texture Transform
Adds a transformation step to the post processing step.
Two modes are available:
1) keep
- Keeps samplers, textures and sampled textures as is
2) transform pure texture into sampled texture and remove pure samplers
- removes all pure samplers
- transforms all pure textures into its sampled counter part
Change-Id: If54972e8052961db66c23f4b7e719d363cf6edbd
John Kessenich [Thu, 25 May 2017 05:12:58 +0000 (23:12 -0600)]
Merge pull request #901 from LoopDawg/imat-construct
HLSL: Add imat, umat, and bmat constructors
John Kessenich [Thu, 25 May 2017 05:10:28 +0000 (23:10 -0600)]
SPV: Fix #904: Correctly check for built-in block redeclations for location check.
John Kessenich [Wed, 24 May 2017 22:44:47 +0000 (16:44 -0600)]
HLSL: Fix #903: Don't short-circuit && or ||.
John Kessenich [Wed, 24 May 2017 22:02:56 +0000 (16:02 -0600)]
HLSL: Fix #902: Incorrect protection against zero arguments.
LoopDawg [Sun, 21 May 2017 03:40:27 +0000 (21:40 -0600)]
HLSL: Add imat, umat, and bmat constructors
Fixes #894
John Kessenich [Sat, 20 May 2017 19:23:25 +0000 (13:23 -0600)]
Fix #373: Implicitly make gl_FragColor a location=0 output.
John Kessenich [Sat, 20 May 2017 18:14:13 +0000 (12:14 -0600)]
SPV: Correctly enforce 'location' presence on in/out blocks.
Blocks have this on members, not the object.
John Kessenich [Sat, 20 May 2017 17:33:54 +0000 (11:33 -0600)]
Merge pull request #900 from LoopDawg/tx-overloads
HLSL: allow name mangling based on texture template type
John Kessenich [Sat, 20 May 2017 05:44:51 +0000 (23:44 -0600)]
More non-determinism fixed.
John Kessenich [Sat, 20 May 2017 05:29:50 +0000 (23:29 -0600)]
Fix C++ portability, non-deterministic order of argument evaluation.
John Kessenich [Sat, 20 May 2017 05:00:13 +0000 (23:00 -0600)]
Fix #857: Convert uniform int to local bool for struct alias assignment.
This was done for one direction, but not both directions, so this commit
picks up the other direction.
John Kessenich [Sat, 20 May 2017 02:19:00 +0000 (20:19 -0600)]
HLSL: Don't do logical short-circuits when the operands are bool-vectors.
This seems a bit ill-defined, and was generating code that made OpPhi of two
operands that were Boolean vectors result in a scalar bool.
LoopDawg [Thu, 18 May 2017 23:43:08 +0000 (17:43 -0600)]
HLSL: allow name mangling based on texture template type
Name mangling did not account for the vector size in the template type of a texture.
This adds that. The mangle is as it ever was for the vec4 case, which leaves
all GLSL behavior and most HLSL behavior uneffected. For vec1-3 the size is added
to the mangle.
Current limitation: textures cannot presently be templatized on structured types,
so this works only for vectors of basic types.
Fixes #895.
Lei Zhang [Fri, 19 May 2017 20:59:24 +0000 (16:59 -0400)]
Remove empty cpp files
This solves ranlib warnings on MacOS.
John Kessenich [Fri, 19 May 2017 03:12:04 +0000 (21:12 -0600)]
Merge pull request #896 from KhronosGroup/spv-location
SPV: Give error on not assigning locations to I/O when generating SPIR-V.
John Kessenich [Fri, 19 May 2017 00:19:12 +0000 (18:19 -0600)]
Merge pull request #897 from LoopDawg/remap-specconstop-fix.2
Remapper: handle embedded opcode in OpSpecConstantOp
LoopDawg [Thu, 18 May 2017 22:13:04 +0000 (16:13 -0600)]
Remapper: handle embedded opcode in OpSpecConstantOp
OpSpecConstantOp contains an embedded opcode which is given as a literal
argument to the OpSpecConstantOp. The subsequent arguments are as the
embedded op would expect, which may be a mixture of IDs and literals. This
adds support for that to the remapper binary parser. Upon seeing such an
embedded op, the parser flips over to parsing the argument list as
appropriate for that opcode.
Fixes #882.
John Kessenich [Thu, 18 May 2017 00:28:19 +0000 (18:28 -0600)]
SPV: Give error on not assigning locations to I/O.
Also, provides an option to auto-assign locations.
Existing tests use this option, to avoid the error message,
however, it is not fully implemented yet.
John Kessenich [Wed, 17 May 2017 16:55:22 +0000 (10:55 -0600)]
Merge pull request #860 from steve-lunarg/sb-counter-args.2
HLSL: add ability to pass struct buffers with counters to fns
John Kessenich [Wed, 17 May 2017 15:25:57 +0000 (09:25 -0600)]
Merge pull request #893 from KhronosGroup/member-call
HLSL: Implement member functions calling member functions.
Fixes #883.
steve-lunarg [Thu, 27 Apr 2017 17:22:32 +0000 (11:22 -0600)]
WIP: HLSL: add ability to pass struct buffers with counters to fns
This modifies function parameter passing to pass the counter
buffer associated with a struct buffer to a function as a
hidden parameter. Similarly function declarations will have
hidden parameters added to accept the associated counter buffers.
There is a limitation: if a SB type may or may not have an associated
counter, passing it as a function parameter will assume that it does, and
the counter will appear in the linkage whether or not there is a counter
method used on the object.
John Kessenich [Wed, 17 May 2017 05:16:26 +0000 (23:16 -0600)]
HLSL: Implement member functions calling member functions.
John Kessenich [Tue, 16 May 2017 16:38:32 +0000 (10:38 -0600)]
Merge pull request #852 from steve-lunarg/declared-builtin
track declared builtin type
steve-lunarg [Mon, 24 Apr 2017 01:44:28 +0000 (19:44 -0600)]
WIP: track declared builtin type [proposal]
Marking as WIP since it might deserve discussion or at least explicit consideration.
During type sanitization, the TQualifier's TBuiltInVariable type is lost. However,
sometimes it's needed downstream. There were already two methods in use to track
it through to places it was needed: one in the TParameter, and one in a map in the
HlslParseContext used for structured buffers.
The latter was going to be insufficient when SB types with counters are passed to
user functions, and it's proving awkward to track the data to where it's needed.
This PR holds a proposal: track the original declared builtin type in the TType,
so it's trivially available where needed.
This lets the other two mechanisms be removed (and they are in this PR). There's a
side benefit of not losing certain types of information before the reflection interface.
This PR is only that proposal, so it changes no test results. If it's acceptable,
I'll use it for the last piece of SB counter functionality.
John Kessenich [Mon, 15 May 2017 15:39:15 +0000 (09:39 -0600)]
Merge pull request #890 from LoopDawg/mip-operator
HLSL: add .mips[][] operator for texture types
LoopDawg [Fri, 12 May 2017 23:14:31 +0000 (17:14 -0600)]
HLSL: add .mips[][] operator for texture types
This implements mytex.mips[mip][coord] for texture types. There is
some error testing, but not comprehensive. The constructs can be
nested, e.g in this case the inner .mips is parsed before the completion
of the outer [][] operator.
tx.mips[tx.mips[a][b].x][c]
John Kessenich [Sat, 13 May 2017 22:03:12 +0000 (16:03 -0600)]
Merge pull request #889 from antiagainst/travis-android
Check Android build on Travis CI
Lei Zhang [Sat, 13 May 2017 18:26:30 +0000 (14:26 -0400)]
Check Android build on Travis CI.
Also stop requiring sudo privilege so that we can use containers
for testing.
John Kessenich [Sat, 13 May 2017 18:54:08 +0000 (12:54 -0600)]
Merge pull request #888 from LoopDawg/geometry-stage-mix
HLSL: allow GS-specific methods in non-GS stages
LoopDawg [Sat, 13 May 2017 15:20:11 +0000 (09:20 -0600)]
HLSL: allow GS-specific methods in other stages
Using GS methods such as Append() in non-GS stages should be ignored, but was
creating errors due to the lack of a stream output symbol for the non-GS stage.
John Kessenich [Fri, 12 May 2017 21:25:41 +0000 (15:25 -0600)]
HLSL: Fix #884: Use promoted children, not pre-promoted, in completing binary nodes.
John Kessenich [Fri, 12 May 2017 20:53:06 +0000 (14:53 -0600)]
Merge pull request #886 from antiagainst/unordered-set
Use unordered_set in ReadableOrderTraverser.
Lei Zhang [Fri, 12 May 2017 00:46:01 +0000 (20:46 -0400)]
Use unordered_set in ReadableOrderTraverser.
Previously we are using unordered_map to map to bool, which can
be simplified with unordered_set.
John Kessenich [Wed, 10 May 2017 17:11:44 +0000 (11:11 -0600)]
Merge pull request #880 from aras-p/master
Fix for lumped/unity/batch builds
John Kessenich [Wed, 10 May 2017 17:10:53 +0000 (11:10 -0600)]
Merge pull request #874 from xlpiao/DescriptorSet-and-Binding
HLSL: Manually configure descriptor set and binding number for resources
Aras Pranckevicius [Wed, 10 May 2017 13:58:38 +0000 (16:58 +0300)]
[lumped builds] Add include guards (#pragma once) to header files that did not have any.
The codebase seems to use both “#pragma once“ approach, and “#ifndef / #define” approach,
so I picked pragma once as that one is less typing & less brittle.
When glslang is built with some other build system and lumped/unity builds are used,
without the include guards some headers would get included multiple times, leading to duplicate
declaration errors.
Aras Pranckevicius [Wed, 10 May 2017 13:52:50 +0000 (16:52 +0300)]
[lumped builds] Only define _CRT_SECURE_NO_WARNINGS if it’s not defined yet.
When glslang is built with some other build system and lumped/unity builds are used,
without the checks this would get “macro is being redefined” warnings/errors.
Hyangran Park [Tue, 2 May 2017 07:27:29 +0000 (16:27 +0900)]
HLSL: Manually configure descriptor set and binding number for resources
John Kessenich [Wed, 10 May 2017 05:30:56 +0000 (23:30 -0600)]
Build fix: Make string assignment simpler to avoid some compiler issues.
Included changing related parameters to const.
Should fix complaints with previous commit. See issue #879.
John Kessenich [Mon, 8 May 2017 06:47:48 +0000 (00:47 -0600)]
Build: Fix portability in previous commit.
John Kessenich [Mon, 8 May 2017 06:12:28 +0000 (00:12 -0600)]
SPV: Support texelFetch() on a textureBuffer (no sampler).
Fixes Vulkan Khronos-internal issue 770.
John Kessenich [Fri, 5 May 2017 11:09:58 +0000 (05:09 -0600)]
SPV: Emit extension for using StorageClassStorageBuffer.
John Kessenich [Thu, 4 May 2017 20:06:02 +0000 (23:06 +0300)]
Merge pull request #878 from steve-lunarg/unroll-hint
HLSL: implement [unroll] and [loop] attributes
steve-lunarg [Wed, 3 May 2017 02:14:50 +0000 (20:14 -0600)]
HLSL: implement [unroll] and [loop] attributes
This adds infrastructure suitable for any front end to create SPIR-V loop
control flags. The only current front end doing so is HLSL.
[unroll] turns into spv::LoopControlUnrollMask
[loop] turns into spv::LoopControlDontUnrollMask
no specification means spv::LoopControlMaskNone
John Kessenich [Wed, 3 May 2017 05:40:15 +0000 (08:40 +0300)]
Merge pull request #877 from steve-lunarg/warn-fix1
Fix iomapper build warnings
steve-lunarg [Wed, 3 May 2017 00:59:55 +0000 (18:59 -0600)]
Fix iomapper build warnings
John Kessenich [Tue, 2 May 2017 19:38:14 +0000 (22:38 +0300)]
Merge pull request #873 from steve-lunarg/gathercmp
HLSL: Implement missing GatherCmp method
steve-lunarg [Tue, 2 May 2017 03:59:34 +0000 (21:59 -0600)]
HLSL: Implement missing GatherCmp
John Kessenich [Sun, 30 Apr 2017 20:02:23 +0000 (14:02 -0600)]
Merge pull request #870 from SoapGentoo/cmake-fixes
Modernise CMake #2
David Seifert [Sat, 29 Apr 2017 08:57:36 +0000 (10:57 +0200)]
Modernise CMake #2
This reverts commit
cfc69d95afed34e1ba1371df0ddb56f2f491a5cb.
* Change CMAKE_INSTALL_PREFIX default on Windows in order
to prevent permission denied errors when trying to install
to "Program Files".
John Kessenich [Sat, 29 Apr 2017 04:13:35 +0000 (22:13 -0600)]
Merge pull request #869 from KhronosGroup/revert-828-fixes
Revert "Modernise CMake"
John Kessenich [Sat, 29 Apr 2017 04:04:24 +0000 (22:04 -0600)]
Revert "Modernise CMake"
John Kessenich [Sat, 29 Apr 2017 03:50:19 +0000 (21:50 -0600)]
Merge pull request #828 from SoapGentoo/fixes
Modernise CMake
David Seifert [Fri, 28 Apr 2017 20:46:52 +0000 (22:46 +0200)]
Make test suite optional by using CTest
David Seifert [Fri, 28 Apr 2017 20:46:52 +0000 (22:46 +0200)]
Modernise CMake
* Use `GNUInstallDirs` in order to respect GNU conventions.
This is especially important for multi-arch/multi-lib setups.
* Specify position independent mode building properly, without
using the historic hack of adding `-fPIC` as a definition.
This makes the build system more portable.
* Only detect C++ (and not C) to slightly speed up configuring.
* Specify C++11 mode using modern CMake idioms.
* Fix some whitespace issues.
John Kessenich [Fri, 28 Apr 2017 15:15:51 +0000 (09:15 -0600)]
Merge pull request #868 from TiemoJung/two_pass_io_remap
Notification phase for io remapper
John Kessenich [Fri, 28 Apr 2017 15:09:51 +0000 (09:09 -0600)]
Merge pull request #867 from steve-lunarg/emptyinit
HLSL: Allow empty struct initializers
t.jung [Fri, 28 Apr 2017 13:54:57 +0000 (15:54 +0200)]
Notification phase for io remapper
Adds a notification phase to the io remapper.
The idea behind this is to give the user a
chance to group uniforms and/or in/out variables
for a better pipeline layout sharing for vulkan.
Change-Id: I7492421085a4156ed3534f01d906ab390d73a623
steve-lunarg [Fri, 28 Apr 2017 00:22:52 +0000 (18:22 -0600)]
HLSL: Allow empty struct initializers
Review request: does this harm GLSL in any way?
John Kessenich [Thu, 27 Apr 2017 21:18:46 +0000 (15:18 -0600)]
HLSL: Turn on hlsl-offsets by default for HLSL-source shaders.
John Kessenich [Thu, 27 Apr 2017 07:36:52 +0000 (01:36 -0600)]
Merge pull request #859 from steve-lunarg/sampleposition
HLSL: add standard sample position return form of GetSamplePosition m…
steve-lunarg [Wed, 26 Apr 2017 14:31:56 +0000 (08:31 -0600)]
HLSL: add standard sample position return form of GetSamplePosition method
Multisample textures support a GetSamplePosition() method intended to query
positions given a sample index. This cannot be truly implemented in SPIR-V,
but #753 requested returning standard positions for the 1..16 cases, which
this PR adds. Anything besides that returns (0,0). If the standard positions
are not used, this will be wrong.
This should be revisited when there is a real query available.
John Kessenich [Tue, 25 Apr 2017 22:05:03 +0000 (16:05 -0600)]
Merge pull request #855 from steve-lunarg/constantbuffer
HLSL: Add ConstantBuffer<T> syntax
steve-lunarg [Tue, 25 Apr 2017 15:30:28 +0000 (09:30 -0600)]
HLSL: Add ConstantBuffer<T> syntax
Note: multi-dimension arrays of ConstantBuffer objects will go through uniform flattening.
John Kessenich [Sat, 22 Apr 2017 15:54:34 +0000 (09:54 -0600)]
Merge pull request #851 from dgkoch/dgkoch_build_fixes3
Fix Android build errors
Daniel Koch [Fri, 21 Apr 2017 20:16:43 +0000 (16:16 -0400)]
Fix Android build errors
glslang/MachineIndependent/iomapper.cpp:207:9: error: field 'resolver' will be initialized after field 'stage' [-Werror,-Wreorder]
: resolver(r)
^
glslang/MachineIndependent/iomapper.cpp:263:9: error: field 'resolver' will be initialized after field 'stage' [-Werror,-Wreorder]
: resolver(r)
^
hlsl/hlslParseHelper.cpp:70:5: error: field 'gsStreamOutput' will be initialized after field 'inputPatch' [-Werror,-Wreorder]
gsStreamOutput(nullptr),
^
John Kessenich [Fri, 21 Apr 2017 17:27:24 +0000 (11:27 -0600)]
Merge pull request #849 from steve-lunarg/samplercmp-errmsg
HLSL: add error for expected comparison sampler in SampleCmp* ops
steve-lunarg [Fri, 21 Apr 2017 15:54:53 +0000 (09:54 -0600)]
HLSL: add error for expected comparison sampler in SampleCmp* ops
This adds an error message if a non-comparison sampler is used with
comparison sampling methods. There's no functional change for correct shaders.
John Kessenich [Fri, 21 Apr 2017 03:32:16 +0000 (21:32 -0600)]
HLSL: Fix #846: support mixed ternary types.
Vector conditions properly convert the true/false expression types to same
width vector as the condition.
Scalar conditions make the true/false expressions convert to each other.
John Kessenich [Fri, 21 Apr 2017 02:36:06 +0000 (20:36 -0600)]
Merge pull request #847 from steve-lunarg/sb-param-fix
HLSL: fix for byte address buffers in fn parmeters
John Kessenich [Fri, 21 Apr 2017 02:35:09 +0000 (20:35 -0600)]
Merge pull request #842 from steve-lunarg/sb-cast
HLSL: cast non-int types to uint on Load/Store indexes
John Kessenich [Fri, 21 Apr 2017 02:34:12 +0000 (20:34 -0600)]
Merge pull request #840 from steve-lunarg/iomap-hlsl
HLSL: hlsl register class iomapping
steve-lunarg [Thu, 20 Apr 2017 22:37:14 +0000 (16:37 -0600)]
HLSL: fix for byte address buffers in fn parmeters
Byte address buffers were failing to detect that they were byte address
buffers when used as fn parameters.
Note: this detection is a little awkward, and could be simplified if
it was easy to obtain the declared builtin type for an object.
steve-lunarg [Thu, 20 Apr 2017 19:16:23 +0000 (13:16 -0600)]
HLSL: add readonly qualifier to tbuffer, so they end up as SRV
steve-lunarg [Tue, 18 Apr 2017 18:18:01 +0000 (12:18 -0600)]
WIP: HLSL: hlsl register class iomapping
Adds --hlsl-iomap option to perform IO mapping in HLSL register space.
--shift-cbuffer-binding is now a synonym for --shift-ubo-binding.
The idea way to do this seems to be passing in a dedicated IO resolver, but
that would require more intrusive restructuring, so maybe best for its
own PR.
The TDefaultHlslIoResolver class and the former TDefaultIoResolver class
share quite a bit of mechanism in a common base class.
TODO: tbuffers are landing in the wrong register class, which needs some
investigation. They're either wrong upstream, or the detection in the
resolver is wrong.
John Kessenich [Thu, 20 Apr 2017 18:21:53 +0000 (12:21 -0600)]
GLSL: Fix #822: Improve information given for syntax errors.
Also, fixed one test file that didn't have its syntax error as the last line.
John Kessenich [Thu, 20 Apr 2017 17:08:24 +0000 (11:08 -0600)]
HLSL: Fix #96: Support do-while loop substatements with no curly braces.
steve-lunarg [Thu, 20 Apr 2017 15:00:56 +0000 (09:00 -0600)]
HLSL: cast non-int types to uint on Load/Store indexes
Some texture and SB operations can take non-integer indexes, which should be
cast to integers before use if they are not already. This adds makeIntegerIndex()
for the purpose. Int types are left alone.
(This was done before for operator[], but needs to apply to some other things
too, hence its extraction into common function now)
John Kessenich [Thu, 20 Apr 2017 00:34:49 +0000 (18:34 -0600)]
SPV: Support test #pragma for generating the StorageBuffer storage class.
Longer term, this storage class should be generated based on the mode
of compilation.
John Kessenich [Wed, 19 Apr 2017 23:42:22 +0000 (17:42 -0600)]
Merge pull request #835 from steve-lunarg/sb-counters
HLSL: structuredbuffer counter functionality
John Kessenich [Wed, 19 Apr 2017 03:07:05 +0000 (21:07 -0600)]
HLSL: vector shape conversions for all ops: Fix #839. Fix #653. Fix #631.
John Kessenich [Tue, 18 Apr 2017 20:47:33 +0000 (14:47 -0600)]
HLSL: Address #839: avoid crash by distinguishing between bad argument and no argument.
steve-lunarg [Sat, 15 Apr 2017 14:18:16 +0000 (08:18 -0600)]
WIP: HLSL: add refection queries for structuredbuffer counter blocks
This adds TProgram::getUniformBlockCounterIndex(int index), which returns the
index the block of the counter buffer associated with the block of the passed in
index, if any, or -1 if none.