Search in sources :

Example 1 with Profiler

use of net.minecraft.util.profiler.Profiler in project sodium-fabric by CaffeineMC.

the class ChunkRenderManager method renderLayer.

public void renderLayer(RenderLayer renderLayer, MatrixStack matrixStack, double d, double e, double f) {
    Profiler profiler = this.client.getProfiler();
    renderLayer.startDrawing();
    // TODO: resort transparent
    // if (renderLayer == RenderLayer.getTranslucent()) {
    // profiler.push("translucent_sort");
    // 
    // double g = d - this.lastTranslucentSortX;
    // double h = e - this.lastTranslucentSortY;
    // double i = f - this.lastTranslucentSortZ;
    // 
    // if (g * g + h * h + i * i > 1.0D) {
    // this.lastTranslucentSortX = d;
    // this.lastTranslucentSortY = e;
    // this.lastTranslucentSortZ = f;
    // 
    // int j = 0;
    // 
    // for (ChunkGraphNode<T> chunkInfo : this.chunkGraph.getVisibleChunks()) {
    // if (j < 15 && chunkInfo.chunk.scheduleSort(renderLayer, this.chunkBuilder)) {
    // ++j;
    // }
    // }
    // }
    // 
    // profiler.pop();
    // }
    profiler.push("filterempty");
    profiler.swap(() -> "render_" + renderLayer);
    boolean notTranslucent = renderLayer != RenderLayer.getTranslucent();
    ObjectListIterator<ChunkGraphNode<T>> it = this.chunkGraph.getVisibleChunks().listIterator(notTranslucent ? 0 : this.chunkGraph.getVisibleChunkCount());
    this.chunkRenderer.begin();
    while (true) {
        if (notTranslucent) {
            if (!it.hasNext()) {
                break;
            }
        } else if (!it.hasPrevious()) {
            break;
        }
        ChunkGraphNode<T> info = notTranslucent ? it.next() : it.previous();
        ChunkRender<T> chunk = info.chunk;
        T data = chunk.getRenderData();
        if (data == null) {
            continue;
        }
        if (chunk.getMeshInfo().containsLayer(renderLayer)) {
            BlockPos origin = chunk.getOrigin();
            matrixStack.push();
            matrixStack.translate((double) origin.getX() - d, (double) origin.getY() - e, (double) origin.getZ() - f);
            this.chunkRenderer.render(matrixStack, renderLayer, data);
            matrixStack.pop();
        }
    }
    this.chunkRenderer.end();
    RenderSystem.clearCurrentColor();
    profiler.pop();
    renderLayer.endDrawing();
}
Also used : Profiler(net.minecraft.util.profiler.Profiler) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with Profiler

use of net.minecraft.util.profiler.Profiler in project LittleMaidModelLoader-Fabric by SistrScarlet.

the class MultiModelArmorLayer method render.

@Override
public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, T entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
    Profiler profiler = MinecraftClient.getInstance().getProfiler();
    profiler.push("littlemaidmodelloader:mm_armor_layer");
    this.renderArmorPart(matrices, vertexConsumers, light, entity, limbAngle, limbDistance, tickDelta, animationProgress, headYaw, headPitch, IHasMultiModel.Part.HEAD);
    this.renderArmorPart(matrices, vertexConsumers, light, entity, limbAngle, limbDistance, tickDelta, animationProgress, headYaw, headPitch, IHasMultiModel.Part.BODY);
    this.renderArmorPart(matrices, vertexConsumers, light, entity, limbAngle, limbDistance, tickDelta, animationProgress, headYaw, headPitch, IHasMultiModel.Part.LEGS);
    this.renderArmorPart(matrices, vertexConsumers, light, entity, limbAngle, limbDistance, tickDelta, animationProgress, headYaw, headPitch, IHasMultiModel.Part.FEET);
    profiler.pop();
}
Also used : Profiler(net.minecraft.util.profiler.Profiler)

Example 3 with Profiler

use of net.minecraft.util.profiler.Profiler in project LittleMaidModelLoader-Fabric by SistrScarlet.

the class MultiModelLightLayer method render.

@Override
public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, T entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
    Profiler profiler = MinecraftClient.getInstance().getProfiler();
    profiler.push("littlemaidmodelloader:mm_eye_layer");
    renderLightLayer(matrices, vertexConsumers, entity, limbAngle, limbDistance, tickDelta, animationProgress, headYaw, headPitch, entity.getCaps());
    profiler.pop();
}
Also used : Profiler(net.minecraft.util.profiler.Profiler)

Example 4 with Profiler

use of net.minecraft.util.profiler.Profiler in project roadrunner by MaxNeedsSnacks.

the class WorldMixin method postBlockEntityTick.

// Add any pending block entities to the world.
@Inject(method = "tickBlockEntities", at = @At("RETURN"))
private void postBlockEntityTick(CallbackInfo ci) {
    Profiler profiler = this.profiler.get();
    profiler.push("pendingBlockEntities$lithium");
    this.blockEntities$lithium.checkOffThreadModifications(false);
    this.pendingBlockEntities$lithium.checkOffThreadModifications(false);
    // The overhead of this is essentially non-zero and doesn't matter in this code.
    for (BlockEntity entity : this.pendingBlockEntities) {
        if (entity.isRemoved()) {
            continue;
        }
        // Try-add directly to avoid the double map lookup, helps speed things along
        if (this.blockEntities$lithium.addIfAbsent(entity)) {
            // vanilla has an extra updateListeners(...) call on the client here, but the one below should be enough
            if (entity instanceof Tickable) {
                this.tickingBlockEntities.add(entity);
            }
            BlockPos pos = entity.getPos();
            World thisWorld = (World) (Object) this;
            if (entity.getWorld() != thisWorld) {
                entity.setLocation(thisWorld, pos);
            }
            entity.onLoad();
            // Avoid the double chunk lookup (isLoaded followed by getChunk) by simply inlining getChunk call
            // pass this.isClient instead of false, so the updateListeners call is always executed on the client (like vanilla)
            Chunk chunk = this.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.FULL, this.isClient);
            if (chunk != null) {
                BlockState state = chunk.getBlockState(pos);
                chunk.setBlockEntity(pos, entity);
                this.updateListeners(pos, state, state, 3);
            }
        }
    }
    this.pendingBlockEntities.clear();
    profiler.pop();
}
Also used : BlockState(net.minecraft.block.BlockState) Profiler(net.minecraft.util.profiler.Profiler) Tickable(net.minecraft.util.Tickable) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) Chunk(net.minecraft.world.chunk.Chunk) BlockEntity(net.minecraft.block.entity.BlockEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 5 with Profiler

use of net.minecraft.util.profiler.Profiler in project SpeedRunIGT by RedLime.

the class MinecraftClientMixin method onInit.

/**
 * Add import font system
 */
@Inject(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/debug/DebugRenderer;<init>(Lnet/minecraft/client/MinecraftClient;)V", shift = At.Shift.BEFORE))
public void onInit(RunArgs args, CallbackInfo ci) {
    this.resourceManager.registerListener(new SinglePreparationResourceReloadListener<Map<Identifier, List<Font>>>() {

        @Override
        protected Map<Identifier, List<Font>> prepare(ResourceManager manager, Profiler profiler) {
            SpeedRunIGT.FONT_MAPS.clear();
            try {
                HashMap<Identifier, List<Font>> map = new HashMap<>();
                File[] fontFiles = SpeedRunIGT.FONT_PATH.toFile().listFiles();
                if (fontFiles == null)
                    return new HashMap<>();
                for (File file : Arrays.stream(fontFiles).filter(file -> file.getName().endsWith(".ttf")).collect(Collectors.toList())) {
                    File config = SpeedRunIGT.FONT_PATH.resolve(file.getName().substring(0, file.getName().length() - 4) + ".json").toFile();
                    if (config.exists()) {
                        FontUtils.addFont(map, file, config);
                    } else {
                        FontUtils.addFont(map, file, null);
                    }
                }
                return map;
            } catch (Throwable e) {
                return new HashMap<>();
            }
        }

        @Override
        protected void apply(Map<Identifier, List<Font>> loader, ResourceManager manager, Profiler profiler) {
            try {
                FontManagerAccessor fontManager = (FontManagerAccessor) ((MinecraftClientAccessor) MinecraftClient.getInstance()).getFontManager();
                for (Map.Entry<Identifier, List<Font>> listEntry : loader.entrySet()) {
                    FontStorage fontStorage = new FontStorage(fontManager.getTextureManager(), listEntry.getKey());
                    fontStorage.setFonts(listEntry.getValue());
                    fontManager.getFontStorages().put(listEntry.getKey(), fontStorage);
                }
                TimerDrawer.fontHeightMap.clear();
            } catch (Throwable e) {
                SpeedRunIGT.error("Error! failed import timer fonts!");
                e.printStackTrace();
            }
        }
    });
}
Also used : MinecraftClientAccessor(com.redlimerl.speedrunigt.mixins.access.MinecraftClientAccessor) HashMap(java.util.HashMap) ReloadableResourceManager(net.minecraft.resource.ReloadableResourceManager) ResourceManager(net.minecraft.resource.ResourceManager) Font(net.minecraft.client.font.Font) Identifier(net.minecraft.util.Identifier) Profiler(net.minecraft.util.profiler.Profiler) FontStorage(net.minecraft.client.font.FontStorage) FontManagerAccessor(com.redlimerl.speedrunigt.mixins.access.FontManagerAccessor) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) File(java.io.File) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

Profiler (net.minecraft.util.profiler.Profiler)6 Identifier (net.minecraft.util.Identifier)2 BlockPos (net.minecraft.util.math.BlockPos)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 FontManagerAccessor (com.redlimerl.speedrunigt.mixins.access.FontManagerAccessor)1 MinecraftClientAccessor (com.redlimerl.speedrunigt.mixins.access.MinecraftClientAccessor)1 File (java.io.File)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 EnvType (net.fabricmc.api.EnvType)1 Environment (net.fabricmc.api.Environment)1 BlockState (net.minecraft.block.BlockState)1 BlockEntity (net.minecraft.block.entity.BlockEntity)1 MinecraftClient (net.minecraft.client.MinecraftClient)1 Font (net.minecraft.client.font.Font)1 FontStorage (net.minecraft.client.font.FontStorage)1 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)1 EntityRenderDispatcher (net.minecraft.client.render.entity.EntityRenderDispatcher)1 LivingEntityRenderer (net.minecraft.client.render.entity.LivingEntityRenderer)1