GlRenderPass.java

com.mojang.blaze3d.opengl.GlRenderPass

信息

  • 全限定名:com.mojang.blaze3d.opengl.GlRenderPass
  • 类型:package-private class
  • 包:com.mojang.blaze3d.opengl
  • 源码路径:src/main/java/com/mojang/blaze3d/opengl/GlRenderPass.java
  • 起始行号:L23
  • 实现:RenderPassBackend
  • 职责:

    TODO

字段/常量

  • MAX_VERTEX_BUFFERS

    • 类型: int
    • 修饰符: protected static final
    • 源码定位: L24
    • 说明:

      TODO

  • VALIDATION

    • 类型: boolean
    • 修饰符: public static final
    • 源码定位: L25
    • 说明:

      TODO

  • encoder

    • 类型: GlCommandEncoder
    • 修饰符: private final
    • 源码定位: L26
    • 说明:

      TODO

  • device

    • 类型: GlDevice
    • 修饰符: private final
    • 源码定位: L27
    • 说明:

      TODO

  • hasDepthTexture

    • 类型: boolean
    • 修饰符: private final
    • 源码定位: L28
    • 说明:

      TODO

  • closed

    • 类型: boolean
    • 修饰符: private
    • 源码定位: L29
    • 说明:

      TODO

  • pipeline

    • 类型: GlRenderPipeline
    • 修饰符: protected
    • 源码定位: L30
    • 说明:

      TODO

  • vertexBuffers

    • 类型: GpuBuffer[]
    • 修饰符: protected final
    • 源码定位: L31
    • 说明:

      TODO

  • indexBuffer

    • 类型: GpuBuffer
    • 修饰符: protected
    • 源码定位: L32
    • 说明:

      TODO

  • indexType

    • 类型: VertexFormat.IndexType
    • 修饰符: protected
    • 源码定位: L33
    • 说明:

      TODO

  • scissorState

    • 类型: ScissorState
    • 修饰符: private final
    • 源码定位: L34
    • 说明:

      TODO

  • uniforms

    • 类型: HashMap<String,GpuBufferSlice>
    • 修饰符: protected final
    • 源码定位: L35
    • 说明:

      TODO

  • samplers

    • 类型: HashMap<String,GlRenderPass.TextureViewAndSampler>
    • 修饰符: protected final
    • 源码定位: L36
    • 说明:

      TODO

  • dirtyUniforms

    • 类型: Set<String>
    • 修饰符: protected final
    • 源码定位: L37
    • 说明:

      TODO

内部类/嵌套类型

  • com.mojang.blaze3d.opengl.GlRenderPass.TextureViewAndSampler
    • 类型: record
    • 修饰符: protected
    • 源码定位: L172
    • 说明:

      TODO

构造器

public GlRenderPass(GlCommandEncoder encoder, GlDevice device, boolean hasDepthTexture) @ L39

  • 构造器名:GlRenderPass
  • 源码定位:L39
  • 修饰符:public

参数:

  • encoder: GlCommandEncoder
  • device: GlDevice
  • hasDepthTexture: boolean

说明:

TODO

方法

下面的方法块按源码顺序生成。

public boolean hasDepthTexture() @ L45

  • 方法名:hasDepthTexture
  • 源码定位:L45
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public void pushDebugGroup(Supplier<String> label) @ L49

  • 方法名:pushDebugGroup
  • 源码定位:L49
  • 返回类型:void
  • 修饰符:public

参数:

  • label: Supplier

说明:

TODO

public void popDebugGroup() @ L54

  • 方法名:popDebugGroup
  • 源码定位:L54
  • 返回类型:void
  • 修饰符:public

参数:

说明:

TODO

public void setPipeline(RenderPipeline pipeline) @ L59

  • 方法名:setPipeline
  • 源码定位:L59
  • 返回类型:void
  • 修饰符:public

参数:

  • pipeline: RenderPipeline

说明:

TODO

public void bindTexture(String name, GpuTextureView textureView, GpuSampler sampler) @ L69

  • 方法名:bindTexture
  • 源码定位:L69
  • 返回类型:void
  • 修饰符:public

参数:

  • name: String
  • textureView: GpuTextureView
  • sampler: GpuSampler

说明:

TODO

public void setUniform(String name, GpuBuffer value) @ L80

  • 方法名:setUniform
  • 源码定位:L80
  • 返回类型:void
  • 修饰符:public

参数:

  • name: String
  • value: GpuBuffer

说明:

TODO

public void setUniform(String name, GpuBufferSlice value) @ L86

  • 方法名:setUniform
  • 源码定位:L86
  • 返回类型:void
  • 修饰符:public

参数:

  • name: String
  • value: GpuBufferSlice

说明:

TODO

public void enableScissor(int x, int y, int width, int height) @ L92

  • 方法名:enableScissor
  • 源码定位:L92
  • 返回类型:void
  • 修饰符:public

参数:

  • x: int
  • y: int
  • width: int
  • height: int

说明:

TODO

public void disableScissor() @ L97

  • 方法名:disableScissor
  • 源码定位:L97
  • 返回类型:void
  • 修饰符:public

参数:

说明:

TODO

public boolean isScissorEnabled() @ L102

  • 方法名:isScissorEnabled
  • 源码定位:L102
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public int getScissorX() @ L106

  • 方法名:getScissorX
  • 源码定位:L106
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public int getScissorY() @ L110

  • 方法名:getScissorY
  • 源码定位:L110
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public int getScissorWidth() @ L114

  • 方法名:getScissorWidth
  • 源码定位:L114
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public int getScissorHeight() @ L118

  • 方法名:getScissorHeight
  • 源码定位:L118
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public void setVertexBuffer(int slot, GpuBuffer vertexBuffer) @ L122

  • 方法名:setVertexBuffer
  • 源码定位:L122
  • 返回类型:void
  • 修饰符:public

参数:

  • slot: int
  • vertexBuffer: GpuBuffer

说明:

TODO

public void setIndexBuffer(GpuBuffer indexBuffer, VertexFormat.IndexType indexType) @ L131

  • 方法名:setIndexBuffer
  • 源码定位:L131
  • 返回类型:void
  • 修饰符:public

参数:

  • indexBuffer: GpuBuffer
  • indexType: VertexFormat.IndexType

说明:

TODO

public void drawIndexed(int baseVertex, int firstIndex, int indexCount, int instanceCount) @ L137

  • 方法名:drawIndexed
  • 源码定位:L137
  • 返回类型:void
  • 修饰符:public

参数:

  • baseVertex: int
  • firstIndex: int
  • indexCount: int
  • instanceCount: int

说明:

TODO

public <T> void drawMultipleIndexed(Collection<RenderPass.Draw<T>> draws, GpuBuffer defaultIndexBuffer, VertexFormat.IndexType defaultIndexType, Collection<String> dynamicUniforms, T uniformArgument) @ L142

  • 方法名:drawMultipleIndexed
  • 源码定位:L142
  • 返回类型: void
  • 修饰符:public

参数:

  • draws: Collection<RenderPass.Draw>
  • defaultIndexBuffer: GpuBuffer
  • defaultIndexType: VertexFormat.IndexType
  • dynamicUniforms: Collection
  • uniformArgument: T

说明:

TODO

public void draw(int firstVertex, int vertexCount) @ L153

  • 方法名:draw
  • 源码定位:L153
  • 返回类型:void
  • 修饰符:public

参数:

  • firstVertex: int
  • vertexCount: int

说明:

TODO

public void close() @ L158

  • 方法名:close
  • 源码定位:L158
  • 返回类型:void
  • 修饰符:public

参数:

说明:

TODO

public boolean isClosed() @ L166

  • 方法名:isClosed
  • 源码定位:L166
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
class GlRenderPass implements RenderPassBackend {
    protected static final int MAX_VERTEX_BUFFERS = 1;
    public static final boolean VALIDATION = SharedConstants.IS_RUNNING_IN_IDE;
    private final GlCommandEncoder encoder;
    private final GlDevice device;
    private final boolean hasDepthTexture;
    private boolean closed;
    protected @Nullable GlRenderPipeline pipeline;
    protected final @Nullable GpuBuffer[] vertexBuffers = new GpuBuffer[1];
    protected @Nullable GpuBuffer indexBuffer;
    protected VertexFormat.IndexType indexType = VertexFormat.IndexType.INT;
    private final ScissorState scissorState = new ScissorState();
    protected final HashMap<String, GpuBufferSlice> uniforms = new HashMap<>();
    protected final HashMap<String, GlRenderPass.TextureViewAndSampler> samplers = new HashMap<>();
    protected final Set<String> dirtyUniforms = new HashSet<>();
 
    public GlRenderPass(GlCommandEncoder encoder, GlDevice device, boolean hasDepthTexture) {
        this.encoder = encoder;
        this.device = device;
        this.hasDepthTexture = hasDepthTexture;
    }
 
    public boolean hasDepthTexture() {
        return this.hasDepthTexture;
    }
 
    @Override
    public void pushDebugGroup(Supplier<String> label) {
        this.device.debugLabels().pushDebugGroup(label);
    }
 
    @Override
    public void popDebugGroup() {
        this.device.debugLabels().popDebugGroup();
    }
 
    @Override
    public void setPipeline(RenderPipeline pipeline) {
        if (this.pipeline == null || this.pipeline.info() != pipeline) {
            this.dirtyUniforms.addAll(this.uniforms.keySet());
            this.dirtyUniforms.addAll(this.samplers.keySet());
        }
 
        this.pipeline = this.device.getOrCompilePipeline(pipeline);
    }
 
    @Override
    public void bindTexture(String name, @Nullable GpuTextureView textureView, @Nullable GpuSampler sampler) {
        if (sampler == null) {
            this.samplers.remove(name);
        } else {
            this.samplers.put(name, new GlRenderPass.TextureViewAndSampler((GlTextureView)textureView, (GlSampler)sampler));
        }
 
        this.dirtyUniforms.add(name);
    }
 
    @Override
    public void setUniform(String name, GpuBuffer value) {
        this.uniforms.put(name, value.slice());
        this.dirtyUniforms.add(name);
    }
 
    @Override
    public void setUniform(String name, GpuBufferSlice value) {
        this.uniforms.put(name, value);
        this.dirtyUniforms.add(name);
    }
 
    @Override
    public void enableScissor(int x, int y, int width, int height) {
        this.scissorState.enable(x, y, width, height);
    }
 
    @Override
    public void disableScissor() {
        this.scissorState.disable();
    }
 
    public boolean isScissorEnabled() {
        return this.scissorState.enabled();
    }
 
    public int getScissorX() {
        return this.scissorState.x();
    }
 
    public int getScissorY() {
        return this.scissorState.y();
    }
 
    public int getScissorWidth() {
        return this.scissorState.width();
    }
 
    public int getScissorHeight() {
        return this.scissorState.height();
    }
 
    @Override
    public void setVertexBuffer(int slot, GpuBuffer vertexBuffer) {
        if (slot >= 0 && slot < 1) {
            this.vertexBuffers[slot] = vertexBuffer;
        } else {
            throw new IllegalArgumentException("Vertex buffer slot is out of range: " + slot);
        }
    }
 
    @Override
    public void setIndexBuffer(@Nullable GpuBuffer indexBuffer, VertexFormat.IndexType indexType) {
        this.indexBuffer = indexBuffer;
        this.indexType = indexType;
    }
 
    @Override
    public void drawIndexed(int baseVertex, int firstIndex, int indexCount, int instanceCount) {
        this.encoder.executeDraw(this, baseVertex, firstIndex, indexCount, this.indexType, instanceCount);
    }
 
    @Override
    public <T> void drawMultipleIndexed(
        Collection<RenderPass.Draw<T>> draws,
        @Nullable GpuBuffer defaultIndexBuffer,
        VertexFormat.@Nullable IndexType defaultIndexType,
        Collection<String> dynamicUniforms,
        T uniformArgument
    ) {
        this.encoder.executeDrawMultiple(this, draws, defaultIndexBuffer, defaultIndexType, dynamicUniforms, uniformArgument);
    }
 
    @Override
    public void draw(int firstVertex, int vertexCount) {
        this.encoder.executeDraw(this, firstVertex, 0, vertexCount, null, 1);
    }
 
    @Override
    public void close() {
        if (!this.closed) {
            this.closed = true;
            this.encoder.finishRenderPass();
        }
    }
 
    @Override
    public boolean isClosed() {
        return this.closed;
    }
 
    @OnlyIn(Dist.CLIENT)
    protected record TextureViewAndSampler(GlTextureView view, GlSampler sampler) {
    }
}

引用的其他类