Skip to content

Commit

Permalink
Merge branch 'felix/raster-gzip' of github.com:visgl/deck.gl into fel…
Browse files Browse the repository at this point in the history
…ix/raster-gzip
  • Loading branch information
felixpalmer committed Jan 15, 2025
2 parents 15dc5a9 + 1a5685f commit cb47c55
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
echo "result=${result}" >> "$GITHUB_OUTPUT"
release:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs: check_branch
permissions:
contents: write
Expand Down
9 changes: 8 additions & 1 deletion modules/extensions/src/data-filter/data-filter-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ const defaultOptions: Required<DataFilterExtensionOptions> = {
countItems: false
};

const CATEGORY_TYPE_FROM_SIZE = {
1: 'uint' as const,
2: 'uvec2' as const,
3: 'uvec3' as const,
4: 'uvec4' as const
};
const DATA_TYPE_FROM_SIZE = {
1: 'float' as const,
2: 'vec2' as const,
Expand All @@ -137,7 +143,7 @@ export default class DataFilterExtension extends LayerExtension<
const {categorySize, filterSize, fp64} = extension.opts;
const defines: Defines = {};
if (categorySize) {
defines.DATACATEGORY_TYPE = DATA_TYPE_FROM_SIZE[categorySize];
defines.DATACATEGORY_TYPE = CATEGORY_TYPE_FROM_SIZE[categorySize];
defines.DATACATEGORY_CHANNELS = categorySize;
}
if (filterSize) {
Expand Down Expand Up @@ -173,6 +179,7 @@ export default class DataFilterExtension extends LayerExtension<
size: categorySize,
stepMode: 'dynamic',
accessor: 'getFilterCategory',
type: 'uint32',
transform:
categorySize === 1
? d => extension._getCategoryKey.call(this, d, 0)
Expand Down
24 changes: 12 additions & 12 deletions modules/extensions/src/data-filter/shader-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type Defines = {
/**
* Primitive type of parameter used for category filtering. If undefined, category filtering disabled.
*/
DATACATEGORY_TYPE?: 'float' | 'vec2' | 'vec3' | 'vec4';
DATACATEGORY_TYPE?: 'uint' | 'uvec2' | 'uvec3' | 'uvec4';
/**
* Number of category filtering channels. Must match dimension of `DATACATEGORY_TYPE`
*/
Expand Down Expand Up @@ -48,7 +48,7 @@ uniform dataFilterUniforms {
#endif
#endif
#ifdef DATACATEGORY_TYPE
highp ivec4 categoryBitMask;
highp uvec4 categoryBitMask;
#endif
} dataFilter;
`;
Expand Down Expand Up @@ -107,26 +107,26 @@ float dataFilter_reduceValue(vec4 value) {
#ifdef DATACATEGORY_TYPE
void dataFilter_setCategoryValue(DATACATEGORY_TYPE category) {
#if DATACATEGORY_CHANNELS == 1 // One 128-bit mask
int dataFilter_masks = dataFilter.categoryBitMask[int(category / 32.0)];
uint dataFilter_masks = dataFilter.categoryBitMask[category / 32u];
#elif DATACATEGORY_CHANNELS == 2 // Two 64-bit masks
ivec2 dataFilter_masks = ivec2(
dataFilter.categoryBitMask[int(category.x / 32.0)],
dataFilter.categoryBitMask[int(category.y / 32.0) + 2]
uvec2 dataFilter_masks = uvec2(
dataFilter.categoryBitMask[category.x / 32u],
dataFilter.categoryBitMask[category.y / 32u + 2u]
);
#elif DATACATEGORY_CHANNELS == 3 // Three 32-bit masks
ivec3 dataFilter_masks = dataFilter.categoryBitMask.xyz;
uvec3 dataFilter_masks = dataFilter.categoryBitMask.xyz;
#else // Four 32-bit masks
ivec4 dataFilter_masks = dataFilter.categoryBitMask;
uvec4 dataFilter_masks = dataFilter.categoryBitMask;
#endif
// Shift mask and extract relevant bits
DATACATEGORY_TYPE dataFilter_bits = DATACATEGORY_TYPE(dataFilter_masks) / pow(DATACATEGORY_TYPE(2.0), mod(category, 32.0));
dataFilter_bits = mod(floor(dataFilter_bits), 2.0);
DATACATEGORY_TYPE dataFilter_bits = DATACATEGORY_TYPE(dataFilter_masks) >> (category & 31u);
dataFilter_bits &= 1u;
#if DATACATEGORY_CHANNELS == 1
if(dataFilter_bits == 0.0) dataFilter_value = 0.0;
if(dataFilter_bits == 0u) dataFilter_value = 0.0;
#else
if(any(equal(dataFilter_bits, DATACATEGORY_TYPE(0.0)))) dataFilter_value = 0.0;
if(any(equal(dataFilter_bits, DATACATEGORY_TYPE(0u)))) dataFilter_value = 0.0;
#endif
}
#endif
Expand Down

0 comments on commit cb47c55

Please sign in to comment.