SKL can use SIMD4X2 when msg type is LD, should use SIMD8. Add the Gen9Encoder for it.
Signed-off-by: Yang Rong <[email protected]> --- backend/src/CMakeLists.txt | 2 ++ backend/src/backend/gen9_context.hpp | 10 +++--- backend/src/backend/gen9_encoder.cpp | 68 ++++++++++++++++++++++++++++++++++++ backend/src/backend/gen9_encoder.hpp | 53 ++++++++++++++++++++++++++++ backend/src/backend/gen_encoder.cpp | 39 ++++++++++----------- backend/src/backend/gen_encoder.hpp | 11 +++++- 6 files changed, 157 insertions(+), 26 deletions(-) create mode 100644 backend/src/backend/gen9_encoder.cpp create mode 100644 backend/src/backend/gen9_encoder.hpp diff --git a/backend/src/CMakeLists.txt b/backend/src/CMakeLists.txt index 861bbdd..e84833a 100644 --- a/backend/src/CMakeLists.txt +++ b/backend/src/CMakeLists.txt @@ -123,6 +123,8 @@ set (GBE_SRC backend/gen75_encoder.cpp backend/gen8_encoder.hpp backend/gen8_encoder.cpp + backend/gen9_encoder.hpp + backend/gen9_encoder.cpp ) set (GBE_LINK_LIBRARIES diff --git a/backend/src/backend/gen9_context.hpp b/backend/src/backend/gen9_context.hpp index 76d36fc..4123414 100644 --- a/backend/src/backend/gen9_context.hpp +++ b/backend/src/backend/gen9_context.hpp @@ -23,7 +23,7 @@ #define __GBE_gen9_CONTEXT_HPP__ #include "backend/gen8_context.hpp" -#include "backend/gen8_encoder.hpp" +#include "backend/gen9_encoder.hpp" namespace gbe { @@ -37,10 +37,10 @@ namespace gbe : Gen8Context(unit, name, deviceID, relaxMath) { }; - protected: - virtual GenEncoder* generateEncoder(void) { - return GBE_NEW(Gen8Encoder, this->simdWidth, 9, deviceID); - } + protected: + virtual GenEncoder* generateEncoder(void) { + return GBE_NEW(Gen9Encoder, this->simdWidth, 9, deviceID); + } private: virtual void newSelection(void); diff --git a/backend/src/backend/gen9_encoder.cpp b/backend/src/backend/gen9_encoder.cpp new file mode 100644 index 0000000..80df50d --- /dev/null +++ b/backend/src/backend/gen9_encoder.cpp @@ -0,0 +1,68 @@ +/* + Copyright (C) Intel Corp. 2006. All Rights Reserved. + Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to + develop this 3D driver. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice (including the + next paragraph) shall be included in all copies or substantial + portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + **********************************************************************/ + +#include "backend/gen9_encoder.hpp" + +namespace gbe +{ + void Gen9Encoder::SAMPLE(GenRegister dest, + GenRegister msg, + unsigned int msg_len, + bool header_present, + unsigned char bti, + unsigned char sampler, + uint32_t simdWidth, + uint32_t writemask, + uint32_t return_format, + bool isLD, + bool isUniform) + { + if (writemask == 0) return; + uint32_t msg_type = isLD ? GEN_SAMPLER_MESSAGE_SIMD8_LD : + GEN_SAMPLER_MESSAGE_SIMD8_SAMPLE; + uint32_t response_length = (4 * (simdWidth / 8)); + uint32_t msg_length = (msg_len * (simdWidth / 8)); + if (header_present) + msg_length++; + uint32_t simd_mode = (simdWidth == 16) ? + GEN_SAMPLER_SIMD_MODE_SIMD16 : GEN_SAMPLER_SIMD_MODE_SIMD8; + if(isUniform) { + response_length = 1; + msg_type = GEN_SAMPLER_MESSAGE_SIMD4X2_LD; + msg_length = 1; + simd_mode = GEN_SAMPLER_SIMD_MODE_SIMD8; + } + GenNativeInstruction *insn = this->next(GEN_OPCODE_SEND); + this->setHeader(insn); + this->setDst(insn, dest); + this->setSrc0(insn, msg); + setSamplerMessage(insn, bti, sampler, msg_type, + response_length, msg_length, + header_present, + simd_mode, return_format); + } +} /* End of the name space. */ diff --git a/backend/src/backend/gen9_encoder.hpp b/backend/src/backend/gen9_encoder.hpp new file mode 100644 index 0000000..319e871 --- /dev/null +++ b/backend/src/backend/gen9_encoder.hpp @@ -0,0 +1,53 @@ +/* + * Copyright © 2012 Intel Corporation + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ + +/** + * \file gen9_context.hpp + */ +#ifndef __GBE_GEN9_ENCODER_HPP__ +#define __GBE_GEN9_ENCODER_HPP__ + +#include "backend/gen8_encoder.hpp" + +namespace gbe +{ + /* This class is used to implement the SKL + specific logic for encoder. */ + class Gen9Encoder : public Gen8Encoder + { + public: + virtual ~Gen9Encoder(void) { } + + Gen9Encoder(uint32_t simdWidth, uint32_t gen, uint32_t deviceID) + : Gen8Encoder(simdWidth, gen, deviceID) { } + /*! Send instruction for the sampler */ + virtual void SAMPLE(GenRegister dest, + GenRegister msg, + unsigned int msg_len, + bool header_present, + unsigned char bti, + unsigned char sampler, + unsigned int simdWidth, + uint32_t writemask, + uint32_t return_format, + bool isLD, + bool isUniform); + + }; +} +#endif /* __GBE_GEN9_ENCODER_HPP__ */ diff --git a/backend/src/backend/gen_encoder.cpp b/backend/src/backend/gen_encoder.cpp index 4d45811..5bf7df6 100644 --- a/backend/src/backend/gen_encoder.cpp +++ b/backend/src/backend/gen_encoder.cpp @@ -275,25 +275,6 @@ namespace gbe } #endif - static void setSamplerMessage(GenEncoder *p, - GenNativeInstruction *insn, - unsigned char bti, - unsigned char sampler, - uint32_t msg_type, - uint32_t response_length, - uint32_t msg_length, - bool header_present, - uint32_t simd_mode, - uint32_t return_format) - { - const GenMessageTarget sfid = GEN_SFID_SAMPLER; - p->setMessageDescriptor(insn, sfid, msg_length, response_length); - insn->bits3.sampler_gen7.bti = bti; - insn->bits3.sampler_gen7.sampler = sampler; - insn->bits3.sampler_gen7.msg_type = msg_type; - insn->bits3.sampler_gen7.simd_mode = simd_mode; - } - static void setDWordScatterMessgae(GenEncoder *p, GenNativeInstruction *insn, uint32_t bti, @@ -1095,6 +1076,24 @@ namespace gbe this->setSrc0(insn, src); } + void GenEncoder::setSamplerMessage(GenNativeInstruction *insn, + unsigned char bti, + unsigned char sampler, + uint32_t msg_type, + uint32_t response_length, + uint32_t msg_length, + bool header_present, + uint32_t simd_mode, + uint32_t return_format) + { + const GenMessageTarget sfid = GEN_SFID_SAMPLER; + setMessageDescriptor(insn, sfid, msg_length, response_length); + insn->bits3.sampler_gen7.bti = bti; + insn->bits3.sampler_gen7.sampler = sampler; + insn->bits3.sampler_gen7.msg_type = msg_type; + insn->bits3.sampler_gen7.simd_mode = simd_mode; + } + void GenEncoder::SAMPLE(GenRegister dest, GenRegister msg, unsigned int msg_len, @@ -1126,7 +1125,7 @@ namespace gbe this->setHeader(insn); this->setDst(insn, dest); this->setSrc0(insn, msg); - setSamplerMessage(this, insn, bti, sampler, msg_type, + setSamplerMessage(insn, bti, sampler, msg_type, response_length, msg_length, header_present, simd_mode, return_format); diff --git a/backend/src/backend/gen_encoder.hpp b/backend/src/backend/gen_encoder.hpp index 1a6f75c..21faabc 100644 --- a/backend/src/backend/gen_encoder.hpp +++ b/backend/src/backend/gen_encoder.hpp @@ -185,7 +185,7 @@ namespace gbe /*! for scratch memory write */ void SCRATCH_WRITE(GenRegister msg, uint32_t offset, uint32_t size, uint32_t src_num, uint32_t channel_mode); /*! Send instruction for the sampler */ - void SAMPLE(GenRegister dest, + virtual void SAMPLE(GenRegister dest, GenRegister msg, unsigned int msg_len, bool header_present, @@ -196,6 +196,15 @@ namespace gbe uint32_t return_format, bool isLD, bool isUniform); + void setSamplerMessage(GenNativeInstruction *insn, + unsigned char bti, + unsigned char sampler, + uint32_t msg_type, + uint32_t response_length, + uint32_t msg_length, + bool header_present, + uint32_t simd_mode, + uint32_t return_format); /*! TypedWrite instruction for texture */ virtual void TYPED_WRITE(GenRegister header, -- 1.8.3.2 _______________________________________________ Beignet mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/beignet
