Towards 1.13
#11
I don't quite understand what you mean altogether. Are you proposing that we add another translation for the BlockState, so that the data is represented:
1. In BlockArea: A single block is represented by a single number, index into per-BlockArea Palette
2. In Palette: A single index maps to "BlockTypeName" and "BlockStateIndex", an index into a global BlockStatePalette
3. In BlockStatePalette: A single index corresponds to the entire BlockState representation (map of key -> value)

In code:
class Palette
{
  struct BlockDef
  {
    std::string mBlockTypeName;  // such as "minecraft:acacia_door"
    size_t mBlockStateIndex;  // Index into global BlockStatePalette
  };
  std::map<UInt32, BlockDef> mBlockTypeMap;
};

using BlockState = map<std::string, std::string>;  // For simplicity, only consider strings as values for now

class BlockStatePalette
{
  std::map<size_t, BlockState> mBlockStateMap;
};

// global:
BlockStatePalette gBlockStatePalette;

class BlockArea
{
  UInt32 mBlocks[];  // To be replaced by smaller numbers when possible
  Palette mPalette;
  
  std::pair<const AString &, const BlockState &> block(const Vector3i & aPos)
  {
    UInt32 paletteIndex = mBlocks[...];
    const AString & blockTypeName = mPalette.mBlockTypeMap[paletteIndex].mBlockTypeName;
    const BlockState & blockState = gPalette.mBlockStateMap[mPalette.mBlockTypeMap[paletteIndex].mBlockStateIndex];
    return {blockTypeName, blockState};
  }
};
I hope the code for BlockArea::block() illustrates the concept enough.

Anyway, such a proposal is possible to implement later on as an optimization, and I don't think the added complexity is worth the effort and savings. I've done a bit of calculations, here's the raw math.

A chunk section (16*16*16 blocks) in the current pre-1.13 format uses exactly 8 KiB of RAM (16 * 16 * 16 blocks, each block 12 bits of type and 4 bits of meta)
A chunk section in the 1.13 format with a local palette can use from 16 KiB of RAM through 2 KiB of RAM downto 0.5 KiB of RAM (16 * 16 * 16 blocks, each block either 32-bit, 4-bit or 1-bit; exact bit-size is governed by the amount of different block types). So we could end up with up to twice as much RAM requirement in the worst case, but also 16 times less RAM in the best case. Considering the 0.5 KiB, storing the BlockStates as a string -> string map could mean a lot of memory, but there will only be 2 blocks in such a case anyway, so not too much of a BlockState to store. In the 16 KiB size, there could be up to 4K different blocks, but my opinion is that many of those will not have any BlockState at all, so the memory used will be reasonable as well.
Basically, I don't suppose that changing the internal representation to one with the local palette would change the RAM requirements dramatically.
Reply
Thanks given by:


Messages In This Thread
Towards 1.13 - by xoft - 01-08-2019, 01:04 AM
RE: Towards 1.13 - by xoft - 01-09-2019, 03:06 AM
RE: Towards 1.13 - by NiLSPACE - 01-09-2019, 06:45 AM
RE: Towards 1.13 - by xoft - 01-09-2019, 09:55 PM
RE: Towards 1.13 - by xoft - 01-09-2019, 09:58 PM
RE: Towards 1.13 - by NiLSPACE - 01-09-2019, 10:28 PM
RE: Towards 1.13 - by xoft - 01-11-2019, 05:57 AM
RE: Towards 1.13 - by ShadowCone - 01-11-2019, 03:52 AM
RE: Towards 1.13 - by NiLSPACE - 01-11-2019, 06:03 AM
RE: Towards 1.13 - by ShadowCone - 01-12-2019, 12:28 AM
RE: Towards 1.13 - by xoft - 01-16-2019, 01:10 AM
RE: Towards 1.13 - by xoft - 01-22-2019, 09:14 AM
RE: Towards 1.13 - by NiLSPACE - 01-22-2019, 06:56 PM
RE: Towards 1.13 - by xoft - 01-22-2019, 07:34 PM
RE: Towards 1.13 - by NiLSPACE - 01-22-2019, 08:57 PM
RE: Towards 1.13 - by NiLSPACE - 01-23-2019, 04:58 AM
RE: Towards 1.13 - by xoft - 01-23-2019, 05:32 AM
RE: Towards 1.13 - by xoft - 01-23-2019, 06:04 AM
RE: Towards 1.13 - by peterbell10 - 01-23-2019, 09:49 AM
RE: Towards 1.13 - by xoft - 01-24-2019, 12:00 AM
RE: Towards 1.13 - by xoft - 01-24-2019, 12:07 AM
RE: Towards 1.13 - by peterbell10 - 01-24-2019, 02:35 AM
RE: Towards 1.13 - by peterbell10 - 01-24-2019, 02:59 AM
RE: Towards 1.13 - by xoft - 01-24-2019, 08:02 AM
RE: Towards 1.13 - by xoft - 01-24-2019, 07:41 PM
RE: Towards 1.13 - by tigerw - 01-25-2019, 02:25 AM
RE: Towards 1.13 - by NiLSPACE - 01-25-2019, 04:41 AM
RE: Towards 1.13 - by xoft - 01-25-2019, 05:08 AM
RE: Towards 1.13 - by NiLSPACE - 01-25-2019, 04:31 PM
RE: Towards 1.13 - by xoft - 01-25-2019, 05:19 AM
RE: Towards 1.13 - by tigerw - 01-25-2019, 06:16 AM
RE: Towards 1.13 - by xoft - 01-25-2019, 07:49 PM
RE: Towards 1.13 - by tigerw - 01-25-2019, 09:44 PM
RE: Towards 1.13 - by tigerw - 01-25-2019, 10:40 PM
RE: Towards 1.13 - by xoft - 01-26-2019, 12:58 AM
RE: Towards 1.13 - by tigerw - 01-26-2019, 09:11 PM
RE: Towards 1.13 - by xoft - 01-27-2019, 03:40 AM
RE: Towards 1.13 - by Aberts10 - 05-28-2019, 09:31 AM
RE: Towards 1.13 - by xoft - 05-30-2019, 12:11 AM
RE: Towards 1.13 - by xoft - 08-04-2019, 07:56 AM
RE: Towards 1.13 - by Seadragon91 - 08-04-2019, 07:22 PM
RE: Towards 1.13 - by xoft - 08-04-2019, 11:34 PM
RE: Towards 1.13 - by xoft - 08-05-2019, 07:20 PM
RE: Towards 1.13 - by xoft - 08-06-2019, 07:50 PM
RE: Towards 1.13 - by xoft - 08-29-2019, 12:02 AM
RE: Towards 1.13 - by xoft - 08-30-2019, 10:21 PM
RE: Towards 1.13 - by xoft - 08-31-2019, 02:35 AM
RE: Towards 1.13 - by NiLSPACE - 09-01-2019, 03:04 AM
RE: Towards 1.13 - by xoft - 09-01-2019, 07:13 AM
RE: Towards 1.13 - by NiLSPACE - 09-02-2019, 03:51 AM
RE: Towards 1.13 - by NiLSPACE - 09-05-2019, 12:25 AM
RE: Towards 1.13 - by xoft - 09-05-2019, 06:04 AM
RE: Towards 1.13 - by xoft - 09-05-2019, 06:05 AM
RE: Towards 1.13 - by xoft - 09-10-2019, 05:57 AM
RE: Towards 1.13 - by xoft - 09-27-2019, 07:50 PM
RE: Towards 1.13 - by xoft - 10-17-2019, 06:23 AM
RE: Towards 1.13 - by xoft - 12-28-2019, 08:45 AM



Users browsing this thread: 7 Guest(s)